From 9e32b2966adf3d5b1f3dd2c1ccadcc1f25aaf7b1 Mon Sep 17 00:00:00 2001 From: dustoair <107600816+dustoair@users.noreply.github.com> Date: Sat, 17 Sep 2022 19:31:29 +0800 Subject: [PATCH] symbol price --- goCharts/draw.go | 10 +++------- handle/replyImage.go | 4 ++-- handle/replyText.go | 5 ++++- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/goCharts/draw.go b/goCharts/draw.go index 43a7ffd..93b0325 100644 --- a/goCharts/draw.go +++ b/goCharts/draw.go @@ -25,13 +25,11 @@ func getRand(len int) []float64 { return res } -func Draw() { - timeUpdate, symbolPriceETH := api.GetSerivers("ETHUSDT") - timeUpdate, symbolPriceBNB := api.GetSerivers("BNBUSDT") +func Draw(symbol string) { + timeUpdate, symbolPriceETH := api.GetSerivers(symbol) log.Println(timeUpdate, symbolPriceETH) values := [][]float64{ symbolPriceETH, - symbolPriceBNB, //getRand(30), //getRand(30), //getRand(30), @@ -46,9 +44,7 @@ func Draw() { charts.XAxisDataOptionFunc(timeUpdate), //charts.XAxisDataOptionFunc(getLastDays(30)), charts.LegendLabelsOptionFunc([]string{ - "BTC", - "ETH", - "BNB", + symbol, //"TRX", }, "150"), func(opt *charts.ChartOption) { diff --git a/handle/replyImage.go b/handle/replyImage.go index f55798b..8e4602e 100644 --- a/handle/replyImage.go +++ b/handle/replyImage.go @@ -8,9 +8,9 @@ import ( "net/http" ) -func replyImageDraw(msgContent MsgContent, timestamp, nonce string, w http.ResponseWriter) { +func replyImageDraw(msgContent MsgContent, timestamp, nonce string, w http.ResponseWriter, symbol string) { //third_part.SendPicMid(msgContent.FromUsername, utils.RandMapValue(global.ImageMap)) - goCharts.Draw() + goCharts.Draw(symbol) filename := "tmp/line-chart.png" go RecordWechatLog(msgContent.FromUsername, msgContent.ToUsername, msgContent.CreateTime, msgContent.MsgType, filename) third_part.SendPicFile(msgContent.FromUsername, filename) diff --git a/handle/replyText.go b/handle/replyText.go index 3ffa23e..f98ca0c 100644 --- a/handle/replyText.go +++ b/handle/replyText.go @@ -42,7 +42,10 @@ func cmdExec(msgContent MsgContent, timestamp, nonce string, w http.ResponseWrit 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) + replyImageDraw(msgContent, timestamp, nonce, w, "BTCUSDT") + replyImageDraw(msgContent, timestamp, nonce, w, "ETHUSDT") + replyImageDraw(msgContent, timestamp, nonce, w, "TRXUSDT") + replyImageDraw(msgContent, timestamp, nonce, w, "BNBUSDT") return case "gold", "黄金":