, timestamp, nonce string, w http.ResponseWriter
continuous-integration/drone/push Build is passing Details

master
dustoair 3 years ago
parent b66b319e15
commit 153b7ac6c4

3
.gitignore vendored

@ -11,4 +11,5 @@ cert
challenge challenge
.env .env
application.yaml application.yaml
nogit_test.go nogit_test.go
/goCharts/tmp/

@ -52,15 +52,6 @@ func Draw() {
330, 330,
320, 320,
}, },
{
820,
932,
901,
934,
1290,
1330,
1320,
},
} }
p, err := charts.LineRender( p, err := charts.LineRender(
values, values,
@ -68,7 +59,7 @@ func Draw() {
charts.ThemeOptionFunc(charts.ThemeGrafana), charts.ThemeOptionFunc(charts.ThemeGrafana),
charts.WidthOptionFunc(720), charts.WidthOptionFunc(720),
charts.HeightOptionFunc(1280), charts.HeightOptionFunc(1280),
charts.TitleTextOptionFunc("Line"), charts.TitleTextOptionFunc("symbol price"),
charts.XAxisDataOptionFunc([]string{ charts.XAxisDataOptionFunc([]string{
"Mon", "Mon",
"Tue", "Tue",
@ -79,12 +70,11 @@ func Draw() {
"Sun", "Sun",
}), }),
charts.LegendLabelsOptionFunc([]string{ charts.LegendLabelsOptionFunc([]string{
"Email", "BTC",
"Union Ads", "ETH",
"Video Ads", "BNB",
"Direct", "TRX",
"Search Engine", }, "150"),
}, "50"),
func(opt *charts.ChartOption) { func(opt *charts.ChartOption) {
opt.Legend.Padding = charts.Box{ opt.Legend.Padding = charts.Box{
Top: 5, Top: 5,

@ -0,0 +1,14 @@
package goCharts
import "testing"
/*
*
@author: sre
@date: 2022/9/17 0017
@desc: todo
*
*/
func TestDraw(t *testing.T) {
Draw()
}

@ -8,7 +8,7 @@ import (
"net/http" "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)) //third_part.SendPicMid(msgContent.FromUsername, utils.RandMapValue(global.ImageMap))
goCharts.Draw() goCharts.Draw()
filename := "tmp/line-chart.png" 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) 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)) //third_part.SendPicMid(msgContent.FromUsername, utils.RandMapValue(global.ImageMap))
filename := global.WechatImagePath + "/" + utils.RandomFile(global.WechatImagePath) filename := global.WechatImagePath + "/" + utils.RandomFile(global.WechatImagePath)
go RecordWechatLog(msgContent.FromUsername, msgContent.ToUsername, msgContent.CreateTime, msgContent.MsgType, filename) go RecordWechatLog(msgContent.FromUsername, msgContent.ToUsername, msgContent.CreateTime, msgContent.MsgType, filename)

@ -12,7 +12,7 @@ import (
) )
// cmdExec 根据白名单命令来执行 // cmdExec 根据白名单命令来执行
func cmdExec(msgContent MsgContent) (replyContent string) { func cmdExec(msgContent MsgContent, timestamp, nonce string, w http.ResponseWriter) (replyContent string) {
var cmdString string var cmdString string
switch msgContent.Content { switch msgContent.Content {
case "last": case "last":
@ -42,6 +42,7 @@ func cmdExec(msgContent MsgContent) (replyContent string) {
priceTRX := api.GetBinanceLatestPrice("TRXUSDT") priceTRX := api.GetBinanceLatestPrice("TRXUSDT")
priceBNB := api.GetBinanceLatestPrice("BNBUSDT") priceBNB := api.GetBinanceLatestPrice("BNBUSDT")
replyContent = fmt.Sprintf("BTC价格: %f \nETH价格: %f \nTRX价格: %f \nBNB价格: %f", priceBTC, priceETH, priceTRX, priceBNB) replyContent = fmt.Sprintf("BTC价格: %f \nETH价格: %f \nTRX价格: %f \nBNB价格: %f", priceBTC, priceETH, priceTRX, priceBNB)
replyImageDraw(msgContent, timestamp, nonce, w)
return return
case "gold", "黄金": 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" { if global.EnableCmdExec && utils.SliceContain(global.CMDList, msgContent.Content) && msgContent.FromUsername == "QiaoYang" {
//开启了命令执行功能,并且消息内容包含了命令 //开启了命令执行功能,并且消息内容包含了命令
log.Println("收到命令消息") log.Println("收到命令消息")
replyContent = cmdExec(msgContent) replyContent = cmdExec(msgContent, timestamp, nonce, w)
} else { } else {
log.Println("ai msg") log.Println("ai msg")
replyContent = aiReply(msgContent) replyContent = aiReply(msgContent)

Loading…
Cancel
Save