diff --git a/README.md b/README.md index 0d8904085e..c7e7cbe5eb 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]
@@ -559,7 +559,7 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] b站推送列表 - - [x] 拉取b站推送 (使用job执行定时任务------记录在"@every 10s"触发的指令) + - [x] 拉取b站推送 (使用job执行定时任务------记录在"@every 5m"触发的指令)
@@ -1283,6 +1283,22 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] 黄油角色[@xxx] +
+
+ steam + + `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/steam"` + + - [x] steam[添加|删除]订阅xxxxx + + - [x] steam查看订阅 + + - [x] steam绑定 api key xxxxxxx + + - [x] 查看apikey + + - [x] 拉取steam订阅 (使用job执行定时任务------记录在"@every 1m"触发的指令) +
抽塔罗牌 diff --git a/go.mod b/go.mod index 4c02a0938b..7d972c83c4 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/FloatTech/AnimeAPI v1.6.1-0.20230316111643-46d40c9d80e3 github.com/FloatTech/floatbox v0.0.0-20230316111222-7ffde57284cc github.com/FloatTech/gg v1.1.2 - github.com/FloatTech/imgfactory v0.2.2-0.20230315152233-49741fc994f9 + github.com/FloatTech/imgfactory v0.2.2-0.20230322091809-b0ddbe44b94b github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9 github.com/FloatTech/sqlite v1.5.7 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b diff --git a/go.sum b/go.sum index c53d9f14e0..b86a1dc55d 100644 --- a/go.sum +++ b/go.sum @@ -13,6 +13,8 @@ github.com/FloatTech/gg v1.1.2 h1:YolgOYg3uDHc1+g0bLtt6QuRA/pvLn+b9IBCIhOOX88= github.com/FloatTech/gg v1.1.2/go.mod h1:uzPzAeT35egARdRuu+1oyjU3CmTwCceoq3Vvje7LpcI= github.com/FloatTech/imgfactory v0.2.2-0.20230315152233-49741fc994f9 h1:IzZLuM/fgKclyMaU/Qb1qlLdGrs2FTietkqOWhh07Gw= github.com/FloatTech/imgfactory v0.2.2-0.20230315152233-49741fc994f9/go.mod h1:el5hGpj1C1bDRxcTXYRwEivDCr40zZeJpcrLrB1fajs= +github.com/FloatTech/imgfactory v0.2.2-0.20230322091809-b0ddbe44b94b h1:VMNci4SWBySdw/6poqF9Dn9zlT5ntTFSJOEEBjRnJ/4= +github.com/FloatTech/imgfactory v0.2.2-0.20230322091809-b0ddbe44b94b/go.mod h1:el5hGpj1C1bDRxcTXYRwEivDCr40zZeJpcrLrB1fajs= github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9 h1:hffajvmQFfP68U6wUwHemPuuwCUoss+SEFfoLYwbGwE= github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9/go.mod h1:NBFPhWae4hqVMeG8ELBBnUQkKce3nDjkljVn6PdiUNs= github.com/FloatTech/sqlite v1.5.7 h1:Bvo4LSojcZ6dVtbHrkqvt6z4v8e+sj0G5PSUIvdawsk= diff --git a/kanban/banner/banner.go b/kanban/banner/banner.go index 3f8313e161..b372b83865 100644 --- a/kanban/banner/banner.go +++ b/kanban/banner/banner.go @@ -3,13 +3,13 @@ package banner // Version ... -var Version = "v1.7.0-beta5" +var Version = "v1.7.0" // Copyright ... var Copyright = "© 2020 - 2023 FloatTech" // Banner ... var Banner = "* OneBot + ZeroBot + Golang\n" + - "* Version " + Version + " - 2023-03-16 19:22:03 +0800 CST\n" + + "* Version " + Version + " - 2023-03-20 12:27:42 +0800 CST\n" + "* Copyright " + Copyright + ". All Rights Reserved.\n" + "* Project: https://github.com/FloatTech/ZeroBot-Plugin" diff --git a/main.go b/main.go index 4eda0e1c96..07428b1b23 100644 --- a/main.go +++ b/main.go @@ -135,6 +135,7 @@ import ( _ "github.com/FloatTech/ZeroBot-Plugin/plugin/setutime" // 来份涩图 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/shadiao" // 沙雕app _ "github.com/FloatTech/ZeroBot-Plugin/plugin/shindan" // 测定 + _ "github.com/FloatTech/ZeroBot-Plugin/plugin/steam" // steam相关 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/tarot" // 抽塔罗牌 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/tiangou" // 舔狗日记 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/tracemoe" // 搜番 @@ -249,13 +250,12 @@ func init() { fmt.Println("Usage:") flag.PrintDefaults() os.Exit(0) - } else { - if *d && !*w { - logrus.SetLevel(logrus.DebugLevel) - } - if *w { - logrus.SetLevel(logrus.WarnLevel) - } + } + if *d && !*w { + logrus.SetLevel(logrus.DebugLevel) + } + if *w { + logrus.SetLevel(logrus.WarnLevel) } for _, s := range flag.Args() { diff --git a/plugin/atri/atri.go b/plugin/atri/atri.go index d72277f3af..2884a7a277 100644 --- a/plugin/atri/atri.go +++ b/plugin/atri/atri.go @@ -40,7 +40,7 @@ func randText(text ...string) message.MessageSegment { } // isAtriSleeping 凌晨0点到6点,ATRI 在睡觉,不回应任何请求 -func isAtriSleeping(ctx *zero.Ctx) bool { +func isAtriSleeping(*zero.Ctx) bool { if now := time.Now().Hour(); now >= 1 && now < 6 { return true } diff --git a/plugin/baidu/search.go b/plugin/baidu/search.go index 642804d458..887bdeac1f 100644 --- a/plugin/baidu/search.go +++ b/plugin/baidu/search.go @@ -1,27 +1,51 @@ -// Package baidu 百度一下 +// Package baidu 百度百科 package baidu 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 ( + api = "https://api.a20safe.com/api.php?api=21&key=7d06a110e9e20a684e02934549db1d3d&text=%s" // api地址 ) -func init() { - control.Register("baidu", &ctrl.Options[*zero.Ctx]{ +type result 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(api, ctx.State["regex_matched"].([]string)[1])) // 将网站返回结果赋值 + if err != nil { + ctx.SendChain(message.Text("出现错误捏:", err)) + return + } + var r result // r数组 + err = json.Unmarshal(es, &r) // 填api返回结果,struct地址 + if err != nil { + ctx.SendChain(message.Text("出现错误捏:", err)) + return + } + if r.Code == 0 && len(r.Data) > 0 { + ctx.SendChain(message.Text(r.Data[0].Content)) // 输出提取后的结果 + } else { + ctx.SendChain(message.Text("API访问错误")) + } + }) } diff --git a/plugin/drawlots/main.go b/plugin/drawlots/main.go index 5097ffbc2f..096dcff875 100644 --- a/plugin/drawlots/main.go +++ b/plugin/drawlots/main.go @@ -244,10 +244,10 @@ func randGif(gifName string) (image.Image, error) { return nil, err } v := im.Image[rand.Intn(len(im.Image))] - return imgfactory.Size(firstImg, firstImg.Bounds().Max.X, firstImg.Bounds().Max.Y).InsertUpC(v, 0, 0, firstImg.Bounds().Max.X/2, firstImg.Bounds().Max.Y/2).Clone().Image(),err + return imgfactory.Size(firstImg, firstImg.Bounds().Dx(), firstImg.Bounds().Dy()).InsertUpC(v, 0, 0, firstImg.Bounds().Dx()/2, firstImg.Bounds().Dy()/2).Clone().Image(),err /*/ // 如果gif图片出现信息缺失请使用上面注释掉的代码,把下面注释了(上面代码部分图存在bug) v := im.Image[rand.Intn(len(im.Image))] - return imgfactory.NewFactoryBG(v.Rect.Max.X, v.Rect.Max.Y, color.NRGBA{0, 0, 0, 255}).InsertUp(v, 0, 0, 0, 0).Clone().Image(), err + return imgfactory.NewFactoryBG(v.Rect.Dx(), v.Rect.Dy(), color.NRGBA{0, 0, 0, 255}).InsertUp(v, 0, 0, 0, 0).Clone().Image(), err // */ } diff --git a/plugin/gif/gif.go b/plugin/gif/gif.go index 0b8d57274f..1174f2f5a3 100644 --- a/plugin/gif/gif.go +++ b/plugin/gif/gif.go @@ -1404,7 +1404,7 @@ func alwaysDoGif(cc *context, value ...string) (string, error) { var err error var face []*imgfactory.Factory name := cc.usrdir + "AlwaysDo.gif" - face, err = imgfactory.LoadAllFrames(cc.headimgsdir[0], 500, 500) + face, err = imgfactory.LoadAllTrueFrames(cc.headimgsdir[0], 500, 500) if err != nil { // 载入失败尝试载入第一帧 face = nil @@ -1438,7 +1438,7 @@ func alwaysDoGif(cc *context, value ...string) (string, error) { canvas := gg.NewContext(500, 600) canvas.DrawImage(f.Image(), 0, 0) canvas.SetColor(color.Black) - // _ = canvas.ParseFontFace(data, 40) + _ = canvas.ParseFontFace(data, 40) canvas.DrawString(arg, 280-l, 560) canvas.DrawImage(imgfactory.Size(f.Image(), 90, 90).Image(), 280, 505) canvas.DrawString("吗", 370, 560) 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地址 ) diff --git a/plugin/saucenao/searcher.go b/plugin/saucenao/searcher.go index a6aa67e99f..2c149d7423 100644 --- a/plugin/saucenao/searcher.go +++ b/plugin/saucenao/searcher.go @@ -162,27 +162,27 @@ func init() { // 插件主体 ctx.SendChain(message.Text("请私聊发送 设置 saucenao api key [apikey] 以启用 saucenao 搜图 (方括号不需要输入), key 请前往 https://saucenao.com/user.php?page=search-api 获取")) } // ascii2d 搜索 - if result, err := ascii2d.ASCII2d(pic); err != nil { + result, err := ascii2d.ASCII2d(pic) + if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) continue - } else { - msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("ascii2d搜图结果"))} - for i := 0; i < len(result) && i < 5; i++ { - 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.Send(msg).ID(); id == 0 { - ctx.SendChain(message.Text("ERROR: 可能被风控了")) - } + } + msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("ascii2d搜图结果"))} + for i := 0; i < len(result) && i < 5; i++ { + 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.Send(msg).ID(); id == 0 { + ctx.SendChain(message.Text("ERROR: 可能被风控了")) } } }) diff --git a/plugin/setutime/setu_geter.go b/plugin/setutime/setu_geter.go index 39b6717d37..4b9c0afaf3 100644 --- a/plugin/setutime/setu_geter.go +++ b/plugin/setutime/setu_geter.go @@ -236,10 +236,7 @@ func (p *imgpool) add(ctx *zero.Ctx, imgtype string, id int64) error { return err } // 添加插画到对应的数据库table - if err := p.db.Insert(imgtype, illust); err != nil { - return err - } - return nil + return p.db.Insert(imgtype, illust) } func (p *imgpool) remove(imgtype string, id int64) error { diff --git a/plugin/sleep_manage/sleep_manage.go b/plugin/sleep_manage/sleep_manage.go index ce5d92a8cd..e233262aec 100644 --- a/plugin/sleep_manage/sleep_manage.go +++ b/plugin/sleep_manage/sleep_manage.go @@ -55,13 +55,13 @@ func timeDuration(time time.Duration) (hour, minute, second int64) { } // 只统计6点到12点的早安 -func isMorning(ctx *zero.Ctx) bool { +func isMorning(*zero.Ctx) bool { now := time.Now().Hour() return now >= 6 && now <= 12 } // 只统计21点到凌晨3点的晚安 -func isEvening(ctx *zero.Ctx) bool { +func isEvening(*zero.Ctx) bool { now := time.Now().Hour() return now >= 21 || now <= 3 } diff --git a/plugin/steam/listenter.go b/plugin/steam/listenter.go index 75ae1ade18..976826558e 100644 --- a/plugin/steam/listenter.go +++ b/plugin/steam/listenter.go @@ -9,7 +9,6 @@ import ( "github.com/FloatTech/floatbox/binary" "github.com/FloatTech/floatbox/web" ctrl "github.com/FloatTech/zbpctrl" - "github.com/sirupsen/logrus" "github.com/tidwall/gjson" zero "github.com/wdvxdr1123/ZeroBot" "github.com/wdvxdr1123/ZeroBot/message" @@ -116,14 +115,12 @@ func getPlayerStatus(streamIds ...string) ([]*player, error) { players := make([]*player, 0) // 拼接请求地址 url := fmt.Sprintf(URL+StatusURL, apiKey, strings.Join(streamIds, ",")) - logrus.Debugln("[steamstatus] getPlayerStatus url:", url) // 拉取并解析数据 data, err := web.GetData(url) if err != nil { return players, err } dataStr := binary.BytesToString(data) - logrus.Debugln("[steamstatus] getPlayerStatus data:", dataStr) index := gjson.Get(dataStr, "response.players.#").Uint() for i := uint64(0); i < index; i++ { players = append(players, &player{ @@ -133,6 +130,5 @@ func getPlayerStatus(streamIds ...string) ([]*player, error) { GameExtraInfo: gjson.Get(dataStr, fmt.Sprintf("response.players.%d.gameextrainfo", i)).String(), }) } - logrus.Debugln("[steamstatus] getPlayerStatus players:", players) return players, nil } diff --git a/plugin/steam/steam.go b/plugin/steam/steam.go index 925dc90a99..db51b2b5f0 100644 --- a/plugin/steam/steam.go +++ b/plugin/steam/steam.go @@ -24,7 +24,7 @@ var ( "- steam删除订阅 xxxxxxx (删除你创建的对于 steamid 的绑定)\n" + "- steam查询订阅 (查询本群内所有的绑定对象)\n" + "-----------------------\n" + - "- steam绑定 api key xxxxxxx (密钥在steam网站申请, 申请地址: https://steamcommunity.com/dev/registerkey)\n" + + "- steam绑定 api key xxxxxxx (密钥在steam网站申请, 申请地址: https://steamcommunity.com/dev/apikey)\n" + "- 查看apikey (查询已经绑定的密钥)\n" + "- 拉取steam订阅 (使用插件定时任务开始)\n" + "-----------------------\n" + diff --git a/winres/winres.json b/winres/winres.json index b81b3d5516..48c0ede1d5 100644 --- a/winres/winres.json +++ b/winres/winres.json @@ -12,7 +12,7 @@ "0409": { "identity": { "name": "ZeroBot-Plugin", - "version": "1.7.0.1749" + "version": "1.7.0.1760" }, "description": "", "minimum-os": "vista", @@ -36,23 +36,23 @@ "#1": { "0000": { "fixed": { - "file_version": "1.7.0.1749", - "product_version": "v1.7.0-beta5", - "timestamp": "2023-03-16T19:22:18+08:00" + "file_version": "1.7.0.1760", + "product_version": "v1.7.0", + "timestamp": "2023-03-20T12:28:01+08:00" }, "info": { "0409": { "Comments": "OneBot plugins based on ZeroBot", "CompanyName": "FloatTech", "FileDescription": "https://github.com/FloatTech/ZeroBot-Plugin", - "FileVersion": "1.7.0.1749", + "FileVersion": "1.7.0.1760", "InternalName": "", "LegalCopyright": "© 2020 - 2023 FloatTech. All Rights Reserved.", "LegalTrademarks": "", "OriginalFilename": "ZBP.EXE", "PrivateBuild": "", "ProductName": "ZeroBot-Plugin", - "ProductVersion": "v1.7.0-beta5", + "ProductVersion": "v1.7.0", "SpecialBuild": "" } }