From ee96e9b870f4dfa05b1b26143ef198d0ddd1672f Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Mon, 6 Feb 2023 20:15:06 +0800 Subject: [PATCH 01/27] readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index fb4082bb99..437c0c2fc1 100644 --- a/README.md +++ b/README.md @@ -1531,6 +1531,9 @@ GOOS=linux GOARCH=mips GOMIPS=softfloat CGO_ENABLED=0 go build -ldflags "-s -w" 5. 运行 OneBot 框架,并同时运行本插件 +# 关联项目 +- [kokomi-原神面板插件](https://github.com/lianhong2758/kokomi-plugin) + ## 特别感谢 - [ZeroBot](https://github.com/wdvxdr1123/ZeroBot) From eb5a98d926d7261844fe75040978ef1aa066936e Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Mon, 6 Feb 2023 20:15:48 +0800 Subject: [PATCH 02/27] 1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 437c0c2fc1..0e0a197d51 100644 --- a/README.md +++ b/README.md @@ -1532,7 +1532,7 @@ GOOS=linux GOARCH=mips GOMIPS=softfloat CGO_ENABLED=0 go build -ldflags "-s -w" 5. 运行 OneBot 框架,并同时运行本插件 # 关联项目 -- [kokomi-原神面板插件](https://github.com/lianhong2758/kokomi-plugin) +- [kokomi-原神面板查询插件](https://github.com/lianhong2758/kokomi-plugin) ## 特别感谢 From 8747f613b14eced2affd0d7c28619902d64fbe0c Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Mon, 6 Feb 2023 20:16:03 +0800 Subject: [PATCH 03/27] 1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e0a197d51..7f89a08cc8 100644 --- a/README.md +++ b/README.md @@ -1531,7 +1531,7 @@ GOOS=linux GOARCH=mips GOMIPS=softfloat CGO_ENABLED=0 go build -ldflags "-s -w" 5. 运行 OneBot 框架,并同时运行本插件 -# 关联项目 +## 关联项目 - [kokomi-原神面板查询插件](https://github.com/lianhong2758/kokomi-plugin) ## 特别感谢 From 836722db9684d2fe24a33576643d34a98925bf09 Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Mon, 6 Feb 2023 22:11:14 +0800 Subject: [PATCH 04/27] =?UTF-8?q?kokomi=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7f89a08cc8..ac2636fae2 100644 --- a/README.md +++ b/README.md @@ -872,6 +872,18 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] 喝奶茶绝绝子 | 绝绝子吃饭 + +
+ lolicon + + `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/kokomi"` + + - [x] kokomi菜单 + + - [x] XX面板 + + - [x] 注:本插件未并入主仓库,需自行安装(须源码方式运行才能添加插件),安装地址- [kokomi-原神面板查询插件](https://github.com/lianhong2758/kokomi-plugin) +
lolicon @@ -1531,9 +1543,6 @@ GOOS=linux GOARCH=mips GOMIPS=softfloat CGO_ENABLED=0 go build -ldflags "-s -w" 5. 运行 OneBot 框架,并同时运行本插件 -## 关联项目 -- [kokomi-原神面板查询插件](https://github.com/lianhong2758/kokomi-plugin) - ## 特别感谢 - [ZeroBot](https://github.com/wdvxdr1123/ZeroBot) From e0606caabec941b7035dbf686570173948f9073d Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Mon, 6 Feb 2023 22:13:09 +0800 Subject: [PATCH 05/27] change --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ac2636fae2..a7e094b5c1 100644 --- a/README.md +++ b/README.md @@ -874,7 +874,7 @@ print("run[CQ:image,file="+j["img"]+"]")
- lolicon + kokomi原神面板 `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/kokomi"` From 6815399fcb9d0567d31efb3b7ed4fe2b4de867cc Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Mon, 6 Feb 2023 22:20:28 +0800 Subject: [PATCH 06/27] 1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a7e094b5c1..b9d37f7b31 100644 --- a/README.md +++ b/README.md @@ -882,7 +882,7 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] XX面板 - - [x] 注:本插件未并入主仓库,需自行安装(须源码方式运行才能添加插件),安装地址- [kokomi-原神面板查询插件](https://github.com/lianhong2758/kokomi-plugin) + - 注:本插件未并入主仓库,需自行安装(须源码方式运行才能添加插件),安装地址- [kokomi-原神面板查询插件](https://github.com/lianhong2758/kokomi-plugin)
From 982e3ce466d31c9b3953101f1a64c29289000225 Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Mon, 6 Feb 2023 22:20:45 +0800 Subject: [PATCH 07/27] 1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b9d37f7b31..bbb9531fcd 100644 --- a/README.md +++ b/README.md @@ -882,7 +882,7 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] XX面板 - - 注:本插件未并入主仓库,需自行安装(须源码方式运行才能添加插件),安装地址- [kokomi-原神面板查询插件](https://github.com/lianhong2758/kokomi-plugin) + - 注:本插件未并入主仓库,需自行安装(须源码方式运行才能添加插件),安装地址- [kokomi-原神面板查询插件](https://github.com/lianhong2758/kokomi-plugin)
From bb9c6b83ffb343b4e0efb23c5872d0a4f5816473 Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Mon, 6 Feb 2023 22:21:02 +0800 Subject: [PATCH 08/27] change --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bbb9531fcd..b9d37f7b31 100644 --- a/README.md +++ b/README.md @@ -882,7 +882,7 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] XX面板 - - 注:本插件未并入主仓库,需自行安装(须源码方式运行才能添加插件),安装地址- [kokomi-原神面板查询插件](https://github.com/lianhong2758/kokomi-plugin) + - 注:本插件未并入主仓库,需自行安装(须源码方式运行才能添加插件),安装地址- [kokomi-原神面板查询插件](https://github.com/lianhong2758/kokomi-plugin)
From 512b4de91d3c9b6267a6382842c92973a5263e64 Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Mon, 6 Feb 2023 22:21:19 +0800 Subject: [PATCH 09/27] change --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b9d37f7b31..dce2097ac9 100644 --- a/README.md +++ b/README.md @@ -882,7 +882,7 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] XX面板 - - 注:本插件未并入主仓库,需自行安装(须源码方式运行才能添加插件),安装地址- [kokomi-原神面板查询插件](https://github.com/lianhong2758/kokomi-plugin) + - 注:本插件未并入主仓库,需自行安装(须源码方式运行才能添加插件),安装地址[kokomi-原神面板查询插件](https://github.com/lianhong2758/kokomi-plugin)
From aab4372967e232a0ebbe9419781e5c49b31f8e57 Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Tue, 7 Feb 2023 16:24:50 +0800 Subject: [PATCH 10/27] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dapi=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/moegoe/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/moegoe/main.go b/plugin/moegoe/main.go index d5a4f964aa..cdfc176d9d 100644 --- a/plugin/moegoe/main.go +++ b/plugin/moegoe/main.go @@ -16,7 +16,7 @@ import ( const ( jpapi = "https://moegoe.azurewebsites.net/api/speak?text=%s&id=%d" krapi = "https://moegoe.azurewebsites.net/api/speakkr?text=%s&id=%d" - cnapi = "http://267978.proxy.nscc-gz.cn:8888?text=%s&speaker=%s" + cnapi = "https://genshinvoice.top/api?speaker=%v&text=%v&format=wav&length=1&noise=0.6&noisew=0.8" ) var speakers = map[string]uint{ @@ -48,6 +48,6 @@ func init() { Handle(func(ctx *zero.Ctx) { text := ctx.State["regex_matched"].([]string)[2] speaker := ctx.State["regex_matched"].([]string)[1] - ctx.SendChain(message.Record(fmt.Sprintf(cnapi, url.QueryEscape(text), speaker))) + ctx.SendChain(message.Record(fmt.Sprintf(cnapi, speaker, url.QueryEscape(text)))) }) } From 0186e6a03d22b3695450e047dc2c94ef6ddf09b7 Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Tue, 7 Feb 2023 16:45:48 +0800 Subject: [PATCH 11/27] =?UTF-8?q?=E6=94=B9=E4=BA=86,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/moegoe/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/moegoe/main.go b/plugin/moegoe/main.go index cdfc176d9d..0ed493fb18 100644 --- a/plugin/moegoe/main.go +++ b/plugin/moegoe/main.go @@ -16,7 +16,7 @@ import ( const ( jpapi = "https://moegoe.azurewebsites.net/api/speak?text=%s&id=%d" krapi = "https://moegoe.azurewebsites.net/api/speakkr?text=%s&id=%d" - cnapi = "https://genshinvoice.top/api?speaker=%v&text=%v&format=wav&length=1&noise=0.6&noisew=0.8" + cnapi = "https://genshinvoice.top/api?text=%v&speaker=%v&format=wav&length=1&noise=0.6&noisew=0.8,cache=0]" ) var speakers = map[string]uint{ @@ -48,6 +48,6 @@ func init() { Handle(func(ctx *zero.Ctx) { text := ctx.State["regex_matched"].([]string)[2] speaker := ctx.State["regex_matched"].([]string)[1] - ctx.SendChain(message.Record(fmt.Sprintf(cnapi, speaker, url.QueryEscape(text)))) + ctx.SendChain(message.Record(fmt.Sprintf(cnapi, url.QueryEscape(text), speaker))) }) } From 551f00f8e26ed10a05ca1c925f2f2ee89905fa3f Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Tue, 7 Feb 2023 16:46:04 +0800 Subject: [PATCH 12/27] 1 --- plugin/moegoe/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/moegoe/main.go b/plugin/moegoe/main.go index 0ed493fb18..c38ac59376 100644 --- a/plugin/moegoe/main.go +++ b/plugin/moegoe/main.go @@ -16,7 +16,7 @@ import ( const ( jpapi = "https://moegoe.azurewebsites.net/api/speak?text=%s&id=%d" krapi = "https://moegoe.azurewebsites.net/api/speakkr?text=%s&id=%d" - cnapi = "https://genshinvoice.top/api?text=%v&speaker=%v&format=wav&length=1&noise=0.6&noisew=0.8,cache=0]" + cnapi = "https://genshinvoice.top/api?text=%v&speaker=%v&format=wav&length=1&noise=0.6&noisew=0.8" ) var speakers = map[string]uint{ From abf1b72d9d6b4569ef76d83f7307a0dd16888a40 Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Tue, 7 Feb 2023 16:49:09 +0800 Subject: [PATCH 13/27] 0 --- plugin/moegoe/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/moegoe/main.go b/plugin/moegoe/main.go index c38ac59376..5619805252 100644 --- a/plugin/moegoe/main.go +++ b/plugin/moegoe/main.go @@ -16,7 +16,7 @@ import ( const ( jpapi = "https://moegoe.azurewebsites.net/api/speak?text=%s&id=%d" krapi = "https://moegoe.azurewebsites.net/api/speakkr?text=%s&id=%d" - cnapi = "https://genshinvoice.top/api?text=%v&speaker=%v&format=wav&length=1&noise=0.6&noisew=0.8" + cnapi = "https://genshinvoice.top/api?text=%s&speaker=%s&format=wav&length=1&noise=0.6&noisew=0.8" ) var speakers = map[string]uint{ From b073ce01ecae9b9e0a1324df6dd935b746a13967 Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Sun, 19 Feb 2023 18:48:29 +0800 Subject: [PATCH 14/27] =?UTF-8?q?=E5=8A=A0=E5=BF=AB=E8=87=AA=E6=A3=80?= =?UTF-8?q?=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/ai_false/ai_false.go | 78 ++++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 13 deletions(-) diff --git a/plugin/ai_false/ai_false.go b/plugin/ai_false/ai_false.go index 6ca3007190..1852bfb87f 100644 --- a/plugin/ai_false/ai_false.go +++ b/plugin/ai_false/ai_false.go @@ -40,6 +40,7 @@ import ( const ( backgroundURL = "https://iw233.cn/api.php?sort=mp" referer = "https://weibo.com/" + picPath = "data/aifalse/pic.png" ) var boottime = time.Now() @@ -50,6 +51,7 @@ func init() { // 插件主体 Brief: "自检, 全局限速", Help: "- 查询计算机当前活跃度: [检查身体 | 自检 | 启动自检 | 系统状态]\n" + "- 设置默认限速为每 m [分钟 | 秒] n 次触发", + PrivateDataFolder: "aifalse", }) c, ok := control.Lookup("aifalse") if !ok { @@ -67,16 +69,20 @@ func init() { // 插件主体 img, err := drawstatus(ctx.State["manager"].(*ctrl.Control[*zero.Ctx]), ctx.Event.SelfID, zero.BotConfig.NickName[0]) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) + dowPicture() return } sendimg, err := imgfactory.ToBytes(img) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) + dowPicture() return } if id := ctx.SendChain(message.ImageBytes(sendimg)); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } + time.Sleep(3 * time.Second) //3s + dowPicture() }) engine.OnRegex(`^设置默认限速为每\s*(\d+)\s*(分钟|秒)\s*(\d+)\s*次触发$`, zero.SuperUserPermission).SetBlock(true). Handle(func(ctx *zero.Ctx) { @@ -133,21 +139,18 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg if err != nil { return } - - url, err := bilibili.GetRealURL(backgroundURL) - if err != nil { - return - } - data, err := web.RequestDataWith(web.NewDefaultClient(), url, "", referer, "", nil) + back, err := gg.LoadPNG(picPath) if err != nil { - return - } - back, _, err := image.Decode(bytes.NewReader(data)) - if err != nil { - return + err = dowPicture() + if err != nil { + return + } + back, err = gg.LoadPNG(picPath) + if err != nil { + return + } } - - data, err = web.GetData("http://q4.qlogo.cn/g?b=qq&nk=" + strconv.FormatInt(uid, 10) + "&s=640") + data, err := web.GetData("http://q4.qlogo.cn/g?b=qq&nk=" + strconv.FormatInt(uid, 10) + "&s=640") if err != nil { return } @@ -234,6 +237,15 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg fw, _ = titlecard.MeasureString(bs) titlecard.DrawStringAnchored(bs, float64(titlecardh)+fw/2, float64(titlecardh)*(0.5+0.5/2), 0.5, 0.5) + + thr, err := botrungroup() + if err != nil { + return + } + fw, _ = titlecard.MeasureString(thr) + + titlecard.DrawStringAnchored(thr, float64(titlecardh)+fw/2, float64(titlecardh)*(0.5+0.75/2), 0.5, 0.5) + titleimg = rendercard.Fillet(titlecard.Image(), 16) }() go func() { @@ -464,6 +476,26 @@ func botruntime() (string, error) { return t.String(), nil } +func botrungroup() (string, error) { + i := 0 + t := &strings.Builder{} + t.WriteString("加入群聊数 ") + t.WriteString("[ ") + zero.RangeBot(func(id int64, ctx *zero.Ctx) bool { + if i > 0 { + t.WriteString(" | ") + } + t.WriteString(strconv.Itoa(len(ctx.GetGroupList().Array()))) + i++ + return true + }) + t.WriteString(" ] | 接收消息 ") + t.WriteString(strconv.FormatInt(zero.GetMessageNum("Re"), 10)) + t.WriteString(" | 发送消息 ") + t.WriteString(strconv.FormatInt(zero.GetMessageNum("sent"), 10)) + return t.String(), nil +} + func botstatus() (string, error) { hostinfo, err := host.Info() if err != nil { @@ -592,3 +624,23 @@ func moreinfo(m *ctrl.Control[*zero.Ctx]) (stateinfo []*status, err error) { } return } + +func dowPicture() error { + url, err := bilibili.GetRealURL(backgroundURL) + if err != nil { + return errors.New("链接转载失败") + } + data, err := web.RequestDataWith(web.NewDefaultClient(), url, "", referer, "", nil) + if err != nil { + return errors.New("获取图片失败") + } + back, _, err := image.Decode(bytes.NewReader(data)) + if err != nil { + return errors.New("解析图片失败") + } + err = gg.SavePNG(picPath, back) + if err != nil { + return errors.New("保存图片失败") + } + return nil +} From 1a337ba8da3028cefb335fd965e473d62602a735 Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Sun, 19 Feb 2023 18:58:43 +0800 Subject: [PATCH 15/27] 1 --- plugin/ai_false/ai_false.go | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/plugin/ai_false/ai_false.go b/plugin/ai_false/ai_false.go index 1852bfb87f..611f434fd8 100644 --- a/plugin/ai_false/ai_false.go +++ b/plugin/ai_false/ai_false.go @@ -135,10 +135,6 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg } moreinfocardh := 30 + (20+32*72/96)*len(moreinfo) + 30 - 20 - basicstate, err := basicstate() - if err != nil { - return - } back, err := gg.LoadPNG(picPath) if err != nil { err = dowPicture() @@ -237,15 +233,6 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg fw, _ = titlecard.MeasureString(bs) titlecard.DrawStringAnchored(bs, float64(titlecardh)+fw/2, float64(titlecardh)*(0.5+0.5/2), 0.5, 0.5) - - thr, err := botrungroup() - if err != nil { - return - } - fw, _ = titlecard.MeasureString(thr) - - titlecard.DrawStringAnchored(thr, float64(titlecardh)+fw/2, float64(titlecardh)*(0.5+0.75/2), 0.5, 0.5) - titleimg = rendercard.Fillet(titlecard.Image(), 16) }() go func() { @@ -476,26 +463,6 @@ func botruntime() (string, error) { return t.String(), nil } -func botrungroup() (string, error) { - i := 0 - t := &strings.Builder{} - t.WriteString("加入群聊数 ") - t.WriteString("[ ") - zero.RangeBot(func(id int64, ctx *zero.Ctx) bool { - if i > 0 { - t.WriteString(" | ") - } - t.WriteString(strconv.Itoa(len(ctx.GetGroupList().Array()))) - i++ - return true - }) - t.WriteString(" ] | 接收消息 ") - t.WriteString(strconv.FormatInt(zero.GetMessageNum("Re"), 10)) - t.WriteString(" | 发送消息 ") - t.WriteString(strconv.FormatInt(zero.GetMessageNum("sent"), 10)) - return t.String(), nil -} - func botstatus() (string, error) { hostinfo, err := host.Info() if err != nil { From a6df63b4591a0ac0d48fce91e70d454fabfa09fb Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Sun, 19 Feb 2023 19:02:25 +0800 Subject: [PATCH 16/27] 2 --- plugin/ai_false/ai_false.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugin/ai_false/ai_false.go b/plugin/ai_false/ai_false.go index 611f434fd8..54ddc70e61 100644 --- a/plugin/ai_false/ai_false.go +++ b/plugin/ai_false/ai_false.go @@ -128,12 +128,15 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg return } diskcardh := 40 + (20+50)*len(diskstate) + 40 - 20 - moreinfo, err := moreinfo(m) if err != nil { return } moreinfocardh := 30 + (20+32*72/96)*len(moreinfo) + 30 - 20 + basicstate, err := basicstate() + if err != nil { + return + } back, err := gg.LoadPNG(picPath) if err != nil { From 03b6cf46659b39b7e60fc481cde2c9c42cb7ee3b Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Sun, 19 Feb 2023 19:03:32 +0800 Subject: [PATCH 17/27] 3 --- plugin/ai_false/ai_false.go | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/ai_false/ai_false.go b/plugin/ai_false/ai_false.go index 54ddc70e61..36c8797527 100644 --- a/plugin/ai_false/ai_false.go +++ b/plugin/ai_false/ai_false.go @@ -128,6 +128,7 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg return } diskcardh := 40 + (20+50)*len(diskstate) + 40 - 20 + moreinfo, err := moreinfo(m) if err != nil { return From 1dd863131224b5c8e0425beabf5e63da4bdead3f Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Sun, 19 Feb 2023 19:05:47 +0800 Subject: [PATCH 18/27] 4 --- plugin/ai_false/ai_false.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/ai_false/ai_false.go b/plugin/ai_false/ai_false.go index 36c8797527..933abb3cb8 100644 --- a/plugin/ai_false/ai_false.go +++ b/plugin/ai_false/ai_false.go @@ -69,20 +69,20 @@ func init() { // 插件主体 img, err := drawstatus(ctx.State["manager"].(*ctrl.Control[*zero.Ctx]), ctx.Event.SelfID, zero.BotConfig.NickName[0]) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) - dowPicture() + _ = dowPicture() return } sendimg, err := imgfactory.ToBytes(img) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) - dowPicture() + _ = dowPicture() return } if id := ctx.SendChain(message.ImageBytes(sendimg)); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } time.Sleep(3 * time.Second) //3s - dowPicture() + _ = dowPicture() }) engine.OnRegex(`^设置默认限速为每\s*(\d+)\s*(分钟|秒)\s*(\d+)\s*次触发$`, zero.SuperUserPermission).SetBlock(true). Handle(func(ctx *zero.Ctx) { From 92959c4842f52c529fd9fa05b97bf30266d7929f Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Sun, 19 Feb 2023 19:40:24 +0800 Subject: [PATCH 19/27] 1 --- plugin/ai_false/ai_false.go | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/plugin/ai_false/ai_false.go b/plugin/ai_false/ai_false.go index 276ea5e3ff..e33fc83cec 100644 --- a/plugin/ai_false/ai_false.go +++ b/plugin/ai_false/ai_false.go @@ -42,7 +42,6 @@ import ( const ( backgroundURL = "https://iw233.cn/api.php?sort=mp" referer = "https://weibo.com/" - picPath = "data/aifalse/pic.png" ) var ( @@ -57,7 +56,6 @@ func init() { // 插件主体 Brief: "自检, 全局限速", Help: "- 查询计算机当前活跃度: [检查身体 | 自检 | 启动自检 | 系统状态]\n" + "- 设置默认限速为每 m [分钟 | 秒] n 次触发", - PrivateDataFolder: "aifalse", }) c, ok := control.Lookup("aifalse") if !ok { @@ -75,20 +73,16 @@ func init() { // 插件主体 img, err := drawstatus(ctx.State["manager"].(*ctrl.Control[*zero.Ctx]), ctx.Event.SelfID, zero.BotConfig.NickName[0]) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) - _ = dowPicture() return } sendimg, err := imgfactory.ToBytes(img) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) - _ = dowPicture() return } if id := ctx.SendChain(message.ImageBytes(sendimg)); id.ID() == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) } - time.Sleep(3 * time.Second) //3s - _ = dowPicture() }) engine.OnRegex(`^设置默认限速为每\s*(\d+)\s*(分钟|秒)\s*(\d+)\s*次触发$`, zero.SuperUserPermission).SetBlock(true). Handle(func(ctx *zero.Ctx) { @@ -140,6 +134,7 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg return } moreinfocardh := 30 + (20+32*72/96)*len(moreinfo) + 30 - 20 + basicstate, err := basicstate() if err != nil { return @@ -609,23 +604,3 @@ func moreinfo(m *ctrl.Control[*zero.Ctx]) (stateinfo []*status, err error) { } return } - -func dowPicture() error { - url, err := bilibili.GetRealURL(backgroundURL) - if err != nil { - return errors.New("链接转载失败") - } - data, err := web.RequestDataWith(web.NewDefaultClient(), url, "", referer, "", nil) - if err != nil { - return errors.New("获取图片失败") - } - back, _, err := image.Decode(bytes.NewReader(data)) - if err != nil { - return errors.New("解析图片失败") - } - err = gg.SavePNG(picPath, back) - if err != nil { - return errors.New("保存图片失败") - } - return nil -} From 9480c88eb5581c7875ae9f6fbf69d3f366e65c67 Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Sun, 19 Feb 2023 20:07:53 +0800 Subject: [PATCH 20/27] 1 --- plugin/ai_false/ai_false.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugin/ai_false/ai_false.go b/plugin/ai_false/ai_false.go index e33fc83cec..81f84f3eb5 100644 --- a/plugin/ai_false/ai_false.go +++ b/plugin/ai_false/ai_false.go @@ -140,19 +140,21 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg return } - data := **(**[]byte)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&bgdata)))) - if data == nil || uintptr(time.Since(boottime).Hours())/24 <= atomic.LoadUintptr(&bgcount) { + dldata := (*[]byte)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&bgdata)))) + if dldata == (*[]byte)(nil) || uintptr(time.Since(boottime).Hours()/24) >= atomic.LoadUintptr(&bgcount) { url, err1 := bilibili.GetRealURL(backgroundURL) if err1 != nil { return nil, err1 } - data, err1 = web.RequestDataWith(web.NewDefaultClient(), url, "", referer, "", nil) + data, err1 := web.RequestDataWith(web.NewDefaultClient(), url, "", referer, "", nil) if err1 != nil { return nil, err1 } atomic.AddUintptr(&bgcount, 1) atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(&bgdata)), unsafe.Pointer(&data)) + dldata = &data } + data := *dldata back, _, err := image.Decode(bytes.NewReader(data)) if err != nil { @@ -603,4 +605,4 @@ func moreinfo(m *ctrl.Control[*zero.Ctx]) (stateinfo []*status, err error) { {name: "Plugin", text: []string{"共 " + strconv.Itoa(count) + " 个"}}, } return -} +} \ No newline at end of file From a287850c7aee6adb4d3f8bd34abbd9c9be373607 Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Fri, 17 Mar 2023 23:16:31 +0800 Subject: [PATCH 21/27] fix jiami --- plugin/jiami/jiami.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/jiami/jiami.go b/plugin/jiami/jiami.go index 290bc02afc..9849054c13 100644 --- a/plugin/jiami/jiami.go +++ b/plugin/jiami/jiami.go @@ -13,8 +13,8 @@ import ( ) const ( - jiami1 = "http://ovooa.com/API/sho_u/?msg=%v" // 加密api地址 - jiami2 = "http://ovooa.com/API/sho_u/?format=1&msg=%v" // 解密api地址 + jiami1 = "http://ovooa.caonm.net/API/sho_u/?msg=%v" // 加密api地址 + jiami2 = "http://ovooa.caonm.net/API/sho_u/?format=1&msg=%v" // 解密api地址 ) From c8c6060e917ad7533369d34a0956a75eadf4f044 Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Fri, 17 Mar 2023 23:17:53 +0800 Subject: [PATCH 22/27] 1 --- plugin/ai_false/ai_false.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/ai_false/ai_false.go b/plugin/ai_false/ai_false.go index f815310564..c3f48aa1e6 100644 --- a/plugin/ai_false/ai_false.go +++ b/plugin/ai_false/ai_false.go @@ -603,4 +603,4 @@ func moreinfo(m *ctrl.Control[*zero.Ctx]) (stateinfo []*status, err error) { {name: "Plugin", text: []string{"共 " + strconv.Itoa(count) + " 个"}}, } return -} \ No newline at end of file +} From 201c6f2f7e961ed1dbf4c5e884b4c97ef26a9c08 Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Sat, 18 Mar 2023 16:47:20 +0800 Subject: [PATCH 23/27] =?UTF-8?q?=E7=99=BE=E5=BA=A6=E7=99=BE=E7=A7=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +-- plugin/baidu/search.go | 56 +++++++++++++++++++++++++++++------------- 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 0d8904085e..99432f1681 100644 --- a/README.md +++ b/README.md @@ -436,11 +436,11 @@ print("run[CQ:image,file="+j["img"]+"]")
- 百度一下 + 百度百科 `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/baidu"` - - [x] 百度下[xxx] + - [x] 百度/百科[xxx]
diff --git a/plugin/baidu/search.go b/plugin/baidu/search.go index 642804d458..c1365354f5 100644 --- a/plugin/baidu/search.go +++ b/plugin/baidu/search.go @@ -1,27 +1,49 @@ -// Package baidu 百度一下 -package baidu +// Package baike 百度百科 +package baike import ( - "net/url" + "encoding/json" + "fmt" + "github.com/FloatTech/floatbox/web" + ctrl "github.com/FloatTech/zbpctrl" + "github.com/FloatTech/zbputils/control" zero "github.com/wdvxdr1123/ZeroBot" "github.com/wdvxdr1123/ZeroBot/message" +) - ctrl "github.com/FloatTech/zbpctrl" - "github.com/FloatTech/zbputils/control" - "github.com/FloatTech/zbputils/ctxext" +const ( + baidu = "https://api.a20safe.com/api.php?api=21&key=7d06a110e9e20a684e02934549db1d3d&text=%s" // api地址 ) -func init() { - control.Register("baidu", &ctrl.Options[*zero.Ctx]{ +type ba struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data []struct { + Content string `json:"content"` + } `json:"data"` +} + +func init() { // 主函数 + en := control.Register("baidu", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, - Brief: "不会百度吗", - Help: "- 百度下[xxx]", - }).OnPrefix("百度下").SetBlock(true).Limit(ctxext.LimitByGroup). - Handle(func(ctx *zero.Ctx) { - txt := ctx.State["args"].(string) - if txt != "" { - ctx.SendChain(message.Text("https://buhuibaidu.me/?s=" + url.QueryEscape(txt))) - } - }) + Help: "百科\n" + + "- 百度/百科+[关键字]", + }) + en.OnRegex(`^[百度|百科]\s*(.+)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) { + es, err := web.GetData(fmt.Sprintf(baidu, ctx.State["regex_matched"].([]string)[1])) // 将网站返回结果赋值 + if err != nil { + ctx.SendChain(message.Text("出现错误捏:", err)) + } + var r ba // r数组 + err = json.Unmarshal(es, &r) // 填api返回结果,struct地址 + if err != nil { + ctx.SendChain(message.Text("出现错误捏:", err)) + } + if r.Code == 0 { + ctx.SendChain(message.Text(r.Data[0].Content)) // 输出提取后的结果 + } else { + ctx.SendChain(message.Text("百度百科未找到信息")) + } + }) } From 83ae8b54e36ef16a3a67b3e398c2f40e7068db03 Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Sat, 18 Mar 2023 16:49:25 +0800 Subject: [PATCH 24/27] 1 --- plugin/baidu/search.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/baidu/search.go b/plugin/baidu/search.go index c1365354f5..5d4aa91e10 100644 --- a/plugin/baidu/search.go +++ b/plugin/baidu/search.go @@ -43,7 +43,7 @@ func init() { // 主函数 if r.Code == 0 { ctx.SendChain(message.Text(r.Data[0].Content)) // 输出提取后的结果 } else { - ctx.SendChain(message.Text("百度百科未找到信息")) + ctx.SendChain(message.Text("Api访问错误")) } }) } From 4b373beb39cccd3207aa01abef92ec111f89e0b0 Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Sat, 18 Mar 2023 16:51:42 +0800 Subject: [PATCH 25/27] fix --- plugin/baidu/search.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/baidu/search.go b/plugin/baidu/search.go index 5d4aa91e10..e6e1c280c3 100644 --- a/plugin/baidu/search.go +++ b/plugin/baidu/search.go @@ -1,5 +1,5 @@ -// Package baike 百度百科 -package baike +// Package baidu 百度百科 +package baidu import ( "encoding/json" From f8a71e005c1a762866916c25a14e421455ab5327 Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Sat, 18 Mar 2023 16:54:34 +0800 Subject: [PATCH 26/27] fix --- plugin/baidu/search.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/baidu/search.go b/plugin/baidu/search.go index e6e1c280c3..fbada0f23b 100644 --- a/plugin/baidu/search.go +++ b/plugin/baidu/search.go @@ -27,7 +27,7 @@ type ba struct { func init() { // 主函数 en := control.Register("baidu", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, - Help: "百科\n" + + Help: "百度百科\n" + "- 百度/百科+[关键字]", }) en.OnRegex(`^[百度|百科]\s*(.+)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) { From eacab9a2bd465829ef45dc69a921f5c5eb5b3109 Mon Sep 17 00:00:00 2001 From: lianhong <2758988938@qq.com> Date: Mon, 20 Mar 2023 12:20:51 +0800 Subject: [PATCH 27/27] fix many bad goods --- plugin/baidu/search.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/plugin/baidu/search.go b/plugin/baidu/search.go index fbada0f23b..853ab76725 100644 --- a/plugin/baidu/search.go +++ b/plugin/baidu/search.go @@ -13,10 +13,10 @@ import ( ) const ( - baidu = "https://api.a20safe.com/api.php?api=21&key=7d06a110e9e20a684e02934549db1d3d&text=%s" // api地址 + api = "https://api.a20safe.com/api.php?api=21&key=7d06a110e9e20a684e02934549db1d3d&text=%s" // api地址 ) -type ba struct { +type result struct { Code int `json:"code"` Msg string `json:"msg"` Data []struct { @@ -28,22 +28,24 @@ func init() { // 主函数 en := control.Register("baidu", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, Help: "百度百科\n" + - "- 百度/百科+[关键字]", + "- 百度/百科[关键字]", }) en.OnRegex(`^[百度|百科]\s*(.+)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) { - es, err := web.GetData(fmt.Sprintf(baidu, ctx.State["regex_matched"].([]string)[1])) // 将网站返回结果赋值 + es, err := web.GetData(fmt.Sprintf(api, ctx.State["regex_matched"].([]string)[1])) // 将网站返回结果赋值 if err != nil { ctx.SendChain(message.Text("出现错误捏:", err)) + return } - var r ba // r数组 + var r result // r数组 err = json.Unmarshal(es, &r) // 填api返回结果,struct地址 if err != nil { ctx.SendChain(message.Text("出现错误捏:", err)) + return } - if r.Code == 0 { + if r.Code == 0 && len(r.Data) > 0 { ctx.SendChain(message.Text(r.Data[0].Content)) // 输出提取后的结果 } else { - ctx.SendChain(message.Text("Api访问错误")) + ctx.SendChain(message.Text("API访问错误")) } }) }