From 6262aab6bd1d8eb61a94e6b70de700ede081860e Mon Sep 17 00:00:00 2001 From: fumiama Date: Tue, 1 Mar 2022 17:29:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=BF=E6=8D=A2CustomNode=E4=B8=BActxext?= =?UTF-8?q?=E7=9A=84=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data | 2 +- go.mod | 4 ++-- go.sum | 8 ++++---- main.go | 2 +- plugin/coser/coser.go | 18 +++--------------- plugin/hs/run.go | 9 +-------- plugin/moyu/holiday_test.go | 2 +- plugin/moyu/nowork.go | 2 +- plugin/saucenao/searcher.go | 34 +++++++++++----------------------- plugin/ymgal/ymgal.go | 23 +++-------------------- 10 files changed, 28 insertions(+), 76 deletions(-) diff --git a/data b/data index 7ba7dfb0..58c61018 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit 7ba7dfb0f39c9c8bedfd494d2014bdb937e7509d +Subproject commit 58c61018e84eebd7626b09d252f540346ffb68ae diff --git a/go.mod b/go.mod index 837e1ffd..d4876449 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module github.com/FloatTech/ZeroBot-Plugin go 1.17 require ( - github.com/FloatTech/AnimeAPI v1.3.1-0.20220227112758-da30b39dd7a7 + github.com/FloatTech/AnimeAPI v1.3.1-0.20220301092207-292c2a0d9971 github.com/FloatTech/sqlite v0.2.0 - github.com/FloatTech/zbputils v1.3.1-0.20220227112438-2ccf42cc85d3 + github.com/FloatTech/zbputils v1.3.1-0.20220301091616-3ace908b3d25 github.com/antchfx/htmlquery v1.2.4 github.com/corona10/goimagehash v1.0.3 github.com/fogleman/gg v1.3.0 diff --git a/go.sum b/go.sum index 6c035225..e4045216 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,10 @@ -github.com/FloatTech/AnimeAPI v1.3.1-0.20220227112758-da30b39dd7a7 h1:JOmelUrxBef/Sg/15PgkBC3IV4BpORQwiSWfqV1nCD0= -github.com/FloatTech/AnimeAPI v1.3.1-0.20220227112758-da30b39dd7a7/go.mod h1:AuFa+9NWdJujJc2PvCoO2NqLOwwwFXKy69X0zexsZS0= +github.com/FloatTech/AnimeAPI v1.3.1-0.20220301092207-292c2a0d9971 h1:IVYw7zzffBYPSLGcSf7kv0P4OOfFRYrl6+Fyiv3ZQRY= +github.com/FloatTech/AnimeAPI v1.3.1-0.20220301092207-292c2a0d9971/go.mod h1:yAmOcbDWxEZYQyLY919C5A/YJ4KX+aaQkpDaVQDVtlQ= github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ= github.com/FloatTech/sqlite v0.2.0 h1:x3uls/hExXH1+bbaNLkvilce6ATtWlDx4IqoxBW/bv8= github.com/FloatTech/sqlite v0.2.0/go.mod h1:xIDWIvpOFl8AXmZm0FC8t3PZjiR6ZutytCpBv2EWCns= -github.com/FloatTech/zbputils v1.3.1-0.20220227112438-2ccf42cc85d3 h1:BA9mbIE2D2hhZnGaFjgIbiUrwG4h6VjVYf4UoDnBVn8= -github.com/FloatTech/zbputils v1.3.1-0.20220227112438-2ccf42cc85d3/go.mod h1:NXv73hWyC4Q4S4wg01DEwLzznSHSmde0o03PnsS1DtY= +github.com/FloatTech/zbputils v1.3.1-0.20220301091616-3ace908b3d25 h1:n88oTj/5QpJuA0NkUCbYvYlka7vwtke+FvaU3VrEtjg= +github.com/FloatTech/zbputils v1.3.1-0.20220301091616-3ace908b3d25/go.mod h1:NXv73hWyC4Q4S4wg01DEwLzznSHSmde0o03PnsS1DtY= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc h1:AAx50/fb/xS4lvsdQg+bFbGvqSDhyV1MF+p2PLCamZ0= github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc/go.mod h1:OMmITAib6POA37xCichWM0aRnoVpSMZO1rB/G01wrr0= diff --git a/main.go b/main.go index 31f6d5d5..833024fc 100644 --- a/main.go +++ b/main.go @@ -161,7 +161,7 @@ var ( url *string adana *string prefix *string - reg = registry.NewRegReader("reilia.fumiama.top:32664", "fumiama") + reg = registry.NewRegReader("reilia.westeurope.cloudapp.azure.com:32664", "fumiama") ) func init() { diff --git a/plugin/coser/coser.go b/plugin/coser/coser.go index c491708e..4e875999 100644 --- a/plugin/coser/coser.go +++ b/plugin/coser/coser.go @@ -32,23 +32,11 @@ func init() { if err != nil { log.Println("err为:", err) } - var m message.Message + text := gjson.Get(helper.BytesToString(data), "data.Title").String() - m = append(m, - message.CustomNode( - ctx.Event.Sender.NickName, - ctx.Event.UserID, - text, - )) + m := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text(text))} gjson.Get(helper.BytesToString(data), "data.data").ForEach(func(_, value gjson.Result) bool { - m = append(m, - message.CustomNode( - ctx.Event.Sender.NickName, - ctx.Event.UserID, - []message.MessageSegment{ - message.Image(value.String()), - }), - ) + m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Image(value.String()))) return true }) diff --git a/plugin/hs/run.go b/plugin/hs/run.go index 75163e5c..f2a078ec 100644 --- a/plugin/hs/run.go +++ b/plugin/hs/run.go @@ -77,14 +77,7 @@ func init() { continue } } - sk = append( - sk, - message.CustomNode( - zero.BotConfig.NickName[0], - ctx.Event.SelfID, - []message.MessageSegment{message.Image("file:///" + cachefile)}, // 图片 - ), - ) + sk = append(sk, ctxext.FakeSenderForwardNode(ctx, message.Image("file:///"+cachefile))) } if id := ctx.SendGroupForwardMessage( ctx.Event.GroupID, diff --git a/plugin/moyu/holiday_test.go b/plugin/moyu/holiday_test.go index 6169d052..0ef66b60 100644 --- a/plugin/moyu/holiday_test.go +++ b/plugin/moyu/holiday_test.go @@ -8,7 +8,7 @@ import ( reg "github.com/fumiama/go-registry" ) -var sr = reg.NewRegedit("reilia.fumiama.top:32664", "fumiama", "--") +var sr = reg.NewRegedit("reilia.westeurope.cloudapp.azure.com:32664", "fumiama", "--") func TestGetHoliday(t *testing.T) { registry.Connect() diff --git a/plugin/moyu/nowork.go b/plugin/moyu/nowork.go index 9846cbfe..a0696d22 100644 --- a/plugin/moyu/nowork.go +++ b/plugin/moyu/nowork.go @@ -21,7 +21,7 @@ func NewHoliday(name string, dur, year int, month time.Month, day int) *Holiday return &Holiday{name: name, date: time.Date(year, month, day, 0, 0, 0, 0, time.Local), dur: time.Duration(dur) * time.Hour * 24} } -var registry = reg.NewRegReader("reilia.fumiama.top:32664", "fumiama") +var registry = reg.NewRegReader("reilia.westeurope.cloudapp.azure.com:32664", "fumiama") // GetHoliday 从 reg 服务器获取节日 func GetHoliday(name string) *Holiday { diff --git a/plugin/saucenao/searcher.go b/plugin/saucenao/searcher.go index 6af260cf..9c9763cc 100644 --- a/plugin/saucenao/searcher.go +++ b/plugin/saucenao/searcher.go @@ -129,30 +129,18 @@ func init() { // 插件主体 ctx.SendChain(message.Text("ERROR: ", err)) continue } else { - var msg message.Message = []message.MessageSegment{ - message.CustomNode( - ctx.Event.Sender.Name(), - ctx.Event.UserID, - "ascii2d搜图结果", - )} + msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("ascii2d搜图结果"))} for i := 0; i < len(result) && i < 5; i++ { - msg = append( - msg, - message.CustomNode( - ctx.Event.Sender.Name(), - ctx.Event.UserID, - []message.MessageSegment{ - message.Image(result[i].Thumb), - message.Text(fmt.Sprintf( - "标题:%s\n图源:%s\n画师:%s\n画师链接:%s\n图片链接:%s", - result[i].Name, - result[i].Type, - result[i].AuthNm, - result[i].Author, - result[i].Link, - )), - }, - ), + msg = append(msg, ctxext.FakeSenderForwardNode(ctx, + message.Image(result[i].Thumb), + message.Text(fmt.Sprintf( + "标题:%s\n图源:%s\n画师:%s\n画师链接:%s\n图片链接:%s", + result[i].Name, + result[i].Type, + result[i].AuthNm, + result[i].Author, + result[i].Link, + ))), ) } if id := ctx.SendGroupForwardMessage( diff --git a/plugin/ymgal/ymgal.go b/plugin/ymgal/ymgal.go index 0b19eb75..a481e062 100644 --- a/plugin/ymgal/ymgal.go +++ b/plugin/ymgal/ymgal.go @@ -64,29 +64,12 @@ func sendYmgal(y ymgal, ctx *zero.Ctx) { ctx.SendChain(message.Text(zero.BotConfig.NickName[0] + "暂时没有这样的图呢")) return } - m := message.Message{ - message.CustomNode( - ctx.Event.Sender.NickName, - ctx.Event.UserID, - y.Title, - )} + m := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text(y.Title))} if y.PictureDescription != "" { - m = append(m, - message.CustomNode( - ctx.Event.Sender.NickName, - ctx.Event.UserID, - y.PictureDescription, - )) + m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text(y.PictureDescription))) } for _, v := range strings.Split(y.PictureList, ",") { - m = append(m, - message.CustomNode( - ctx.Event.Sender.NickName, - ctx.Event.UserID, - []message.MessageSegment{ - message.Image(v), - }), - ) + m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Image(v))) } if id := ctx.SendGroupForwardMessage( ctx.Event.GroupID,