diff --git a/README.md b/README.md index 88a284f8..1f6e3992 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,8 @@ print("run[CQ:image,file="+j["img"]+"]") ``` ![随机b站404页趣图](https://user-images.githubusercontent.com/41315874/157371451-c09ad3bb-c61a-4a42-9c47-fab3305bc0f8.png) +- **渲染任意文字到图片** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/font"` + - [x] (用[终末体|终末变体|紫罗兰体|樱酥体|Consolas体|苹方体])渲染文字xxx - **聊天** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/chat"` - [x] [BOT名字] - [x] [戳一戳BOT] diff --git a/data b/data index c6f5b6ed..d6efc79f 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit c6f5b6ed318cc0cb8e729812e9dc58275f8438a6 +Subproject commit d6efc79f18395853ea23bf4f98f848f5dda3ce55 diff --git a/go.mod b/go.mod index 83a7ac74..d69865f1 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( github.com/FloatTech/AnimeAPI v1.3.2-0.20220326161751-d0d2797b91da github.com/FloatTech/sqlite v0.2.1 - github.com/FloatTech/zbputils v1.3.2-0.20220326161600-f9554b2fb9a4 + github.com/FloatTech/zbputils v1.3.2-0.20220327052638-95033087f201 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 e28482db..c0a329b2 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/FloatTech/AnimeAPI v1.3.2-0.20220326161751-d0d2797b91da h1:KbJujP8k2/ github.com/FloatTech/AnimeAPI v1.3.2-0.20220326161751-d0d2797b91da/go.mod h1:aC3EOKpb0R0VOdW9QIQCfqN6ZFymOfvCgzVY1/Fz3Og= github.com/FloatTech/sqlite v0.2.1 h1:9t6Me48XJJCIoPy4nLRvcdhcVKfT0c2lilp7SEKROG8= github.com/FloatTech/sqlite v0.2.1/go.mod h1:6NfHRzqOo9RWeMJEoAQVuo51Omd5LFNxCNQhMF02/9U= -github.com/FloatTech/zbputils v1.3.2-0.20220326161600-f9554b2fb9a4 h1:+OnHN8QcMqwEx37a3TMBw7CT5OTyFs8qqa4Hub+Igbk= -github.com/FloatTech/zbputils v1.3.2-0.20220326161600-f9554b2fb9a4/go.mod h1:qZlHzG1s1giQrXaosjOAA2utGNaPZjwJsVZfBog2bhg= +github.com/FloatTech/zbputils v1.3.2-0.20220327052638-95033087f201 h1:7x73xvsTmz7HWL4CjmX0jmfp2XAr2Hvpt2ay+DPOo6c= +github.com/FloatTech/zbputils v1.3.2-0.20220327052638-95033087f201/go.mod h1:qZlHzG1s1giQrXaosjOAA2utGNaPZjwJsVZfBog2bhg= 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 baf7c768..d4b8c891 100644 --- a/main.go +++ b/main.go @@ -73,6 +73,7 @@ import ( _ "github.com/FloatTech/ZeroBot-Plugin/plugin/drift_bottle" // 漂流瓶 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/emojimix" // 合成emoji _ "github.com/FloatTech/ZeroBot-Plugin/plugin/epidemic" // 城市疫情查询 + _ "github.com/FloatTech/ZeroBot-Plugin/plugin/font" // 渲染任意文字到图片 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/fortune" // 运势 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/funny" // 笑话 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/genshin" // 原神抽卡 diff --git a/plugin/bilibili/info.go b/plugin/bilibili/info.go index bc517312..31d02eb9 100644 --- a/plugin/bilibili/info.go +++ b/plugin/bilibili/info.go @@ -27,7 +27,7 @@ func init() { keyword := ctx.State["regex_matched"].([]string)[1] rest, err := uid(keyword) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } id := rest.Get("data.result.0.mid").String() @@ -36,20 +36,20 @@ func init() { client := &http.Client{} req, err := http.NewRequest(method, url, nil) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } req.Header.Add("cookie", "CURRENT_FNVAL=80; _uuid=772B88E8-3ED1-D589-29BB-F6CB5214239A06137infoc; blackside_state=1; bfe_id=6f285c892d9d3c1f8f020adad8bed553; rpdid=|(umY~Jkl|kJ0J'uYkR|)lu|); fingerprint=0ec2b1140fb30b56d7b5e415bc3b5fb1; buvid_fp=C91F5265-3DF4-4D5A-9FF3-C546370B14C0143096infoc; buvid_fp_plain=C91F5265-3DF4-4D5A-9FF3-C546370B14C0143096infoc; SESSDATA=9e0266f6%2C1639637127%2Cb0172%2A61; bili_jct=96ddbd7e22d527abdc0501339a12d4d3; DedeUserID=695737880; DedeUserID__ckMd5=0117660e75db7b01; sid=5labuhaf; PVID=1; bfe_id=1e33d9ad1cb29251013800c68af42315") res, err := client.Do(req) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } defer res.Body.Close() body, err := io.ReadAll(res.Body) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } data := string(body) diff --git a/plugin/bilibili/live_info.go b/plugin/bilibili/live_info.go index f0769a22..6336a6f0 100644 --- a/plugin/bilibili/live_info.go +++ b/plugin/bilibili/live_info.go @@ -19,14 +19,14 @@ func init() { keyword := ctx.State["regex_matched"].([]string)[1] res, err := uid(keyword) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } id := res.Get("data.result.0.mid").String() // 获取详情 fo, err := fansapi(id) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } ctx.SendChain(message.Text( diff --git a/plugin/bilibili_push/bilibili_push.go b/plugin/bilibili_push/bilibili_push.go index a2d5bcff..18b5c7fb 100644 --- a/plugin/bilibili_push/bilibili_push.go +++ b/plugin/bilibili_push/bilibili_push.go @@ -214,7 +214,7 @@ func init() { log.Errorln("[bilibilipush]:", err) } if id := ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))); id.ID() == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) + ctx.SendChain(message.Text("ERROR:可能被风控了")) } }) } diff --git a/plugin/book_review/book_review.go b/plugin/book_review/book_review.go index 48a2053d..8b525b84 100644 --- a/plugin/book_review/book_review.go +++ b/plugin/book_review/book_review.go @@ -45,7 +45,7 @@ func init() { log.Println("err:", err) } if id := ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))); id.ID() == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) + ctx.SendChain(message.Text("ERROR:可能被风控了")) } }) @@ -57,7 +57,7 @@ func init() { log.Println("err:", err) } if id := ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))); id.ID() == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) + ctx.SendChain(message.Text("ERROR:可能被风控了")) } }) } diff --git a/plugin/coser/coser.go b/plugin/coser/coser.go index 67564f70..751d12af 100644 --- a/plugin/coser/coser.go +++ b/plugin/coser/coser.go @@ -43,7 +43,7 @@ func init() { if id := ctx.SendGroupForwardMessage( ctx.Event.GroupID, m).Get("message_id").Int(); id == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) + ctx.SendChain(message.Text("ERROR:可能被风控了")) } }) } diff --git a/plugin/diana/bing.go b/plugin/diana/bing.go index f67e6808..f06f1aa5 100644 --- a/plugin/diana/bing.go +++ b/plugin/diana/bing.go @@ -46,7 +46,7 @@ func init() { Handle(func(ctx *zero.Ctx) { err := data.AddText(ctx.State["regex_matched"].([]string)[1]) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) } else { ctx.SendChain(message.Text("记住啦!")) } diff --git a/plugin/epidemic/epidemic.go b/plugin/epidemic/epidemic.go index 206b836c..6f42147a 100644 --- a/plugin/epidemic/epidemic.go +++ b/plugin/epidemic/epidemic.go @@ -63,7 +63,7 @@ func init() { } data, time, err := queryEpidemic(city) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } if data == nil { diff --git a/plugin/font/main.go b/plugin/font/main.go new file mode 100644 index 00000000..19b25db0 --- /dev/null +++ b/plugin/font/main.go @@ -0,0 +1,43 @@ +// Package font 渲染任意文字到图片 +package font + +import ( + "github.com/FloatTech/zbputils/binary" + "github.com/FloatTech/zbputils/control" + "github.com/FloatTech/zbputils/control/order" + "github.com/FloatTech/zbputils/ctxext" + "github.com/FloatTech/zbputils/img/text" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" +) + +func init() { + control.Register("font", order.AcquirePrio(), &control.Options{ + DisableOnDefault: false, + Help: "渲染任意文字到图片\n- (用[终末体|终末变体|紫罗兰体|樱酥体|Consolas体|苹方体])渲染文字xxx", + }).OnRegex(`^(用.+)?渲染文字([\s\S]+)$`).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { + fnt := ctx.State["regex_matched"].([]string)[1] + txt := ctx.State["regex_matched"].([]string)[2] + switch fnt { + case "用终末体": + fnt = text.SyumatuFontFile + case "用终末变体": + fnt = text.NisiFontFile + case "用紫罗兰体": + fnt = text.VioletEvergardenFontFile + case "用樱酥体": + fnt = text.SakuraFontFile + case "用Consolas体": + fnt = text.ConsolasFontFile + case "用苹方体": + default: + fnt = text.FontFile + } + b, err := text.RenderToBase64(txt, fnt, 400, 20) + if err != nil { + ctx.SendChain(message.Text("ERROR:", err)) + return + } + ctx.SendChain(message.Image("base64://" + binary.BytesToString(b))) + }) +} diff --git a/plugin/fortune/fortune.go b/plugin/fortune/fortune.go index 9ada3932..d6373cc1 100644 --- a/plugin/fortune/fortune.go +++ b/plugin/fortune/fortune.go @@ -125,7 +125,7 @@ func init() { zipfile := images + kind + ".zip" _, err := file.GetLazyData(zipfile, false, false) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } @@ -136,7 +136,7 @@ func init() { // 随机获取背景 background, index, err := randimage(zipfile, seed) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } @@ -155,7 +155,7 @@ func init() { return err }, ctxext.Send(ctx), ctxext.GetMessage(ctx)) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } }) diff --git a/plugin/github/repo_searcher.go b/plugin/github/repo_searcher.go index 84d0a529..a512376f 100644 --- a/plugin/github/repo_searcher.go +++ b/plugin/github/repo_searcher.go @@ -36,12 +36,12 @@ func init() { // 插件主体 }.Encode() body, err := netGet(api.String(), header) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) } // 解析请求 info := gjson.ParseBytes(body) if info.Get("total_count").Int() == 0 { - ctx.SendChain(message.Text("ERROR: 没有找到这样的仓库")) + ctx.SendChain(message.Text("ERROR:没有找到这样的仓库")) return } repo := info.Get("items.0") diff --git a/plugin/hs/run.go b/plugin/hs/run.go index d2640d07..126b69d3 100644 --- a/plugin/hs/run.go +++ b/plugin/hs/run.go @@ -83,7 +83,7 @@ func init() { ctx.Event.GroupID, sk, ).Get("message_id").Int(); id == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) + ctx.SendChain(message.Text("ERROR:可能被风控了")) } }) // 卡组 diff --git a/plugin/image_finder/keyword.go b/plugin/image_finder/keyword.go index 4f07b9db..c90c6f03 100644 --- a/plugin/image_finder/keyword.go +++ b/plugin/image_finder/keyword.go @@ -44,13 +44,13 @@ func init() { keyword := ctx.State["regex_matched"].([]string)[1] soutujson, err := soutuapi(keyword) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } rannum := rand.Intn(len(soutujson.Data.Illusts)) illust, err := pixiv.Works(soutujson.Data.Illusts[rannum].ID) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } u := illust.ImageUrls[0] @@ -62,7 +62,7 @@ func init() { return illust.DownloadToCache(0) }, ctxext.SendFakeForwardToGroup(ctx), ctxext.GetFirstMessageInForward(ctx)) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } }) diff --git a/plugin/lolicon/lolicon.go b/plugin/lolicon/lolicon.go index d16e0ca0..9bc885c0 100644 --- a/plugin/lolicon/lolicon.go +++ b/plugin/lolicon/lolicon.go @@ -39,12 +39,12 @@ func init() { for i := 0; i < math.Min(cap(queue)-len(queue), 2); i++ { data, err := web.GetData(api) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) continue } json := gjson.ParseBytes(data) if e := json.Get("error").Str; e != "" { - ctx.SendChain(message.Text("ERROR: ", e)) + ctx.SendChain(message.Text("ERROR:", e)) continue } url := json.Get("data.0.urls.original").Str @@ -65,7 +65,7 @@ func init() { }() select { case <-time.After(time.Minute): - ctx.SendChain(message.Text("ERROR: 等待填充,请稍后再试......")) + ctx.SendChain(message.Text("ERROR:等待填充,请稍后再试......")) case img := <-queue: id := ctx.SendChain(message.Image(img)) if id.ID() == 0 { diff --git a/plugin/moyu_calendar/calendar.go b/plugin/moyu_calendar/calendar.go index 02e84a0f..b0500d23 100644 --- a/plugin/moyu_calendar/calendar.go +++ b/plugin/moyu_calendar/calendar.go @@ -38,17 +38,17 @@ func init() { title := fmt.Sprintf("摸鱼人日历 %d月%d日", time.Now().Month(), time.Now().Day()) sg, cookies, err := sougou(title, "摸鱼人日历", ua) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } wx, err := redirect(sg, cookies, ua) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } image, err := calendar(wx, ua) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } ctx.SendChain(message.Image(image)) diff --git a/plugin/nativesetu/main.go b/plugin/nativesetu/main.go index fc0d06e2..19cb6431 100644 --- a/plugin/nativesetu/main.go +++ b/plugin/nativesetu/main.go @@ -51,7 +51,7 @@ func init() { err := ns.db.Pick(imgtype, sc) ns.mu.RUnlock() if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) } else { p := "file:///" + setupath + "/" + sc.Path if ctx.Event.GroupID != 0 { @@ -71,7 +71,7 @@ func init() { if err == nil { ctx.SendChain(message.Text("成功!")) } else { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) } }) engine.OnRegex(`^设置本地setu绝对路径(.*)$`, zero.SuperUserPermission).SetBlock(true). @@ -81,7 +81,7 @@ func init() { if err == nil { ctx.SendChain(message.Text("成功!")) } else { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) } }) engine.OnFullMatch("刷新所有本地setu", zero.SuperUserPermission).SetBlock(true). @@ -90,7 +90,7 @@ func init() { if err == nil { ctx.SendChain(message.Text("成功!")) } else { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) } }) engine.OnFullMatch("所有本地setu分类").SetBlock(true). diff --git a/plugin/novel/qianbi.go b/plugin/novel/qianbi.go index 4f929beb..1dbca273 100644 --- a/plugin/novel/qianbi.go +++ b/plugin/novel/qianbi.go @@ -84,7 +84,7 @@ func init() { log.Println("err:", err) } if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id.ID() == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) + ctx.SendChain(message.Text("ERROR:可能被风控了")) } } else { text := htmlquery.InnerText(htmlquery.FindOne(doc, "//div[@id='tipss']")) diff --git a/plugin/omikuji/sensou.go b/plugin/omikuji/sensou.go index 6168aea7..d1913c2e 100644 --- a/plugin/omikuji/sensou.go +++ b/plugin/omikuji/sensou.go @@ -61,7 +61,7 @@ func init() { // 插件主体 log.Errorln("[omikuji]:", err) } if id := ctx.SendChain(message.At(ctx.Event.UserID), message.Image("base64://"+helper.BytesToString(kujiBytes))); id.ID() == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) + ctx.SendChain(message.Text("ERROR:可能被风控了")) } }) } diff --git a/plugin/runcode/code_runner.go b/plugin/runcode/code_runner.go index a13c48f6..e0515f53 100644 --- a/plugin/runcode/code_runner.go +++ b/plugin/runcode/code_runner.go @@ -132,7 +132,7 @@ func init() { // 运行失败 ctx.SendChain( message.Text("> ", ctx.Event.Sender.NickName, "\n"), - message.Text("ERROR: ", err), + message.Text("ERROR:", err), ) } else { // 运行成功 diff --git a/plugin/saucenao/searcher.go b/plugin/saucenao/searcher.go index a81059dc..23967451 100644 --- a/plugin/saucenao/searcher.go +++ b/plugin/saucenao/searcher.go @@ -36,7 +36,7 @@ func init() { // 插件主体 // 获取P站插图信息 illust, err := pixiv.Works(id) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } if illust.Pid > 0 { @@ -91,7 +91,7 @@ func init() { // 插件主体 for _, pic := range ctx.State["image_url"].([]string) { fmt.Println(pic) if result, err := saucenao.SauceNAO(pic); err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) } else { // 返回SauceNAO的结果 ctx.SendChain( @@ -110,7 +110,7 @@ func init() { // 插件主体 continue } if result, err := yandex.Yandex(pic); err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) } else { ctx.SendChain( message.Text("也许是这个?"), @@ -126,7 +126,7 @@ func init() { // 插件主体 } // 不论结果如何都执行 ascii2d 搜索 if result, err := ascii2d.Ascii2d(pic); err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) continue } else { msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("ascii2d搜图结果"))} @@ -147,7 +147,7 @@ func init() { // 插件主体 ctx.Event.GroupID, msg, ).Get("message_id").Int(); id == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) + ctx.SendChain(message.Text("ERROR:可能被风控了")) } } } diff --git a/plugin/setutime/setu_geter.go b/plugin/setutime/setu_geter.go index a2488df6..b8b8b71b 100644 --- a/plugin/setutime/setu_geter.go +++ b/plugin/setutime/setu_geter.go @@ -86,13 +86,13 @@ func init() { // 插件主体 ctx.SendChain(message.Text("INFO: 正在填充弹药......")) time.Sleep(time.Second * 10) if pool.size(imgtype) == 0 { - ctx.SendChain(message.Text("ERROR: 等待填充,请稍后再试......")) + ctx.SendChain(message.Text("ERROR:等待填充,请稍后再试......")) return } } // 从缓冲池里抽一张 if id := ctx.SendChain(*pool.pop(imgtype)); id.ID() == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) + ctx.SendChain(message.Text("ERROR:可能被风控了")) } }) @@ -118,7 +118,7 @@ func init() { // 插件主体 ) // 查询数据库 if err := pool.remove(imgtype, id); err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } ctx.SendChain(message.Text("删除成功")) @@ -159,7 +159,7 @@ func (p *imgpool) push(ctx *zero.Ctx, imgtype string, illust *pixiv.Illust) { if fileutil.IsNotExist(f) { // 下载图片 if err := illust.DownloadToCache(0); err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } } @@ -197,7 +197,7 @@ func (p *imgpool) fill(ctx *zero.Ctx, imgtype string) { illust := &pixiv.Illust{} // 查询出一张图片 if err := p.db.Pick(imgtype, illust); err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) continue } // 向缓冲池添加一张图片 diff --git a/plugin/shindan/shindan.go b/plugin/shindan/shindan.go index 292c82c5..6f125051 100644 --- a/plugin/shindan/shindan.go +++ b/plugin/shindan/shindan.go @@ -69,7 +69,7 @@ func handlepic(ctx *zero.Ctx) { log.Errorln("[shindan]:", err) } if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id.ID() == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) + ctx.SendChain(message.Text("ERROR:可能被风控了")) } } diff --git a/plugin/tracemoe/moe.go b/plugin/tracemoe/moe.go index e1d49775..c78a1266 100644 --- a/plugin/tracemoe/moe.go +++ b/plugin/tracemoe/moe.go @@ -29,7 +29,7 @@ func init() { // 插件主体 for _, pic := range ctx.State["image_url"].([]string) { fmt.Println(pic) if result, err := moe.Search(pic, true, true); err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) } else if len(result.Result) > 0 { r := result.Result[0] hint := "我有把握是这个!" diff --git a/plugin/translation/tl.go b/plugin/translation/tl.go index 02981e30..d20211f1 100644 --- a/plugin/translation/tl.go +++ b/plugin/translation/tl.go @@ -24,7 +24,7 @@ func init() { msg := []string{ctx.State["regex_matched"].([]string)[2]} data, err := web.GetData("https://api.cloolc.club/fanyi?data=" + msg[0]) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) } info := gjson.ParseBytes(data) repo := info.Get("data.0") diff --git a/plugin/vtb_quotation/vtb_quotation.go b/plugin/vtb_quotation/vtb_quotation.go index 467c9357..3a838124 100644 --- a/plugin/vtb_quotation/vtb_quotation.go +++ b/plugin/vtb_quotation/vtb_quotation.go @@ -70,7 +70,7 @@ func init() { log.Errorln("[vtb]:", err) } if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(firstStepImageBytes))); id.ID() == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) + ctx.SendChain(message.Text("ERROR:可能被风控了")) } // 步骤0,1,2,依次选择3个类别 step := 0 @@ -102,7 +102,7 @@ func init() { log.Errorln("[vtb]:", err) } if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(firstStepImageBytes))); id.ID() == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) + ctx.SendChain(message.Text("ERROR:可能被风控了")) } errorCount++ } else { @@ -111,7 +111,7 @@ func init() { log.Errorln("[vtb]:", err) } if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(secondStepMessageBytes))); id.ID() == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) + ctx.SendChain(message.Text("ERROR:可能被风控了")) } step++ } @@ -133,7 +133,7 @@ func init() { log.Errorln("[vtb]:", err) } if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(secondStepMessageBytes))); id.ID() == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) + ctx.SendChain(message.Text("ERROR:可能被风控了")) } errorCount++ } else { @@ -142,7 +142,7 @@ func init() { log.Errorln("[vtb]:", err) } if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(thirdStepMessageBytes))); id.ID() == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) + ctx.SendChain(message.Text("ERROR:可能被风控了")) } step++ } @@ -165,7 +165,7 @@ func init() { log.Errorln("[vtb]:", err) } if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(firstStepImageBytes))); id.ID() == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) + ctx.SendChain(message.Text("ERROR:可能被风控了")) } errorCount++ step = 1 diff --git a/plugin/wtf/main.go b/plugin/wtf/main.go index 83568654..664fab63 100644 --- a/plugin/wtf/main.go +++ b/plugin/wtf/main.go @@ -31,7 +31,7 @@ func init() { // 调用接口 i, err := strconv.Atoi(ctx.State["regex_matched"].([]string)[1]) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } w := newWtf(i) @@ -54,7 +54,7 @@ func init() { text, err = w.predict(name) } if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + ctx.SendChain(message.Text("ERROR:", err)) return } // TODO: 可注入 diff --git a/plugin/ymgal/ymgal.go b/plugin/ymgal/ymgal.go index 69c3d000..6afe74d0 100644 --- a/plugin/ymgal/ymgal.go +++ b/plugin/ymgal/ymgal.go @@ -71,6 +71,6 @@ func sendYmgal(y ymgal, ctx *zero.Ctx) { if id := ctx.SendGroupForwardMessage( ctx.Event.GroupID, m).Get("message_id").Int(); id == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) + ctx.SendChain(message.Text("ERROR:可能被风控了")) } }