mirror of
https://github.com/woodchen-ink/Q58Bot.git
synced 2025-07-18 05:42:06 +08:00
修复无效符号问题
This commit is contained in:
parent
04ff32efdd
commit
cef184fcc0
@ -76,7 +76,7 @@ func sendPriceUpdate() {
|
|||||||
message := fmt.Sprintf("市场更新 - %s (SGT)\n\n", now.Format("2006-01-02 15:04:05"))
|
message := fmt.Sprintf("市场更新 - %s (SGT)\n\n", now.Format("2006-01-02 15:04:05"))
|
||||||
|
|
||||||
for _, symbol := range symbols {
|
for _, symbol := range symbols {
|
||||||
info, err := getTickerInfo(symbol)
|
info, err := getTickerInfo(symbol) // 直接使用完整的交易对名称
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error getting ticker info for %s: %v", symbol, err)
|
log.Printf("Error getting ticker info for %s: %v", symbol, err)
|
||||||
continue
|
continue
|
||||||
|
@ -30,11 +30,11 @@ func LoadSymbols() error {
|
|||||||
symbols = nil // 清空旧的符号列表
|
symbols = nil // 清空旧的符号列表
|
||||||
for _, symbol := range exchangeInfo.Symbols {
|
for _, symbol := range exchangeInfo.Symbols {
|
||||||
if symbol.Status == "TRADING" && symbol.QuoteAsset == "USDT" {
|
if symbol.Status == "TRADING" && symbol.QuoteAsset == "USDT" {
|
||||||
symbols = append(symbols, symbol.BaseAsset)
|
symbols = append(symbols, symbol.Symbol) // 使用完整的交易对名称
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Loaded %d trading pairs", len(symbols))
|
log.Printf("Loaded %d valid USDT trading pairs", len(symbols))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,14 +60,12 @@ func StartSymbolRefresh(interval time.Duration) {
|
|||||||
|
|
||||||
// HandleSymbolQuery 处理虚拟币名查询
|
// HandleSymbolQuery 处理虚拟币名查询
|
||||||
func HandleSymbolQuery(bot *tgbotapi.BotAPI, message *tgbotapi.Message) {
|
func HandleSymbolQuery(bot *tgbotapi.BotAPI, message *tgbotapi.Message) {
|
||||||
// 获取所有虚拟币名
|
|
||||||
symbols := GetAllSymbols()
|
symbols := GetAllSymbols()
|
||||||
|
upperMsg := strings.ToUpper(message.Text)
|
||||||
|
|
||||||
// 检查消息内容中是否包含虚拟币名
|
|
||||||
for _, symbol := range symbols {
|
for _, symbol := range symbols {
|
||||||
if strings.Contains(strings.ToUpper(message.Text), symbol) {
|
if strings.Contains(upperMsg, strings.TrimSuffix(symbol, "USDT")) {
|
||||||
// 查询价格并回复
|
info, err := getTickerInfo(symbol)
|
||||||
info, err := getTickerInfo(symbol + "USDT") // 查询对应USDT价格
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error getting ticker info for %s: %v", symbol, err)
|
log.Printf("Error getting ticker info for %s: %v", symbol, err)
|
||||||
return
|
return
|
||||||
@ -79,7 +77,7 @@ func HandleSymbolQuery(bot *tgbotapi.BotAPI, message *tgbotapi.Message) {
|
|||||||
msg := tgbotapi.NewMessage(message.Chat.ID, replyMessage)
|
msg := tgbotapi.NewMessage(message.Chat.ID, replyMessage)
|
||||||
msg.ParseMode = "Markdown"
|
msg.ParseMode = "Markdown"
|
||||||
bot.Send(msg)
|
bot.Send(msg)
|
||||||
return // 找到并回复后退出
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user