From 153b7ac6c4c99d4ab50d4345c0673f30d1dd11c0 Mon Sep 17 00:00:00 2001 From: dustoair <107600816+dustoair@users.noreply.github.com> Date: Sat, 17 Sep 2022 17:27:09 +0800 Subject: [PATCH] , timestamp, nonce string, w http.ResponseWriter --- .gitignore | 3 ++- goCharts/draw.go | 22 ++++++---------------- goCharts/draw_test.go | 14 ++++++++++++++ handle/replyImage.go | 4 ++-- handle/replyText.go | 5 +++-- 5 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 goCharts/draw_test.go diff --git a/.gitignore b/.gitignore index 1b08030..b2d1e95 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ cert challenge .env application.yaml -nogit_test.go \ No newline at end of file +nogit_test.go +/goCharts/tmp/ diff --git a/goCharts/draw.go b/goCharts/draw.go index 5db5194..bf006db 100644 --- a/goCharts/draw.go +++ b/goCharts/draw.go @@ -52,15 +52,6 @@ func Draw() { 330, 320, }, - { - 820, - 932, - 901, - 934, - 1290, - 1330, - 1320, - }, } p, err := charts.LineRender( values, @@ -68,7 +59,7 @@ func Draw() { charts.ThemeOptionFunc(charts.ThemeGrafana), charts.WidthOptionFunc(720), charts.HeightOptionFunc(1280), - charts.TitleTextOptionFunc("Line"), + charts.TitleTextOptionFunc("symbol price"), charts.XAxisDataOptionFunc([]string{ "Mon", "Tue", @@ -79,12 +70,11 @@ func Draw() { "Sun", }), charts.LegendLabelsOptionFunc([]string{ - "Email", - "Union Ads", - "Video Ads", - "Direct", - "Search Engine", - }, "50"), + "BTC", + "ETH", + "BNB", + "TRX", + }, "150"), func(opt *charts.ChartOption) { opt.Legend.Padding = charts.Box{ Top: 5, diff --git a/goCharts/draw_test.go b/goCharts/draw_test.go new file mode 100644 index 0000000..e69d148 --- /dev/null +++ b/goCharts/draw_test.go @@ -0,0 +1,14 @@ +package goCharts + +import "testing" + +/* +* +@author: sre +@date: 2022/9/17 0017 +@desc: todo +* +*/ +func TestDraw(t *testing.T) { + Draw() +} diff --git a/handle/replyImage.go b/handle/replyImage.go index b47f49b..f55798b 100644 --- a/handle/replyImage.go +++ b/handle/replyImage.go @@ -8,7 +8,7 @@ import ( "net/http" ) -func replyImage(msgContent MsgContent, timestamp, nonce string, w http.ResponseWriter) { +func replyImageDraw(msgContent MsgContent, timestamp, nonce string, w http.ResponseWriter) { //third_part.SendPicMid(msgContent.FromUsername, utils.RandMapValue(global.ImageMap)) goCharts.Draw() filename := "tmp/line-chart.png" @@ -16,7 +16,7 @@ func replyImage(msgContent MsgContent, timestamp, nonce string, w http.ResponseW third_part.SendPicFile(msgContent.FromUsername, filename) } -func replyImageEmoj(msgContent MsgContent, timestamp, nonce string, w http.ResponseWriter) { +func replyImage(msgContent MsgContent, timestamp, nonce string, w http.ResponseWriter) { //third_part.SendPicMid(msgContent.FromUsername, utils.RandMapValue(global.ImageMap)) filename := global.WechatImagePath + "/" + utils.RandomFile(global.WechatImagePath) go RecordWechatLog(msgContent.FromUsername, msgContent.ToUsername, msgContent.CreateTime, msgContent.MsgType, filename) diff --git a/handle/replyText.go b/handle/replyText.go index 2b7cb53..3ffa23e 100644 --- a/handle/replyText.go +++ b/handle/replyText.go @@ -12,7 +12,7 @@ import ( ) // cmdExec 根据白名单命令来执行 -func cmdExec(msgContent MsgContent) (replyContent string) { +func cmdExec(msgContent MsgContent, timestamp, nonce string, w http.ResponseWriter) (replyContent string) { var cmdString string switch msgContent.Content { case "last": @@ -42,6 +42,7 @@ func cmdExec(msgContent MsgContent) (replyContent string) { priceTRX := api.GetBinanceLatestPrice("TRXUSDT") priceBNB := api.GetBinanceLatestPrice("BNBUSDT") replyContent = fmt.Sprintf("BTC价格: %f \nETH价格: %f \nTRX价格: %f \nBNB价格: %f", priceBTC, priceETH, priceTRX, priceBNB) + replyImageDraw(msgContent, timestamp, nonce, w) return case "gold", "黄金": @@ -88,7 +89,7 @@ func replyText(msgContent MsgContent, timestamp, nonce string, w http.ResponseWr if global.EnableCmdExec && utils.SliceContain(global.CMDList, msgContent.Content) && msgContent.FromUsername == "QiaoYang" { //开启了命令执行功能,并且消息内容包含了命令 log.Println("收到命令消息") - replyContent = cmdExec(msgContent) + replyContent = cmdExec(msgContent, timestamp, nonce, w) } else { log.Println("ai msg") replyContent = aiReply(msgContent)