From 8706dda30394d3c6536efb9c3fb59ff79cbc6006 Mon Sep 17 00:00:00 2001 From: dustoair <107600816+dustoair@users.noreply.github.com> Date: Sat, 17 Sep 2022 08:30:10 +0800 Subject: [PATCH] add bnb and trx prcie --- global/cmds.go | 6 +----- handle/replyText.go | 42 ++++-------------------------------------- 2 files changed, 5 insertions(+), 43 deletions(-) diff --git a/global/cmds.go b/global/cmds.go index 750f4a1..64ac027 100644 --- a/global/cmds.go +++ b/global/cmds.go @@ -8,11 +8,7 @@ var CMDList = []string{ "last", "删除图片", "删除文本", - "ETH", - "eth", - "BTC", - "btc", - "虚拟货币", + "虚拟货币", "ETH", "eth", "BTC", "btc", "trx", "TRX", "BNB", "bnb", "gold", "黄金", "ip", diff --git a/handle/replyText.go b/handle/replyText.go index 9b36a90..2300993 100644 --- a/handle/replyText.go +++ b/handle/replyText.go @@ -36,10 +36,12 @@ func cmdExec(msgContent MsgContent) (replyContent string) { textMd5 := utils.Md5String(lastText.Content) go RecordWechatBlockWords(lastText.Content, textMd5, msgContent.FromUsername) return - case "eth", "btc", "ETH", "BTC", "虚拟货币": + case "虚拟货币", "ETH", "eth", "BTC", "btc", "trx", "TRX", "BNB", "bnb": priceBTC := api.GetBinanceLatestPrice("BTCUSDT") priceETH := api.GetBinanceLatestPrice("ETHUSDT") - replyContent = fmt.Sprintf("BTC价格: %f \n ETH价格: %f", priceBTC, priceETH) + priceTRX := api.GetBinanceLatestPrice("TRXUSDT") + priceBNB := api.GetBinanceLatestPrice("BNBUSDT") + replyContent = fmt.Sprintf("BTC价格: %f \n ETH价格: %f \n TRX价格: %f \n BNB价格: %f", priceBTC, priceETH, priceTRX, priceBNB) return case "gold", "黄金": @@ -87,42 +89,6 @@ func replyText(msgContent MsgContent, timestamp, nonce string, w http.ResponseWr //开启了命令执行功能,并且消息内容包含了命令 log.Println("收到命令消息") replyContent = cmdExec(msgContent) - //cmdString := cmdExec(msgContent) - //var cmdString string - //if msgContent.Content == "last" { - // cmdString = global.HistoryCmds[len(global.HistoryCmds)-1] - //} else if msgContent.Content == "history" { - // cmdString = utils.SlicePrint(global.HistoryCmds) - //} else if msgContent.Content == "删除图片" { - // //通过文本消息删除上一张图片 - // lastImg := GetLastWechatLog(msgContent.FromUsername, "image") - // err := utils.DeleteFile(lastImg.Content) - // if err != nil { - // log.Println("删除图片失败: ", lastImg.Content) - // return - // } else { - // log.Println("图片已删除: ", lastImg.Content) - // return - // } - // - //} else if msgContent.Content == "删除文本" { - // //通过文本消息删除上一条文本消息 - // lastText := GetLastWechatLog(msgContent.FromUsername, "text") - // textMd5 := utils.Md5String(lastText.Content) - // go RecordWechatBlockWords(lastText.Content, textMd5, msgContent.FromUsername) - // return - // - //} else { - // cmdString = msgContent.Content - //} - //global.HistoryCmds = append(global.HistoryCmds, msgContent.Content) - //replyContent, err := utils.CMDShellTrick(cmdString) - //if err != nil { - // replyContent = "/:,@!执行失败:\n" + msgContent.Content - //} else { - // replyContent = "/::D执行成功:\n" + replyContent - // //aiAnswer = "执行命令:" + msgContent.Content - //} } else { log.Println("ai msg") replyContent = aiReply(msgContent)