From 8256658ac2f2c31812d7af5b23ff622806ac9340 Mon Sep 17 00:00:00 2001 From: fumiama Date: Mon, 17 Jan 2022 23:04:32 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20add=20rough=20guild=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 6 +++--- go.sum | 12 ++++++------ plugin_acgimage/classify.go | 10 +++++----- plugin_ai_reply/main.go | 2 +- plugin_bilibili_push/bilibili_push.go | 2 +- plugin_book_review/book_review.go | 4 ++-- plugin_danbooru/main.go | 2 +- plugin_diana/zhiwang.go | 4 +--- plugin_novel/qianbi.go | 4 ++-- plugin_omikuji/sensou.go | 2 +- plugin_score/sign_in.go | 2 +- plugin_setutime/setu_geter.go | 4 ++-- plugin_shindan/shindan.go | 2 +- plugin_vtb_quotation/vtb_quotation.go | 12 ++++++------ 14 files changed, 33 insertions(+), 35 deletions(-) diff --git a/go.mod b/go.mod index 0a1c5861..6d0fef4f 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/FloatTech/ZeroBot-Plugin go 1.17 require ( - github.com/FloatTech/AnimeAPI v1.2.4-beta3 - github.com/FloatTech/zbputils v1.2.4-beta3 + github.com/FloatTech/AnimeAPI v1.2.4-beta4 + github.com/FloatTech/zbputils v1.2.4-beta4 github.com/antchfx/htmlquery v1.2.4 github.com/chromedp/chromedp v0.7.6 github.com/corona10/goimagehash v1.0.3 @@ -20,7 +20,7 @@ require ( github.com/shirou/gopsutil/v3 v3.21.12 github.com/sirupsen/logrus v1.8.1 github.com/tidwall/gjson v1.12.1 - github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220116120140-cd6069eba722 + github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220117142919-4ad1916ac4c8 golang.org/x/image v0.0.0-20211028202545-6944b10bf410 ) diff --git a/go.sum b/go.sum index 6d051b57..4fd1c0c1 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ -github.com/FloatTech/AnimeAPI v1.2.4-beta3 h1:635e2vSmurBJXfcnQM1Vo0s6gj3juVHPzXXx2B5ud8M= -github.com/FloatTech/AnimeAPI v1.2.4-beta3/go.mod h1:iPDCjwhWVxRWeRcBZTtxnlEr3oYpuSOjPDAzy8D330k= +github.com/FloatTech/AnimeAPI v1.2.4-beta4 h1:eOfgF94DQCWExvdyDj9kWQHH7b1zI7dHnOlldwHYfbE= +github.com/FloatTech/AnimeAPI v1.2.4-beta4/go.mod h1:gisq6pI4YN4BL6MLafRYIvb1h14TJmQOH/Jff75iWf0= github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ= -github.com/FloatTech/zbputils v1.2.4-beta3 h1:qMfBEoB1r4HaSw4vKRrugMMxctEa7a0h10k3Zwnm49k= -github.com/FloatTech/zbputils v1.2.4-beta3/go.mod h1:kF36a1wKBZLvWaHFetpIJixMN8Qtzc3F6s7KBIK7DLA= +github.com/FloatTech/zbputils v1.2.4-beta4 h1:ghZ15qXSy8avn4ZSDsiA+pzOyUrxUjJRfEt9NibO4xE= +github.com/FloatTech/zbputils v1.2.4-beta4/go.mod h1:4UzrG5qle4Dd7vVAljgEun0TSfzZDI7L+XTqGPLPu2s= github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb h1:Rkj28fqIwGx/EgBzRYtpmJRfH6wqVn7cNdc7aJ0QE4M= github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb/go.mod h1:imVKbfKqqeit+C/eaWGb4MKQ3z3gN6pRpBU5RMtp5so= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= @@ -163,8 +163,8 @@ github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVM github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/wdvxdr1123/ZeroBot v1.3.2/go.mod h1:i2DIqQjtjE+3gvVi9r9sc+QpNaUuyTXx/HNXXayIpwI= github.com/wdvxdr1123/ZeroBot v1.4.1/go.mod h1:7t9m4vDZPwWAmzKlhP6IvUoisOIiqNdm/3AJgiY3+ew= -github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220116120140-cd6069eba722 h1:0KDWodIHPh11BgkyfSxWF7zlaejusCFH8OOZO5dVsJg= -github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220116120140-cd6069eba722/go.mod h1:7t9m4vDZPwWAmzKlhP6IvUoisOIiqNdm/3AJgiY3+ew= +github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220117142919-4ad1916ac4c8 h1:AwWe53a7VNoHahybOxXoAeZXTriUWoM2RZyv3EtO6P0= +github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220117142919-4ad1916ac4c8/go.mod h1:7t9m4vDZPwWAmzKlhP6IvUoisOIiqNdm/3AJgiY3+ew= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= diff --git a/plugin_acgimage/classify.go b/plugin_acgimage/classify.go index f483fef1..8ba68e56 100644 --- a/plugin_acgimage/classify.go +++ b/plugin_acgimage/classify.go @@ -27,7 +27,7 @@ const ( var ( // r18有一定保护,一般不会发出图片 randapi = "&loli=true&r18=true" - msgof = make(map[int64]int64) + msgof = make(map[int64]message.MessageID) block = false limit = rate.NewManager(time.Minute, 5) ) @@ -53,7 +53,7 @@ func init() { // 插件主体 } }) // 有保护的随机图片 - engine.OnFullMatch("随机图片", zero.OnlyGroup).SetBlock(true). + engine.OnFullMatch("随机图片", zero.OnlyPublic).SetBlock(true). Handle(func(ctx *zero.Ctx) { if limit.Load(ctx.Event.UserID).Acquire() { class, dhash, comment, _ := classify.Classify(randapi, true) @@ -63,7 +63,7 @@ func init() { // 插件主体 ctx.SendChain(message.Text("你太快啦!")) }) // 直接随机图片,无r18保护,后果自负。如果出r18图可尽快通过发送"太涩了"撤回 - engine.OnFullMatch("直接随机", zero.OnlyGroup, zero.AdminPermission).SetBlock(true). + engine.OnFullMatch("直接随机", zero.OnlyPublic, zero.AdminPermission).SetBlock(true). Handle(func(ctx *zero.Ctx) { if block { ctx.SendChain(message.Text("请稍后再试哦")) @@ -89,7 +89,7 @@ func init() { // 插件主体 } }) // 上传一张图进行评价 - engine.OnKeywordGroup([]string{"评价图片"}, zero.OnlyGroup, picture.CmdMatch, picture.MustGiven).SetBlock(true). + engine.OnKeywordGroup([]string{"评价图片"}, zero.OnlyPublic, picture.CmdMatch, picture.MustGiven).SetBlock(true). Handle(func(ctx *zero.Ctx) { ctx.SendChain(message.Text("少女祈祷中...")) for _, url := range ctx.State["image_url"].([]string) { @@ -111,7 +111,7 @@ func init() { // 插件主体 }) } -func setLastMsg(id int64, msg int64) { +func setLastMsg(id int64, msg message.MessageID) { msgof[id] = msg } diff --git a/plugin_ai_reply/main.go b/plugin_ai_reply/main.go index 2181ab78..16265794 100644 --- a/plugin_ai_reply/main.go +++ b/plugin_ai_reply/main.go @@ -38,7 +38,7 @@ func init() { // 插件主体 reply := aireply.Talk(ctx.ExtractPlainText()) // 回复 time.Sleep(time.Second * 1) - if ctx.Event.MessageType == "group" { + if zero.OnlyPublic(ctx) { reply = append(reply, message.Reply(ctx.Event.MessageID)) ctx.Send(reply) return diff --git a/plugin_bilibili_push/bilibili_push.go b/plugin_bilibili_push/bilibili_push.go index fc47e940..0f9442fd 100644 --- a/plugin_bilibili_push/bilibili_push.go +++ b/plugin_bilibili_push/bilibili_push.go @@ -207,7 +207,7 @@ func init() { if err != nil { log.Errorln("[bilibilipush]:", err) } - if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id == 0 { + if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } }) diff --git a/plugin_book_review/book_review.go b/plugin_book_review/book_review.go index 0570d3c0..bb024a51 100644 --- a/plugin_book_review/book_review.go +++ b/plugin_book_review/book_review.go @@ -27,7 +27,7 @@ func init() { if err != nil { log.Println("err:", err) } - if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id == 0 { + if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } }) @@ -39,7 +39,7 @@ func init() { if err != nil { log.Println("err:", err) } - if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id == 0 { + if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } }) diff --git a/plugin_danbooru/main.go b/plugin_danbooru/main.go index 5b011dad..15ca5158 100644 --- a/plugin_danbooru/main.go +++ b/plugin_danbooru/main.go @@ -32,7 +32,7 @@ func init() { // 插件主体 "- 鉴赏图片[图片]", }) // 上传一张图进行评价 - engine.OnKeywordGroup([]string{"鉴赏图片"}, zero.OnlyGroup, picture.CmdMatch, picture.MustGiven).SetBlock(true). + engine.OnKeywordGroup([]string{"鉴赏图片"}, zero.OnlyPublic, picture.CmdMatch, picture.MustGiven).SetBlock(true). Handle(func(ctx *zero.Ctx) { ctx.SendChain(message.Text("少女祈祷中...")) for _, url := range ctx.State["image_url"].([]string) { diff --git a/plugin_diana/zhiwang.go b/plugin_diana/zhiwang.go index 7b477074..d4c274c4 100644 --- a/plugin_diana/zhiwang.go +++ b/plugin_diana/zhiwang.go @@ -5,7 +5,6 @@ import ( "bytes" "encoding/json" "math" - "strconv" "time" "github.com/wdvxdr1123/ZeroBot/message" @@ -33,8 +32,7 @@ func init() { Handle(func(ctx *zero.Ctx) { msg := ctx.Event.Message if msg[0].Type == "reply" { - id, _ := strconv.Atoi(msg[0].Data["id"]) - msg := ctx.GetMessage(int64(id)).Elements[0].Data["text"] + msg := ctx.GetMessage(message.NewMessageID(msg[0].Data["id"])).Elements[0].Data["text"] zhiwangjson := zhiwangapi(msg) if zhiwangjson == nil || zhiwangjson.Code != 0 { diff --git a/plugin_novel/qianbi.go b/plugin_novel/qianbi.go index b44a660e..e2a18bd0 100644 --- a/plugin_novel/qianbi.go +++ b/plugin_novel/qianbi.go @@ -92,7 +92,7 @@ func init() { if err != nil { log.Println("err:", err) } - if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id == 0 { + if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } } else { @@ -124,7 +124,7 @@ func init() { if err != nil { log.Println("err:", err) } - if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id == 0 { + if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } } diff --git a/plugin_omikuji/sensou.go b/plugin_omikuji/sensou.go index 8eee77c8..5da58370 100644 --- a/plugin_omikuji/sensou.go +++ b/plugin_omikuji/sensou.go @@ -46,7 +46,7 @@ func init() { // 插件主体 if err != nil { log.Errorln("[omikuji]:", err) } - if id := ctx.SendChain(message.At(ctx.Event.UserID), message.Image("base64://"+helper.BytesToString(kujiBytes))); id == 0 { + if id := ctx.SendChain(message.At(ctx.Event.UserID), message.Image("base64://"+helper.BytesToString(kujiBytes))); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } }) diff --git a/plugin_score/sign_in.go b/plugin_score/sign_in.go index 2d714350..67e796bb 100644 --- a/plugin_score/sign_in.go +++ b/plugin_score/sign_in.go @@ -41,7 +41,7 @@ var ( ) func init() { - engine.OnFullMatch("签到").SetBlock(true). + engine.OnFullMatch("签到", zero.OnlyGroup).SetBlock(true). Handle(func(ctx *zero.Ctx) { uid := ctx.Event.UserID now := time.Now() diff --git a/plugin_setutime/setu_geter.go b/plugin_setutime/setu_geter.go index a4fa3ec0..0a178659 100644 --- a/plugin_setutime/setu_geter.go +++ b/plugin_setutime/setu_geter.go @@ -118,7 +118,7 @@ func init() { // 插件主体 } } // 从缓冲池里抽一张 - if id := ctx.SendChain(message.Image(file(pool.pop(imgtype)))); id == 0 { + if id := ctx.SendChain(message.Image(file(pool.pop(imgtype)))); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } }) @@ -142,7 +142,7 @@ func init() { // 插件主体 return } // 发送到发送者 - if id := ctx.SendChain(message.Image(file(illust))); id == 0 { + if id := ctx.SendChain(message.Image(file(illust))); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控,发送失败")) return } diff --git a/plugin_shindan/shindan.go b/plugin_shindan/shindan.go index 97de1315..d83e060a 100644 --- a/plugin_shindan/shindan.go +++ b/plugin_shindan/shindan.go @@ -58,7 +58,7 @@ func handle(ctx *zero.Ctx) { if err != nil { log.Errorln("[shindan]:", err) } - if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id == 0 { + if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } default: diff --git a/plugin_vtb_quotation/vtb_quotation.go b/plugin_vtb_quotation/vtb_quotation.go index 0af65853..1517e6c1 100644 --- a/plugin_vtb_quotation/vtb_quotation.go +++ b/plugin_vtb_quotation/vtb_quotation.go @@ -52,7 +52,7 @@ func init() { if err != nil { log.Errorln("[vtb]:", err) } - if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(firstStepImageBytes))); id == 0 { + if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(firstStepImageBytes))); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } // 步骤0,1,2,依次选择3个类别 @@ -84,7 +84,7 @@ func init() { if err != nil { log.Errorln("[vtb]:", err) } - if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(firstStepImageBytes))); id == 0 { + if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(firstStepImageBytes))); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } errorCount++ @@ -93,7 +93,7 @@ func init() { if err != nil { log.Errorln("[vtb]:", err) } - if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(secondStepMessageBytes))); id == 0 { + if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(secondStepMessageBytes))); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } step++ @@ -115,7 +115,7 @@ func init() { if err != nil { log.Errorln("[vtb]:", err) } - if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(secondStepMessageBytes))); id == 0 { + if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(secondStepMessageBytes))); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } errorCount++ @@ -124,7 +124,7 @@ func init() { if err != nil { log.Errorln("[vtb]:", err) } - if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(thirdStepMessageBytes))); id == 0 { + if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(thirdStepMessageBytes))); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } step++ @@ -147,7 +147,7 @@ func init() { if err != nil { log.Errorln("[vtb]:", err) } - if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(firstStepImageBytes))); id == 0 { + if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(firstStepImageBytes))); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } errorCount++