From e5b2b369e324ee02748843b944db66f300c97494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E6=9F=B3=E7=85=9C?= <101934327+fangliuyu@users.noreply.github.com> Date: Wed, 15 Mar 2023 23:03:01 +0800 Subject: [PATCH 01/95] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8A=A0=E7=AD=BE?= =?UTF-8?q?=E9=80=BB=E8=BE=91=20(#620)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update main.go * Update main.go * Update main.go --- plugin/drawlots/main.go | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/plugin/drawlots/main.go b/plugin/drawlots/main.go index dfba45299d..5097ffbc2f 100644 --- a/plugin/drawlots/main.go +++ b/plugin/drawlots/main.go @@ -2,8 +2,10 @@ package drawlots import ( + "bytes" "errors" "image" + "image/color" "image/gif" "math/rand" "os" @@ -11,6 +13,7 @@ import ( "strings" "github.com/FloatTech/floatbox/file" + "github.com/FloatTech/floatbox/web" "github.com/FloatTech/imgfactory" ctrl "github.com/FloatTech/zbpctrl" control "github.com/FloatTech/zbputils/control" @@ -38,9 +41,11 @@ var ( return lotsList }() en = control.Register("drawlots", &ctrl.Options[*zero.Ctx]{ - DisableOnDefault: false, - Brief: "多功能抽签", - Help: "支持图包文件夹和gif抽签\n-------------\n- (刷新)抽签列表\n- 抽[签名]签\n- 看签[gif签名]\n- 加签[签名][gif图片]\n- 删签[gif签名]", + DisableOnDefault: false, + Brief: "多功能抽签", + Help: "支持图包文件夹和gif抽签\n" + + "-------------\n" + + "- (刷新)抽签列表\n- 抽[签名]签\n- 看[gif签名]签\n- 加[签名]签[gif图片]\n- 删[gif签名]签", PrivateDataFolder: "drawlots", }).ApplySingle(ctxext.DefaultSingle) datapath = file.BOTPATH + "/" + en.DataFolder() @@ -96,9 +101,9 @@ func init() { } ctx.SendChain(message.Reply(ctx.Event.MessageID), message.ImageBytes(data)) }) - en.OnPrefix("看签", zero.UserOrGrpAdmin).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { + en.OnRegex(`^看(.+)签$`, zero.UserOrGrpAdmin).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { id := ctx.Event.MessageID - lotsName := strings.TrimSpace(ctx.State["args"].(string)) + lotsName := ctx.State["regex_matched"].([]string)[1] fileInfo, ok := lotsList[lotsName] if !ok { ctx.Send(message.ReplyWithMessage(id, message.Text("才...才没有", lotsName, "签这种东西啦"))) @@ -110,26 +115,25 @@ func init() { } ctx.Send(message.ReplyWithMessage(id, message.Image("file:///"+datapath+lotsName+"."+fileInfo.lotsType))) }) - en.OnPrefix("加签", zero.SuperUserPermission, zero.MustProvidePicture).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { + en.OnRegex(`^加(.+)签.*`, zero.SuperUserPermission, zero.MustProvidePicture).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { id := ctx.Event.MessageID - lotsName := strings.TrimSpace(ctx.State["args"].(string)) + lotsName := ctx.State["regex_matched"].([]string)[1] if lotsName == "" { ctx.Send(message.ReplyWithMessage(id, message.Text("请使用正确的指令形式哦~"))) return } picURL := ctx.State["image_url"].([]string)[0] - err := file.DownloadTo(picURL, datapath+"/"+lotsName+".gif") + gifdata, err := web.GetData(picURL) if err != nil { - ctx.SendChain(message.Text("ERROR:", err)) return } - file, err := os.Open(datapath + "/" + lotsName + ".gif") + im, err := gif.DecodeAll(bytes.NewReader(gifdata)) if err != nil { ctx.SendChain(message.Text("ERROR:", err)) return } - im, err := gif.DecodeAll(file) - _ = file.Close() + fileName := datapath + "/" + lotsName + ".gif" + err = file.DownloadTo(picURL, fileName) if err != nil { ctx.SendChain(message.Text("ERROR:", err)) return @@ -140,9 +144,9 @@ func init() { } ctx.Send(message.ReplyWithMessage(id, message.Text("成功!"))) }) - en.OnPrefix("删签", zero.SuperUserPermission).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { + en.OnRegex(`^删(.+)签$`, zero.SuperUserPermission).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { id := ctx.Event.MessageID - lotsName := strings.TrimSpace(ctx.State["args"].(string)) + lotsName := ctx.State["regex_matched"].([]string)[1] fileInfo, ok := lotsList[lotsName] if !ok { ctx.Send(message.ReplyWithMessage(id, message.Text("才...才没有", lotsName, "签这种东西啦"))) @@ -244,6 +248,6 @@ func randGif(gifName string) (image.Image, error) { /*/ // 如果gif图片出现信息缺失请使用上面注释掉的代码,把下面注释了(上面代码部分图存在bug) v := im.Image[rand.Intn(len(im.Image))] - return imgfactory.Size(v, v.Bounds().Max.X, v.Bounds().Max.Y).Image(), err + 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 // */ } From 56e931665ed69bb8f7f4720b28989fc5f17038c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Thu, 16 Mar 2023 19:18:35 +0800 Subject: [PATCH 02/95] fix: gif by @nekohouse09 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index d26dcfb709..fb3d83b3d9 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/FloatTech/AnimeAPI v1.6.1-0.20230312042320-53aa800c2c58 github.com/FloatTech/floatbox v0.0.0-20230312033609-f3826d7c8d00 github.com/FloatTech/gg v1.1.2 - github.com/FloatTech/imgfactory v0.2.2-0.20230215052637-9f7b05520ca9 + github.com/FloatTech/imgfactory v0.2.2-0.20230315152233-49741fc994f9 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 da22e324f1..1db004f1c5 100644 --- a/go.sum +++ b/go.sum @@ -10,6 +10,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.20230215052637-9f7b05520ca9 h1:Havq0z/N79KeD50L7ms+Hv8F4Sw98Dt8lXM8jECp04o= github.com/FloatTech/imgfactory v0.2.2-0.20230215052637-9f7b05520ca9/go.mod h1:el5hGpj1C1bDRxcTXYRwEivDCr40zZeJpcrLrB1fajs= +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/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= From 5e93368e577f2afd151d477fa3380a5870c511fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Thu, 16 Mar 2023 19:20:28 +0800 Subject: [PATCH 03/95] =?UTF-8?q?fix=20#586:=20=E4=BB=A5=E5=9B=BE=E6=90=9C?= =?UTF-8?q?=E5=9B=BE=E5=88=86=E5=BC=80=E5=8F=91=E6=89=BE=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=20url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 10 +++++----- go.sum | 22 ++++++++++------------ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/go.mod b/go.mod index fb3d83b3d9..5d506aea45 100644 --- a/go.mod +++ b/go.mod @@ -4,15 +4,15 @@ go 1.20 require ( github.com/Baidu-AIP/golang-sdk v1.1.1 - github.com/FloatTech/AnimeAPI v1.6.1-0.20230312042320-53aa800c2c58 - github.com/FloatTech/floatbox v0.0.0-20230312033609-f3826d7c8d00 + 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/rendercard v0.0.10-0.20230223064326-45d29fa4ede9 github.com/FloatTech/sqlite v1.5.7 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b - github.com/FloatTech/zbpctrl v1.5.3-0.20230301071613-f2c5c97cec88 - github.com/FloatTech/zbputils v1.6.2-0.20230312042148-dd8632bf31f5 + github.com/FloatTech/zbpctrl v1.5.3-0.20230316111343-dd078fa43fe3 + github.com/FloatTech/zbputils v1.6.2-0.20230316111555-2d1ec958de04 github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 @@ -37,7 +37,7 @@ require ( github.com/sirupsen/logrus v1.9.0 github.com/tidwall/gjson v1.14.4 github.com/wcharczuk/go-chart/v2 v2.1.0 - github.com/wdvxdr1123/ZeroBot v1.6.10 + github.com/wdvxdr1123/ZeroBot v1.6.11 gitlab.com/gomidi/midi/v2 v2.0.25 golang.org/x/image v0.3.0 golang.org/x/sys v0.4.0 diff --git a/go.sum b/go.sum index 1db004f1c5..201fa93ee7 100644 --- a/go.sum +++ b/go.sum @@ -2,14 +2,12 @@ github.com/Baidu-AIP/golang-sdk v1.1.1 h1:RQsAmgDSAkiq22I6n7XJ2t3afgzFeqjY46FGhv github.com/Baidu-AIP/golang-sdk v1.1.1/go.mod h1:bXnGw7xPeKt8aF7UCELKrV6UZ/46spItONK1RQBQj1Y= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= -github.com/FloatTech/AnimeAPI v1.6.1-0.20230312042320-53aa800c2c58 h1:26/j1fmDkBwk1UwRqMDV8+IC9HMz+9xbncK/Mx3t2YQ= -github.com/FloatTech/AnimeAPI v1.6.1-0.20230312042320-53aa800c2c58/go.mod h1:A+qtDCzq4rtwEcxzB1boBX8wjHxYWTFyafxiq0sNZyA= -github.com/FloatTech/floatbox v0.0.0-20230312033609-f3826d7c8d00 h1:KvQd0IaJqBPkc4mpyldX9UcRVlUPVazlcmS79LU0pJ8= -github.com/FloatTech/floatbox v0.0.0-20230312033609-f3826d7c8d00/go.mod h1:0l1xHjcTlONupyOY5lB5PY6kFWFMHQh89e1Zqm5QZlo= +github.com/FloatTech/AnimeAPI v1.6.1-0.20230316111643-46d40c9d80e3 h1:SyXS1YXrRuzO3YVCZB/5gSX7vaFbSMwzN+RXLNNKq5M= +github.com/FloatTech/AnimeAPI v1.6.1-0.20230316111643-46d40c9d80e3/go.mod h1:h+22XrJTgcn0m4aM3o1pYo5G0+Mv4v7wW5xvZQ4LabY= +github.com/FloatTech/floatbox v0.0.0-20230316111222-7ffde57284cc h1:1yentlIEJImE0rla5xE7o73ZW37eS/byFhPEwx9WYEs= +github.com/FloatTech/floatbox v0.0.0-20230316111222-7ffde57284cc/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI= 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.20230215052637-9f7b05520ca9 h1:Havq0z/N79KeD50L7ms+Hv8F4Sw98Dt8lXM8jECp04o= -github.com/FloatTech/imgfactory v0.2.2-0.20230215052637-9f7b05520ca9/go.mod h1:el5hGpj1C1bDRxcTXYRwEivDCr40zZeJpcrLrB1fajs= 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/rendercard v0.0.10-0.20230223064326-45d29fa4ede9 h1:hffajvmQFfP68U6wUwHemPuuwCUoss+SEFfoLYwbGwE= @@ -18,10 +16,10 @@ github.com/FloatTech/sqlite v1.5.7 h1:Bvo4LSojcZ6dVtbHrkqvt6z4v8e+sj0G5PSUIvdaws github.com/FloatTech/sqlite v1.5.7/go.mod h1:zFbHzRfB+CJ+VidfjuVbrcin3DAz283F7hF1hIeHzpY= github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJGLDNIdRX3BI546D3O7k7vrVueZw= github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= -github.com/FloatTech/zbpctrl v1.5.3-0.20230301071613-f2c5c97cec88 h1:jdTWiYXGtYZhxIn9oGYkObNVa8GtJvki+ihsoMlLJPs= -github.com/FloatTech/zbpctrl v1.5.3-0.20230301071613-f2c5c97cec88/go.mod h1:8IRMtcWhK4S8QdpStJqXQZtIBgAqUH72Imq3BQ45TWg= -github.com/FloatTech/zbputils v1.6.2-0.20230312042148-dd8632bf31f5 h1:/Zm5n+2bIpL5how66638nA0NIy+OQOgiCQuEgDYodpQ= -github.com/FloatTech/zbputils v1.6.2-0.20230312042148-dd8632bf31f5/go.mod h1:0xorZ1IN/UYFCUyUGwHyfA4azQHvDjk0M3F4Mh+gFss= +github.com/FloatTech/zbpctrl v1.5.3-0.20230316111343-dd078fa43fe3 h1:mCVrTvS2LMNaI2bNA1Gu/B4F5MnfGaTaJClgR6+rhdA= +github.com/FloatTech/zbpctrl v1.5.3-0.20230316111343-dd078fa43fe3/go.mod h1:IagyEhY38VcbbQgVRzAM9f9mhaUn90rM5BTPfudtl1g= +github.com/FloatTech/zbputils v1.6.2-0.20230316111555-2d1ec958de04 h1:ovL+7SAPTBCXy6XNRSdJhNvHtbueWCwEb/jtztmizAc= +github.com/FloatTech/zbputils v1.6.2-0.20230316111555-2d1ec958de04/go.mod h1:jUmX4WBgGRcfjGeIobmVao10AHmXtL3gT00qLbx3/yo= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= @@ -205,8 +203,8 @@ github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYm github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4= github.com/wcharczuk/go-chart/v2 v2.1.0 h1:tY2slqVQ6bN+yHSnDYwZebLQFkphK4WNrVwnt7CJZ2I= github.com/wcharczuk/go-chart/v2 v2.1.0/go.mod h1:yx7MvAVNcP/kN9lKXM/NTce4au4DFN99j6i1OwDclNA= -github.com/wdvxdr1123/ZeroBot v1.6.10 h1:exmPWNjWtOMLgLQW/svQDybExRJAfDkjpE3S2U6fBOY= -github.com/wdvxdr1123/ZeroBot v1.6.10/go.mod h1:y29UIOy0RD3P+0meDNIWRhcJF3jtWPN9xP9hgt/AJAU= +github.com/wdvxdr1123/ZeroBot v1.6.11 h1:44Wr6CsCtWlFensK5IhuVCWkosdRw0rA8SygVD8DgoI= +github.com/wdvxdr1123/ZeroBot v1.6.11/go.mod h1:y29UIOy0RD3P+0meDNIWRhcJF3jtWPN9xP9hgt/AJAU= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= From 1d8f5a78693e141c32c3d36f8a8b2f1d59e79725 Mon Sep 17 00:00:00 2001 From: KoiParadise Date: Thu, 16 Mar 2023 19:21:18 +0800 Subject: [PATCH 04/95] fix: unexpected misplaced name (#622) --- plugin/score/sign_in.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/score/sign_in.go b/plugin/score/sign_in.go index 2c0198f317..1b9aecb493 100644 --- a/plugin/score/sign_in.go +++ b/plugin/score/sign_in.go @@ -167,7 +167,7 @@ func init() { } // draw head nickName := ctx.CardOrNickName(uid) - canvas.DrawStringWrapped(nickName, 350, 180, 0.5, 0.5, 0.5, 0.5, gg.AlignLeft) + canvas.DrawString(nickName, 350, 180) canvas.Fill() // main draw data, err = file.GetLazyData(text.FontFile, control.Md5File, true) From 0d85fa04e1c484dca1f32ae14ae73406c2bcfa3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Thu, 16 Mar 2023 19:22:30 +0800 Subject: [PATCH 05/95] =?UTF-8?q?=F0=9F=94=96=20v1.7.0-beta5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kanban/banner/banner.go | 4 ++-- winres/winres.json | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kanban/banner/banner.go b/kanban/banner/banner.go index 22298c863a..3f8313e161 100644 --- a/kanban/banner/banner.go +++ b/kanban/banner/banner.go @@ -3,13 +3,13 @@ package banner // Version ... -var Version = "v1.7.0-beta4" +var Version = "v1.7.0-beta5" // Copyright ... var Copyright = "© 2020 - 2023 FloatTech" // Banner ... var Banner = "* OneBot + ZeroBot + Golang\n" + - "* Version " + Version + " - 2023-03-12 12:28:19 +0800 CST\n" + + "* Version " + Version + " - 2023-03-16 19:22:03 +0800 CST\n" + "* Copyright " + Copyright + ". All Rights Reserved.\n" + "* Project: https://github.com/FloatTech/ZeroBot-Plugin" diff --git a/winres/winres.json b/winres/winres.json index 4c2ecaecc6..b81b3d5516 100644 --- a/winres/winres.json +++ b/winres/winres.json @@ -12,7 +12,7 @@ "0409": { "identity": { "name": "ZeroBot-Plugin", - "version": "1.7.0.1744" + "version": "1.7.0.1749" }, "description": "", "minimum-os": "vista", @@ -36,23 +36,23 @@ "#1": { "0000": { "fixed": { - "file_version": "1.7.0.1744", - "product_version": "v1.7.0-beta4", - "timestamp": "2023-03-12T12:28:32+08:00" + "file_version": "1.7.0.1749", + "product_version": "v1.7.0-beta5", + "timestamp": "2023-03-16T19:22:18+08:00" }, "info": { "0409": { "Comments": "OneBot plugins based on ZeroBot", "CompanyName": "FloatTech", "FileDescription": "https://github.com/FloatTech/ZeroBot-Plugin", - "FileVersion": "1.7.0.1744", + "FileVersion": "1.7.0.1749", "InternalName": "", "LegalCopyright": "© 2020 - 2023 FloatTech. All Rights Reserved.", "LegalTrademarks": "", "OriginalFilename": "ZBP.EXE", "PrivateBuild": "", "ProductName": "ZeroBot-Plugin", - "ProductVersion": "v1.7.0-beta4", + "ProductVersion": "v1.7.0-beta5", "SpecialBuild": "" } } From f7a61ed0ee192914e798ff920a66320146b643e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Thu, 16 Mar 2023 19:24:26 +0800 Subject: [PATCH 06/95] =?UTF-8?q?=F0=9F=8E=A8=20edit=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 69ccfc136b..0d8904085e 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ [![go](https://goreportcard.com/badge/github.com/FloatTech/ZeroBot-Plugin?style=flat-square&logo=go)](https://goreportcard.com/badge/github.com/FloatTech/ZeroBot-Plugin) [![onebot](https://img.shields.io/badge/onebot-v11-black?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHAAAABwCAMAAADxPgR5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAxQTFRF////29vbr6+vAAAAk1hCcwAAAAR0Uk5T////AEAqqfQAAAKcSURBVHja7NrbctswDATQXfD//zlpO7FlmwAWIOnOtNaTM5JwDMa8E+PNFz7g3waJ24fviyDPgfhz8fHP39cBcBL9KoJbQUxjA2iYqHL3FAnvzhL4GtVNUcoSZe6eSHizBcK5LL7dBr2AUZlev1ARRHCljzRALIEog6H3U6bCIyqIZdAT0eBuJYaGiJaHSjmkYIZd+qSGWAQnIaz2OArVnX6vrItQvbhZJtVGB5qX9wKqCMkb9W7aexfCO/rwQRBzsDIsYx4AOz0nhAtWu7bqkEQBO0Pr+Ftjt5fFCUEbm0Sbgdu8WSgJ5NgH2iu46R/o1UcBXJsFusWF/QUaz3RwJMEgngfaGGdSxJkE/Yg4lOBryBiMwvAhZrVMUUvwqU7F05b5WLaUIN4M4hRocQQRnEedgsn7TZB3UCpRrIJwQfqvGwsg18EnI2uSVNC8t+0QmMXogvbPg/xk+Mnw/6kW/rraUlvqgmFreAA09xW5t0AFlHrQZ3CsgvZm0FbHNKyBmheBKIF2cCA8A600aHPmFtRB1XvMsJAiza7LpPog0UJwccKdzw8rdf8MyN2ePYF896LC5hTzdZqxb6VNXInaupARLDNBWgI8spq4T0Qb5H4vWfPmHo8OyB1ito+AysNNz0oglj1U955sjUN9d41LnrX2D/u7eRwxyOaOpfyevCWbTgDEoilsOnu7zsKhjRCsnD/QzhdkYLBLXjiK4f3UWmcx2M7PO21CKVTH84638NTplt6JIQH0ZwCNuiWAfvuLhdrcOYPVO9eW3A67l7hZtgaY9GZo9AFc6cryjoeFBIWeU+npnk/nLE0OxCHL1eQsc1IciehjpJv5mqCsjeopaH6r15/MrxNnVhu7tmcslay2gO2Z1QfcfX0JMACG41/u0RrI9QAAAABJRU5ErkJggg==)](https://t.me/zerobotplugin) - [![zerobot](https://img.shields.io/badge/zerobot-v1.6.10-black?style=flat-square&logo=go)](https://github.com/wdvxdr1123/ZeroBot) + [![zerobot](https://img.shields.io/badge/zerobot-v1.6.11-black?style=flat-square&logo=go)](https://github.com/wdvxdr1123/ZeroBot) [![license](https://img.shields.io/github/license/FloatTech/ZeroBot-Plugin.svg?style=flat-square&logo=gnu)](https://raw.githubusercontent.com/FloatTech/ZeroBot-Plugin/master/LICENSE) [![tencent-qq](https://img.shields.io/badge/group-1048452984-red?style=flat-square&logo=tencent-qq)](https://jq.qq.com/?_wv=1027&k=QMb7x1mM) [![telegram](https://img.shields.io/badge/Telegram-click%20me-informational?style=flat-square&logo=telegram)](https://t.me/zerobotplugin) From bc3c4303be7ff84fa17c34d945290b74d50e8887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=B2=E5=AE=9D=E5=9D=8F=E5=9D=8F=E5=9D=8F?= <2758988938@qq.com> Date: Sat, 18 Mar 2023 00:28:31 +0800 Subject: [PATCH 07/95] fix jiami api (#624) --- 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 f1dba97922a66c3206c7f3b0d4793a6132ef45ab Mon Sep 17 00:00:00 2001 From: DreamZero <79574799+Jiang-Red@users.noreply.github.com> Date: Sat, 18 Mar 2023 00:30:22 +0800 Subject: [PATCH 08/95] feat: steam plugin (#621) --- README.md | 18 +++- main.go | 1 + plugin/bilibili/bilibili.go | 2 +- plugin/steam/listenter.go | 134 ++++++++++++++++++++++++++++++ plugin/steam/steam.go | 158 ++++++++++++++++++++++++++++++++++++ plugin/steam/store.go | 117 ++++++++++++++++++++++++++ 6 files changed, 428 insertions(+), 2 deletions(-) create mode 100644 plugin/steam/listenter.go create mode 100644 plugin/steam/steam.go create mode 100644 plugin/steam/store.go diff --git a/README.md b/README.md index 0d8904085e..b1a594aeca 100644 --- a/README.md +++ b/README.md @@ -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/main.go b/main.go index 58308ab389..b6edd3cd20 100644 --- a/main.go +++ b/main.go @@ -131,6 +131,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" // 搜番 diff --git a/plugin/bilibili/bilibili.go b/plugin/bilibili/bilibili.go index f6de28e712..60250b2d8d 100644 --- a/plugin/bilibili/bilibili.go +++ b/plugin/bilibili/bilibili.go @@ -56,7 +56,7 @@ func init() { "- 查成分 [xxx]\n" + "- 查弹幕 [xxx]\n" + "- 设置b站cookie b_ut=7;buvid3=0;i-wanna-go-back=-1;innersign=0;\n" + - "- 更新vup" + + "- 更新vup\n" + "Tips: (412就是拦截的意思,建议私聊把cookie设全)\n", PublicDataFolder: "Bilibili", }) diff --git a/plugin/steam/listenter.go b/plugin/steam/listenter.go new file mode 100644 index 0000000000..4e76f597c5 --- /dev/null +++ b/plugin/steam/listenter.go @@ -0,0 +1,134 @@ +package steam + +import ( + "fmt" + "strconv" + "strings" + "time" + + "github.com/FloatTech/floatbox/binary" + "github.com/FloatTech/floatbox/web" + ctrl "github.com/FloatTech/zbpctrl" + "github.com/tidwall/gjson" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" +) + +// ----------------------- 远程调用 ---------------------- +const ( + URL = "https://api.steampowered.com/" // steam API 调用地址 + StatusURL = "ISteamUser/GetPlayerSummaries/v2/?key=%+v&steamids=%+v" // 根据用户steamID获取用户状态 + steamapikeygid = 3 +) + +var apiKey string + +func init() { + engine.OnRegex(`^steam绑定\s*api\s*key\s*(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) { + apiKey = ctx.State["regex_matched"].([]string)[1] + m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) + _ = m.Manager.Response(steamapikeygid) + err := m.Manager.SetExtra(steamapikeygid, apiKey) + if err != nil { + ctx.SendChain(message.Text("[steam] ERROR: 保存apikey失败!")) + return + } + ctx.SendChain(message.Text("保存apikey成功!")) + }) + engine.OnFullMatch("查看apikey", zero.OnlyPrivate, zero.SuperUserPermission, getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) { + ctx.SendChain(message.Text("apikey为: ", apiKey)) + }) + engine.OnFullMatch("拉取steam订阅", getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) { + su := zero.BotConfig.SuperUsers[0] + // 获取所有处于监听状态的用户信息 + infos, err := database.findAll() + if err != nil { + // 挂了就给管理员发消息 + ctx.SendPrivateMessage(su, message.Text("[steam] ERROR: ", err)) + return + } + if len(infos) == 0 { + return + } + // 收集这波用户的streamId,然后查当前的状态,并建立信息映射表 + streamIds := make([]string, len(infos)) + localPlayerMap := make(map[int64]*player) + for i, info := range infos { + streamIds[i] = strconv.FormatInt(info.SteamID, 10) + localPlayerMap[info.SteamID] = info + } + // 将所有用户状态查一遍 + playerStatus, err := getPlayerStatus(streamIds...) + if err != nil { + // 出错就发消息 + ctx.SendPrivateMessage(su, message.Text("[steam] ERROR: ", err)) + return + } + // 遍历返回的信息做对比,假如信息有变化则发消息 + now := time.Now() + msg := make(message.Message, 0, len(playerStatus)) + for _, playerInfo := range playerStatus { + msg = msg[:0] + localInfo := localPlayerMap[playerInfo.SteamID] + // 排除不需要处理的情况 + if localInfo.GameID == 0 && playerInfo.GameID == 0 { + continue + } + // 打开游戏 + if localInfo.GameID == 0 && playerInfo.GameID != 0 { + msg = append(msg, message.Text(playerInfo.PersonaName, "正在玩", playerInfo.GameExtraInfo)) + localInfo.LastUpdate = now.Unix() + } + // 更换游戏 + if localInfo.GameID != 0 && playerInfo.GameID != localInfo.GameID && playerInfo.GameID != 0 { + msg = append(msg, message.Text(playerInfo.PersonaName, "玩了", (now.Unix()-localInfo.LastUpdate)/60, "分钟后, 丢下了", localInfo.GameExtraInfo, ", 转头去玩", playerInfo.GameExtraInfo)) + localInfo.LastUpdate = now.Unix() + } + // 关闭游戏 + if playerInfo.GameID != localInfo.GameID && playerInfo.GameID == 0 { + msg = append(msg, message.Text(playerInfo.PersonaName, "玩了", (now.Unix()-localInfo.LastUpdate)/60, "分钟后, 关掉了", localInfo.GameExtraInfo)) + localInfo.LastUpdate = 0 + } + if len(msg) != 0 { + groups := strings.Split(localInfo.Target, ",") + for _, groupString := range groups { + group, err := strconv.ParseInt(groupString, 10, 64) + if err != nil { + ctx.SendPrivateMessage(su, message.Text("[steam] ERROR: ", err, "\nOTHER: SteamID ", localInfo.SteamID)) + continue + } + ctx.SendGroupMessage(group, msg) + } + } + // 更新数据 + localInfo.GameID = playerInfo.GameID + localInfo.GameExtraInfo = playerInfo.GameExtraInfo + if err = database.update(localInfo); err != nil { + ctx.SendPrivateMessage(su, message.Text("[steam] ERROR: ", err, "\nEXP: 更新数据失败\nOTHER: SteamID ", localInfo.SteamID)) + } + } + }) +} + +// getPlayerStatus 获取用户状态 +func getPlayerStatus(streamIds ...string) ([]*player, error) { + players := make([]*player, 0) + // 拼接请求地址 + url := fmt.Sprintf(URL+StatusURL, apiKey, strings.Join(streamIds, ",")) + // 拉取并解析数据 + data, err := web.GetData(url) + if err != nil { + return players, err + } + dataStr := binary.BytesToString(data) + index := gjson.Get(dataStr, "response.players.#").Uint() + for i := uint64(0); i < index; i++ { + players = append(players, &player{ + SteamID: gjson.Get(dataStr, fmt.Sprintf("response.players.%d.steamid", i)).Int(), + PersonaName: gjson.Get(dataStr, fmt.Sprintf("response.players.%d.personaname", i)).String(), + GameID: gjson.Get(dataStr, fmt.Sprintf("response.players.%d.gameid", i)).Int(), + GameExtraInfo: gjson.Get(dataStr, fmt.Sprintf("response.players.%d.gameextrainfo", i)).String(), + }) + } + return players, nil +} diff --git a/plugin/steam/steam.go b/plugin/steam/steam.go new file mode 100644 index 0000000000..ac9f3f116c --- /dev/null +++ b/plugin/steam/steam.go @@ -0,0 +1,158 @@ +// Package steam 获取steam用户状态 +package steam + +import ( + "strconv" + "strings" + "time" + + "github.com/FloatTech/floatbox/binary" + "github.com/FloatTech/floatbox/math" + ctrl "github.com/FloatTech/zbpctrl" + "github.com/FloatTech/zbputils/control" + "github.com/FloatTech/zbputils/ctxext" + "github.com/FloatTech/zbputils/img/text" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" +) + +var ( + engine = control.Register("steam", &ctrl.Options[*zero.Ctx]{ + DisableOnDefault: false, + Brief: "steam相关插件", + Help: "- steam添加订阅 xxxxxxx (可输入需要绑定的 steamid)\n" + + "- steam删除订阅 xxxxxxx (删除你创建的对于 steamid 的绑定)\n" + + "- steam查询订阅 (查询本群内所有的绑定对象)\n" + + "-----------------------\n" + + "- steam绑定 api key xxxxxxx (密钥在steam网站申请, 申请地址: https://steamcommunity.com/dev/registerkey)\n" + + "- 查看apikey (查询已经绑定的密钥)\n" + + "- 拉取steam订阅 (使用插件定时任务开始)\n" + + "-----------------------\n" + + "Tips: steamID在用户资料页的链接上面, 形如7656119820673xxxx\n" + + "需要先私聊绑定apikey, 订阅用户之后使用job插件设置定时, 例: \n" + + "记录在\"@every 1m\"触发的指令\n" + + "拉取steam订阅", + PrivateDataFolder: "steam", + }).ApplySingle(ctxext.DefaultSingle) +) + +func init() { + // 创建绑定流程 + engine.OnRegex(`^steam添加订阅\s*(\d+)$`, zero.OnlyGroup, getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) { + steamidstr := ctx.State["regex_matched"].([]string)[1] + steamID := math.Str2Int64(steamidstr) + // 获取用户状态 + playerStatus, err := getPlayerStatus(steamidstr) + if err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 添加失败, 获取用户信息错误")) + return + } + if len(playerStatus) == 0 { + ctx.SendChain(message.Text("[steam] ERROR: 需要添加的用户不存在, 请检查id或url")) + return + } + playerData := playerStatus[0] + // 判断用户是否已经初始化:若未初始化,通过用户的steamID获取当前状态并初始化;若已经初始化则更新用户信息 + info, err := database.find(steamID) + if err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 添加失败,数据库错误")) + return + } + // 处理数据 + groupID := strconv.FormatInt(ctx.Event.GroupID, 10) + if info.Target == "" { + info = player{ + SteamID: steamID, + PersonaName: playerData.PersonaName, + Target: groupID, + GameID: playerData.GameID, + GameExtraInfo: playerData.GameExtraInfo, + LastUpdate: time.Now().Unix(), + } + } else if !strings.Contains(info.Target, groupID) { + info.Target = strings.Join([]string{info.Target, groupID}, ",") + } + // 更新数据库 + if err = database.update(&info); err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 更新数据库失败")) + return + } + ctx.SendChain(message.Text("添加成功")) + }) + // 删除绑定流程 + engine.OnRegex(`^steam删除订阅\s*(\d+)$`, zero.OnlyGroup, getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) { + steamID := math.Str2Int64(ctx.State["regex_matched"].([]string)[1]) + groupID := strconv.FormatInt(ctx.Event.GroupID, 10) + // 判断是否已经绑定该steamID,若已绑定就将群列表从推送群列表钟去除 + info, err := database.findWithGroupID(steamID, groupID) + if err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 删除失败,数据库错误")) + return + } + if info.SteamID == 0 { + ctx.SendChain(message.Text("[steam] ERROR: 所需要删除的用户不存在。")) + return + } + // 从绑定列表中剔除需要删除的对象 + targets := strings.Split(info.Target, ",") + newTargets := make([]string, 0) + for _, target := range targets { + if target == groupID { + continue + } + newTargets = append(newTargets, target) + } + if len(newTargets) == 0 { + if err = database.del(steamID); err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 删除失败,数据库错误")) + return + } + } else { + info.Target = strings.Join(newTargets, ",") + if err = database.update(&info); err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 删除失败,数据库错误")) + return + } + } + ctx.SendChain(message.Text("删除成功")) + }) + // 查询当前群绑定信息 + engine.OnFullMatch("steam查询订阅", zero.OnlyGroup, getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) { + // 获取群信息 + groupID := strconv.FormatInt(ctx.Event.GroupID, 10) + // 获取所有绑定信息 + infos, err := database.findAll() + if err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 查询订阅失败, 数据库错误")) + return + } + if len(infos) == 0 { + ctx.SendChain(message.Text("[steam] ERROR: 还未订阅过用户关系!")) + return + } + // 遍历所有信息,如果包含该群就收集对应的steamID + var sb strings.Builder + head := " 查询steam订阅成功, 该群订阅的用户有: \n" + sb.WriteString(head) + for _, info := range infos { + if strings.Contains(info.Target, groupID) { + sb.WriteString(" ") + sb.WriteString(info.PersonaName) + sb.WriteString(":") + sb.WriteString(strconv.FormatInt(info.SteamID, 10)) + sb.WriteString("\n") + } + } + if sb.String() == head { + ctx.SendChain(message.Text("查询成功,该群暂时还没有被绑定的用户!")) + return + } + // 组装并返回结果 + data, err := text.RenderToBase64(sb.String(), text.FontFile, 400, 18) + if err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err)) + return + } + ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))) + }) +} diff --git a/plugin/steam/store.go b/plugin/steam/store.go new file mode 100644 index 0000000000..b175fb2164 --- /dev/null +++ b/plugin/steam/store.go @@ -0,0 +1,117 @@ +package steam + +import ( + "strconv" + "sync" + "time" + + fcext "github.com/FloatTech/floatbox/ctxext" + sql "github.com/FloatTech/sqlite" + ctrl "github.com/FloatTech/zbpctrl" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" +) + +var ( + database streamDB + // 开启并检查数据库链接 + getDB = fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool { + database.db.DBPath = engine.DataFolder() + "steam.db" + err := database.db.Open(time.Hour * 24) + if err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err)) + return false + } + if err = database.db.Create(TableListenPlayer, &player{}); err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err)) + return false + } + // 校验密钥是否初始化 + m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) + _ = m.Manager.Response(steamapikeygid) + _ = m.Manager.GetExtra(steamapikeygid, &apiKey) + if apiKey == "" { + ctx.SendChain(message.Text("ERROR: 未设置steam apikey")) + return false + } + return true + }) +) + +// streamDB 继承方法的存储结构 +type streamDB struct { + sync.RWMutex + db sql.Sqlite +} + +const ( + // TableListenPlayer 存储查询用户信息 + TableListenPlayer = "listen_player" +) + +// player 用户状态存储结构体 +type player struct { + SteamID int64 `json:"steam_id"` // 绑定用户标识ID + PersonaName string `json:"persona_name"` // 用户昵称 + Target string `json:"target"` // 信息推送群组 + GameID int64 `json:"game_id"` // 游戏ID + GameExtraInfo string `json:"game_extra_info"` // 游戏信息 + LastUpdate int64 `json:"last_update"` // 更新时间 +} + +// update 如果主键不存在则插入一条新的数据,如果主键存在直接复写 +func (sql *streamDB) update(dbInfo *player) error { + sql.Lock() + defer sql.Unlock() + return sql.db.Insert(TableListenPlayer, dbInfo) +} + +// find 根据主键查信息 +func (sql *streamDB) find(steamID int64) (dbInfo player, err error) { + sql.Lock() + defer sql.Unlock() + condition := "where steam_id = " + strconv.FormatInt(steamID, 10) + if !sql.db.CanFind(TableListenPlayer, condition) { + return player{}, nil // 规避没有该用户数据的报错 + } + err = sql.db.Find(TableListenPlayer, &dbInfo, condition) + return +} + +// findWithGroupID 根据用户steamID和groupID查询信息 +func (sql *streamDB) findWithGroupID(steamID int64, groupID string) (dbInfo player, err error) { + sql.Lock() + defer sql.Unlock() + condition := "where steam_id = " + strconv.FormatInt(steamID, 10) + " AND target LIKE '%" + groupID + "%'" + if !sql.db.CanFind(TableListenPlayer, condition) { + return player{}, nil // 规避没有该用户数据的报错 + } + err = sql.db.Find(TableListenPlayer, &dbInfo, condition) + return +} + +// findAll 查询所有库信息 +func (sql *streamDB) findAll() (dbInfos []*player, err error) { + sql.Lock() + defer sql.Unlock() + var info player + num, err := sql.db.Count(TableListenPlayer) + if err != nil || num == 0 { + return + } + dbInfos = make([]*player, 0, num) + err = sql.db.FindFor(TableListenPlayer, &info, "", func() error { + if info.SteamID != 0 { + dbInfos = append(dbInfos, &info) + } + return nil + }) + return +} + +// del 删除指定数据 +func (sql *streamDB) del(steamID int64) error { + sql.Lock() + defer sql.Unlock() + return sql.db.Del(TableListenPlayer, "where steam_id = "+strconv.FormatInt(steamID, 10)) +} From 107149892c517ca07b9c02ba12e42ef8313c0ed9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 18 Mar 2023 00:32:36 +0800 Subject: [PATCH 09/95] =?UTF-8?q?=F0=9F=8E=A8=20=E6=94=B9=E8=BF=9B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=B7=E5=BC=8F=20(#625)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- plugin/steam/listenter.go | 268 ++++++++++++++++---------------- plugin/steam/steam.go | 316 +++++++++++++++++++------------------- plugin/steam/store.go | 234 ++++++++++++++-------------- 3 files changed, 409 insertions(+), 409 deletions(-) diff --git a/plugin/steam/listenter.go b/plugin/steam/listenter.go index 4e76f597c5..9cf2ca3431 100644 --- a/plugin/steam/listenter.go +++ b/plugin/steam/listenter.go @@ -1,134 +1,134 @@ -package steam - -import ( - "fmt" - "strconv" - "strings" - "time" - - "github.com/FloatTech/floatbox/binary" - "github.com/FloatTech/floatbox/web" - ctrl "github.com/FloatTech/zbpctrl" - "github.com/tidwall/gjson" - zero "github.com/wdvxdr1123/ZeroBot" - "github.com/wdvxdr1123/ZeroBot/message" -) - -// ----------------------- 远程调用 ---------------------- -const ( - URL = "https://api.steampowered.com/" // steam API 调用地址 - StatusURL = "ISteamUser/GetPlayerSummaries/v2/?key=%+v&steamids=%+v" // 根据用户steamID获取用户状态 - steamapikeygid = 3 -) - -var apiKey string - -func init() { - engine.OnRegex(`^steam绑定\s*api\s*key\s*(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) { - apiKey = ctx.State["regex_matched"].([]string)[1] - m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) - _ = m.Manager.Response(steamapikeygid) - err := m.Manager.SetExtra(steamapikeygid, apiKey) - if err != nil { - ctx.SendChain(message.Text("[steam] ERROR: 保存apikey失败!")) - return - } - ctx.SendChain(message.Text("保存apikey成功!")) - }) - engine.OnFullMatch("查看apikey", zero.OnlyPrivate, zero.SuperUserPermission, getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) { - ctx.SendChain(message.Text("apikey为: ", apiKey)) - }) - engine.OnFullMatch("拉取steam订阅", getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) { - su := zero.BotConfig.SuperUsers[0] - // 获取所有处于监听状态的用户信息 - infos, err := database.findAll() - if err != nil { - // 挂了就给管理员发消息 - ctx.SendPrivateMessage(su, message.Text("[steam] ERROR: ", err)) - return - } - if len(infos) == 0 { - return - } - // 收集这波用户的streamId,然后查当前的状态,并建立信息映射表 - streamIds := make([]string, len(infos)) - localPlayerMap := make(map[int64]*player) - for i, info := range infos { - streamIds[i] = strconv.FormatInt(info.SteamID, 10) - localPlayerMap[info.SteamID] = info - } - // 将所有用户状态查一遍 - playerStatus, err := getPlayerStatus(streamIds...) - if err != nil { - // 出错就发消息 - ctx.SendPrivateMessage(su, message.Text("[steam] ERROR: ", err)) - return - } - // 遍历返回的信息做对比,假如信息有变化则发消息 - now := time.Now() - msg := make(message.Message, 0, len(playerStatus)) - for _, playerInfo := range playerStatus { - msg = msg[:0] - localInfo := localPlayerMap[playerInfo.SteamID] - // 排除不需要处理的情况 - if localInfo.GameID == 0 && playerInfo.GameID == 0 { - continue - } - // 打开游戏 - if localInfo.GameID == 0 && playerInfo.GameID != 0 { - msg = append(msg, message.Text(playerInfo.PersonaName, "正在玩", playerInfo.GameExtraInfo)) - localInfo.LastUpdate = now.Unix() - } - // 更换游戏 - if localInfo.GameID != 0 && playerInfo.GameID != localInfo.GameID && playerInfo.GameID != 0 { - msg = append(msg, message.Text(playerInfo.PersonaName, "玩了", (now.Unix()-localInfo.LastUpdate)/60, "分钟后, 丢下了", localInfo.GameExtraInfo, ", 转头去玩", playerInfo.GameExtraInfo)) - localInfo.LastUpdate = now.Unix() - } - // 关闭游戏 - if playerInfo.GameID != localInfo.GameID && playerInfo.GameID == 0 { - msg = append(msg, message.Text(playerInfo.PersonaName, "玩了", (now.Unix()-localInfo.LastUpdate)/60, "分钟后, 关掉了", localInfo.GameExtraInfo)) - localInfo.LastUpdate = 0 - } - if len(msg) != 0 { - groups := strings.Split(localInfo.Target, ",") - for _, groupString := range groups { - group, err := strconv.ParseInt(groupString, 10, 64) - if err != nil { - ctx.SendPrivateMessage(su, message.Text("[steam] ERROR: ", err, "\nOTHER: SteamID ", localInfo.SteamID)) - continue - } - ctx.SendGroupMessage(group, msg) - } - } - // 更新数据 - localInfo.GameID = playerInfo.GameID - localInfo.GameExtraInfo = playerInfo.GameExtraInfo - if err = database.update(localInfo); err != nil { - ctx.SendPrivateMessage(su, message.Text("[steam] ERROR: ", err, "\nEXP: 更新数据失败\nOTHER: SteamID ", localInfo.SteamID)) - } - } - }) -} - -// getPlayerStatus 获取用户状态 -func getPlayerStatus(streamIds ...string) ([]*player, error) { - players := make([]*player, 0) - // 拼接请求地址 - url := fmt.Sprintf(URL+StatusURL, apiKey, strings.Join(streamIds, ",")) - // 拉取并解析数据 - data, err := web.GetData(url) - if err != nil { - return players, err - } - dataStr := binary.BytesToString(data) - index := gjson.Get(dataStr, "response.players.#").Uint() - for i := uint64(0); i < index; i++ { - players = append(players, &player{ - SteamID: gjson.Get(dataStr, fmt.Sprintf("response.players.%d.steamid", i)).Int(), - PersonaName: gjson.Get(dataStr, fmt.Sprintf("response.players.%d.personaname", i)).String(), - GameID: gjson.Get(dataStr, fmt.Sprintf("response.players.%d.gameid", i)).Int(), - GameExtraInfo: gjson.Get(dataStr, fmt.Sprintf("response.players.%d.gameextrainfo", i)).String(), - }) - } - return players, nil -} +package steam + +import ( + "fmt" + "strconv" + "strings" + "time" + + "github.com/FloatTech/floatbox/binary" + "github.com/FloatTech/floatbox/web" + ctrl "github.com/FloatTech/zbpctrl" + "github.com/tidwall/gjson" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" +) + +// ----------------------- 远程调用 ---------------------- +const ( + URL = "https://api.steampowered.com/" // steam API 调用地址 + StatusURL = "ISteamUser/GetPlayerSummaries/v2/?key=%+v&steamids=%+v" // 根据用户steamID获取用户状态 + steamapikeygid = 3 +) + +var apiKey string + +func init() { + engine.OnRegex(`^steam绑定\s*api\s*key\s*(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) { + apiKey = ctx.State["regex_matched"].([]string)[1] + m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) + _ = m.Manager.Response(steamapikeygid) + err := m.Manager.SetExtra(steamapikeygid, apiKey) + if err != nil { + ctx.SendChain(message.Text("[steam] ERROR: 保存apikey失败!")) + return + } + ctx.SendChain(message.Text("保存apikey成功!")) + }) + engine.OnFullMatch("查看apikey", zero.OnlyPrivate, zero.SuperUserPermission, getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) { + ctx.SendChain(message.Text("apikey为: ", apiKey)) + }) + engine.OnFullMatch("拉取steam订阅", getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) { + su := zero.BotConfig.SuperUsers[0] + // 获取所有处于监听状态的用户信息 + infos, err := database.findAll() + if err != nil { + // 挂了就给管理员发消息 + ctx.SendPrivateMessage(su, message.Text("[steam] ERROR: ", err)) + return + } + if len(infos) == 0 { + return + } + // 收集这波用户的streamId,然后查当前的状态,并建立信息映射表 + streamIds := make([]string, len(infos)) + localPlayerMap := make(map[int64]*player) + for i, info := range infos { + streamIds[i] = strconv.FormatInt(info.SteamID, 10) + localPlayerMap[info.SteamID] = info + } + // 将所有用户状态查一遍 + playerStatus, err := getPlayerStatus(streamIds...) + if err != nil { + // 出错就发消息 + ctx.SendPrivateMessage(su, message.Text("[steam] ERROR: ", err)) + return + } + // 遍历返回的信息做对比,假如信息有变化则发消息 + now := time.Now() + msg := make(message.Message, 0, len(playerStatus)) + for _, playerInfo := range playerStatus { + msg = msg[:0] + localInfo := localPlayerMap[playerInfo.SteamID] + // 排除不需要处理的情况 + if localInfo.GameID == 0 && playerInfo.GameID == 0 { + continue + } + // 打开游戏 + if localInfo.GameID == 0 && playerInfo.GameID != 0 { + msg = append(msg, message.Text(playerInfo.PersonaName, "正在玩", playerInfo.GameExtraInfo)) + localInfo.LastUpdate = now.Unix() + } + // 更换游戏 + if localInfo.GameID != 0 && playerInfo.GameID != localInfo.GameID && playerInfo.GameID != 0 { + msg = append(msg, message.Text(playerInfo.PersonaName, "玩了", (now.Unix()-localInfo.LastUpdate)/60, "分钟后, 丢下了", localInfo.GameExtraInfo, ", 转头去玩", playerInfo.GameExtraInfo)) + localInfo.LastUpdate = now.Unix() + } + // 关闭游戏 + if playerInfo.GameID != localInfo.GameID && playerInfo.GameID == 0 { + msg = append(msg, message.Text(playerInfo.PersonaName, "玩了", (now.Unix()-localInfo.LastUpdate)/60, "分钟后, 关掉了", localInfo.GameExtraInfo)) + localInfo.LastUpdate = 0 + } + if len(msg) != 0 { + groups := strings.Split(localInfo.Target, ",") + for _, groupString := range groups { + group, err := strconv.ParseInt(groupString, 10, 64) + if err != nil { + ctx.SendPrivateMessage(su, message.Text("[steam] ERROR: ", err, "\nOTHER: SteamID ", localInfo.SteamID)) + continue + } + ctx.SendGroupMessage(group, msg) + } + } + // 更新数据 + localInfo.GameID = playerInfo.GameID + localInfo.GameExtraInfo = playerInfo.GameExtraInfo + if err = database.update(localInfo); err != nil { + ctx.SendPrivateMessage(su, message.Text("[steam] ERROR: ", err, "\nEXP: 更新数据失败\nOTHER: SteamID ", localInfo.SteamID)) + } + } + }) +} + +// getPlayerStatus 获取用户状态 +func getPlayerStatus(streamIds ...string) ([]*player, error) { + players := make([]*player, 0) + // 拼接请求地址 + url := fmt.Sprintf(URL+StatusURL, apiKey, strings.Join(streamIds, ",")) + // 拉取并解析数据 + data, err := web.GetData(url) + if err != nil { + return players, err + } + dataStr := binary.BytesToString(data) + index := gjson.Get(dataStr, "response.players.#").Uint() + for i := uint64(0); i < index; i++ { + players = append(players, &player{ + SteamID: gjson.Get(dataStr, fmt.Sprintf("response.players.%d.steamid", i)).Int(), + PersonaName: gjson.Get(dataStr, fmt.Sprintf("response.players.%d.personaname", i)).String(), + GameID: gjson.Get(dataStr, fmt.Sprintf("response.players.%d.gameid", i)).Int(), + GameExtraInfo: gjson.Get(dataStr, fmt.Sprintf("response.players.%d.gameextrainfo", i)).String(), + }) + } + return players, nil +} diff --git a/plugin/steam/steam.go b/plugin/steam/steam.go index ac9f3f116c..925dc90a99 100644 --- a/plugin/steam/steam.go +++ b/plugin/steam/steam.go @@ -1,158 +1,158 @@ -// Package steam 获取steam用户状态 -package steam - -import ( - "strconv" - "strings" - "time" - - "github.com/FloatTech/floatbox/binary" - "github.com/FloatTech/floatbox/math" - ctrl "github.com/FloatTech/zbpctrl" - "github.com/FloatTech/zbputils/control" - "github.com/FloatTech/zbputils/ctxext" - "github.com/FloatTech/zbputils/img/text" - zero "github.com/wdvxdr1123/ZeroBot" - "github.com/wdvxdr1123/ZeroBot/message" -) - -var ( - engine = control.Register("steam", &ctrl.Options[*zero.Ctx]{ - DisableOnDefault: false, - Brief: "steam相关插件", - Help: "- steam添加订阅 xxxxxxx (可输入需要绑定的 steamid)\n" + - "- steam删除订阅 xxxxxxx (删除你创建的对于 steamid 的绑定)\n" + - "- steam查询订阅 (查询本群内所有的绑定对象)\n" + - "-----------------------\n" + - "- steam绑定 api key xxxxxxx (密钥在steam网站申请, 申请地址: https://steamcommunity.com/dev/registerkey)\n" + - "- 查看apikey (查询已经绑定的密钥)\n" + - "- 拉取steam订阅 (使用插件定时任务开始)\n" + - "-----------------------\n" + - "Tips: steamID在用户资料页的链接上面, 形如7656119820673xxxx\n" + - "需要先私聊绑定apikey, 订阅用户之后使用job插件设置定时, 例: \n" + - "记录在\"@every 1m\"触发的指令\n" + - "拉取steam订阅", - PrivateDataFolder: "steam", - }).ApplySingle(ctxext.DefaultSingle) -) - -func init() { - // 创建绑定流程 - engine.OnRegex(`^steam添加订阅\s*(\d+)$`, zero.OnlyGroup, getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) { - steamidstr := ctx.State["regex_matched"].([]string)[1] - steamID := math.Str2Int64(steamidstr) - // 获取用户状态 - playerStatus, err := getPlayerStatus(steamidstr) - if err != nil { - ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 添加失败, 获取用户信息错误")) - return - } - if len(playerStatus) == 0 { - ctx.SendChain(message.Text("[steam] ERROR: 需要添加的用户不存在, 请检查id或url")) - return - } - playerData := playerStatus[0] - // 判断用户是否已经初始化:若未初始化,通过用户的steamID获取当前状态并初始化;若已经初始化则更新用户信息 - info, err := database.find(steamID) - if err != nil { - ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 添加失败,数据库错误")) - return - } - // 处理数据 - groupID := strconv.FormatInt(ctx.Event.GroupID, 10) - if info.Target == "" { - info = player{ - SteamID: steamID, - PersonaName: playerData.PersonaName, - Target: groupID, - GameID: playerData.GameID, - GameExtraInfo: playerData.GameExtraInfo, - LastUpdate: time.Now().Unix(), - } - } else if !strings.Contains(info.Target, groupID) { - info.Target = strings.Join([]string{info.Target, groupID}, ",") - } - // 更新数据库 - if err = database.update(&info); err != nil { - ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 更新数据库失败")) - return - } - ctx.SendChain(message.Text("添加成功")) - }) - // 删除绑定流程 - engine.OnRegex(`^steam删除订阅\s*(\d+)$`, zero.OnlyGroup, getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) { - steamID := math.Str2Int64(ctx.State["regex_matched"].([]string)[1]) - groupID := strconv.FormatInt(ctx.Event.GroupID, 10) - // 判断是否已经绑定该steamID,若已绑定就将群列表从推送群列表钟去除 - info, err := database.findWithGroupID(steamID, groupID) - if err != nil { - ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 删除失败,数据库错误")) - return - } - if info.SteamID == 0 { - ctx.SendChain(message.Text("[steam] ERROR: 所需要删除的用户不存在。")) - return - } - // 从绑定列表中剔除需要删除的对象 - targets := strings.Split(info.Target, ",") - newTargets := make([]string, 0) - for _, target := range targets { - if target == groupID { - continue - } - newTargets = append(newTargets, target) - } - if len(newTargets) == 0 { - if err = database.del(steamID); err != nil { - ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 删除失败,数据库错误")) - return - } - } else { - info.Target = strings.Join(newTargets, ",") - if err = database.update(&info); err != nil { - ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 删除失败,数据库错误")) - return - } - } - ctx.SendChain(message.Text("删除成功")) - }) - // 查询当前群绑定信息 - engine.OnFullMatch("steam查询订阅", zero.OnlyGroup, getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) { - // 获取群信息 - groupID := strconv.FormatInt(ctx.Event.GroupID, 10) - // 获取所有绑定信息 - infos, err := database.findAll() - if err != nil { - ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 查询订阅失败, 数据库错误")) - return - } - if len(infos) == 0 { - ctx.SendChain(message.Text("[steam] ERROR: 还未订阅过用户关系!")) - return - } - // 遍历所有信息,如果包含该群就收集对应的steamID - var sb strings.Builder - head := " 查询steam订阅成功, 该群订阅的用户有: \n" - sb.WriteString(head) - for _, info := range infos { - if strings.Contains(info.Target, groupID) { - sb.WriteString(" ") - sb.WriteString(info.PersonaName) - sb.WriteString(":") - sb.WriteString(strconv.FormatInt(info.SteamID, 10)) - sb.WriteString("\n") - } - } - if sb.String() == head { - ctx.SendChain(message.Text("查询成功,该群暂时还没有被绑定的用户!")) - return - } - // 组装并返回结果 - data, err := text.RenderToBase64(sb.String(), text.FontFile, 400, 18) - if err != nil { - ctx.SendChain(message.Text("[steam] ERROR: ", err)) - return - } - ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))) - }) -} +// Package steam 获取steam用户状态 +package steam + +import ( + "strconv" + "strings" + "time" + + "github.com/FloatTech/floatbox/binary" + "github.com/FloatTech/floatbox/math" + ctrl "github.com/FloatTech/zbpctrl" + "github.com/FloatTech/zbputils/control" + "github.com/FloatTech/zbputils/ctxext" + "github.com/FloatTech/zbputils/img/text" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" +) + +var ( + engine = control.Register("steam", &ctrl.Options[*zero.Ctx]{ + DisableOnDefault: false, + Brief: "steam相关插件", + Help: "- steam添加订阅 xxxxxxx (可输入需要绑定的 steamid)\n" + + "- steam删除订阅 xxxxxxx (删除你创建的对于 steamid 的绑定)\n" + + "- steam查询订阅 (查询本群内所有的绑定对象)\n" + + "-----------------------\n" + + "- steam绑定 api key xxxxxxx (密钥在steam网站申请, 申请地址: https://steamcommunity.com/dev/registerkey)\n" + + "- 查看apikey (查询已经绑定的密钥)\n" + + "- 拉取steam订阅 (使用插件定时任务开始)\n" + + "-----------------------\n" + + "Tips: steamID在用户资料页的链接上面, 形如7656119820673xxxx\n" + + "需要先私聊绑定apikey, 订阅用户之后使用job插件设置定时, 例: \n" + + "记录在\"@every 1m\"触发的指令\n" + + "拉取steam订阅", + PrivateDataFolder: "steam", + }).ApplySingle(ctxext.DefaultSingle) +) + +func init() { + // 创建绑定流程 + engine.OnRegex(`^steam添加订阅\s*(\d+)$`, zero.OnlyGroup, getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) { + steamidstr := ctx.State["regex_matched"].([]string)[1] + steamID := math.Str2Int64(steamidstr) + // 获取用户状态 + playerStatus, err := getPlayerStatus(steamidstr) + if err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 添加失败, 获取用户信息错误")) + return + } + if len(playerStatus) == 0 { + ctx.SendChain(message.Text("[steam] ERROR: 需要添加的用户不存在, 请检查id或url")) + return + } + playerData := playerStatus[0] + // 判断用户是否已经初始化:若未初始化,通过用户的steamID获取当前状态并初始化;若已经初始化则更新用户信息 + info, err := database.find(steamID) + if err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 添加失败,数据库错误")) + return + } + // 处理数据 + groupID := strconv.FormatInt(ctx.Event.GroupID, 10) + if info.Target == "" { + info = player{ + SteamID: steamID, + PersonaName: playerData.PersonaName, + Target: groupID, + GameID: playerData.GameID, + GameExtraInfo: playerData.GameExtraInfo, + LastUpdate: time.Now().Unix(), + } + } else if !strings.Contains(info.Target, groupID) { + info.Target = strings.Join([]string{info.Target, groupID}, ",") + } + // 更新数据库 + if err = database.update(&info); err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 更新数据库失败")) + return + } + ctx.SendChain(message.Text("添加成功")) + }) + // 删除绑定流程 + engine.OnRegex(`^steam删除订阅\s*(\d+)$`, zero.OnlyGroup, getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) { + steamID := math.Str2Int64(ctx.State["regex_matched"].([]string)[1]) + groupID := strconv.FormatInt(ctx.Event.GroupID, 10) + // 判断是否已经绑定该steamID,若已绑定就将群列表从推送群列表钟去除 + info, err := database.findWithGroupID(steamID, groupID) + if err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 删除失败,数据库错误")) + return + } + if info.SteamID == 0 { + ctx.SendChain(message.Text("[steam] ERROR: 所需要删除的用户不存在。")) + return + } + // 从绑定列表中剔除需要删除的对象 + targets := strings.Split(info.Target, ",") + newTargets := make([]string, 0) + for _, target := range targets { + if target == groupID { + continue + } + newTargets = append(newTargets, target) + } + if len(newTargets) == 0 { + if err = database.del(steamID); err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 删除失败,数据库错误")) + return + } + } else { + info.Target = strings.Join(newTargets, ",") + if err = database.update(&info); err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 删除失败,数据库错误")) + return + } + } + ctx.SendChain(message.Text("删除成功")) + }) + // 查询当前群绑定信息 + engine.OnFullMatch("steam查询订阅", zero.OnlyGroup, getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) { + // 获取群信息 + groupID := strconv.FormatInt(ctx.Event.GroupID, 10) + // 获取所有绑定信息 + infos, err := database.findAll() + if err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err, "\nEXP: 查询订阅失败, 数据库错误")) + return + } + if len(infos) == 0 { + ctx.SendChain(message.Text("[steam] ERROR: 还未订阅过用户关系!")) + return + } + // 遍历所有信息,如果包含该群就收集对应的steamID + var sb strings.Builder + head := " 查询steam订阅成功, 该群订阅的用户有: \n" + sb.WriteString(head) + for _, info := range infos { + if strings.Contains(info.Target, groupID) { + sb.WriteString(" ") + sb.WriteString(info.PersonaName) + sb.WriteString(":") + sb.WriteString(strconv.FormatInt(info.SteamID, 10)) + sb.WriteString("\n") + } + } + if sb.String() == head { + ctx.SendChain(message.Text("查询成功,该群暂时还没有被绑定的用户!")) + return + } + // 组装并返回结果 + data, err := text.RenderToBase64(sb.String(), text.FontFile, 400, 18) + if err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err)) + return + } + ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))) + }) +} diff --git a/plugin/steam/store.go b/plugin/steam/store.go index b175fb2164..16c934447e 100644 --- a/plugin/steam/store.go +++ b/plugin/steam/store.go @@ -1,117 +1,117 @@ -package steam - -import ( - "strconv" - "sync" - "time" - - fcext "github.com/FloatTech/floatbox/ctxext" - sql "github.com/FloatTech/sqlite" - ctrl "github.com/FloatTech/zbpctrl" - zero "github.com/wdvxdr1123/ZeroBot" - "github.com/wdvxdr1123/ZeroBot/message" -) - -var ( - database streamDB - // 开启并检查数据库链接 - getDB = fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool { - database.db.DBPath = engine.DataFolder() + "steam.db" - err := database.db.Open(time.Hour * 24) - if err != nil { - ctx.SendChain(message.Text("[steam] ERROR: ", err)) - return false - } - if err = database.db.Create(TableListenPlayer, &player{}); err != nil { - ctx.SendChain(message.Text("[steam] ERROR: ", err)) - return false - } - // 校验密钥是否初始化 - m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) - _ = m.Manager.Response(steamapikeygid) - _ = m.Manager.GetExtra(steamapikeygid, &apiKey) - if apiKey == "" { - ctx.SendChain(message.Text("ERROR: 未设置steam apikey")) - return false - } - return true - }) -) - -// streamDB 继承方法的存储结构 -type streamDB struct { - sync.RWMutex - db sql.Sqlite -} - -const ( - // TableListenPlayer 存储查询用户信息 - TableListenPlayer = "listen_player" -) - -// player 用户状态存储结构体 -type player struct { - SteamID int64 `json:"steam_id"` // 绑定用户标识ID - PersonaName string `json:"persona_name"` // 用户昵称 - Target string `json:"target"` // 信息推送群组 - GameID int64 `json:"game_id"` // 游戏ID - GameExtraInfo string `json:"game_extra_info"` // 游戏信息 - LastUpdate int64 `json:"last_update"` // 更新时间 -} - -// update 如果主键不存在则插入一条新的数据,如果主键存在直接复写 -func (sql *streamDB) update(dbInfo *player) error { - sql.Lock() - defer sql.Unlock() - return sql.db.Insert(TableListenPlayer, dbInfo) -} - -// find 根据主键查信息 -func (sql *streamDB) find(steamID int64) (dbInfo player, err error) { - sql.Lock() - defer sql.Unlock() - condition := "where steam_id = " + strconv.FormatInt(steamID, 10) - if !sql.db.CanFind(TableListenPlayer, condition) { - return player{}, nil // 规避没有该用户数据的报错 - } - err = sql.db.Find(TableListenPlayer, &dbInfo, condition) - return -} - -// findWithGroupID 根据用户steamID和groupID查询信息 -func (sql *streamDB) findWithGroupID(steamID int64, groupID string) (dbInfo player, err error) { - sql.Lock() - defer sql.Unlock() - condition := "where steam_id = " + strconv.FormatInt(steamID, 10) + " AND target LIKE '%" + groupID + "%'" - if !sql.db.CanFind(TableListenPlayer, condition) { - return player{}, nil // 规避没有该用户数据的报错 - } - err = sql.db.Find(TableListenPlayer, &dbInfo, condition) - return -} - -// findAll 查询所有库信息 -func (sql *streamDB) findAll() (dbInfos []*player, err error) { - sql.Lock() - defer sql.Unlock() - var info player - num, err := sql.db.Count(TableListenPlayer) - if err != nil || num == 0 { - return - } - dbInfos = make([]*player, 0, num) - err = sql.db.FindFor(TableListenPlayer, &info, "", func() error { - if info.SteamID != 0 { - dbInfos = append(dbInfos, &info) - } - return nil - }) - return -} - -// del 删除指定数据 -func (sql *streamDB) del(steamID int64) error { - sql.Lock() - defer sql.Unlock() - return sql.db.Del(TableListenPlayer, "where steam_id = "+strconv.FormatInt(steamID, 10)) -} +package steam + +import ( + "strconv" + "sync" + "time" + + fcext "github.com/FloatTech/floatbox/ctxext" + sql "github.com/FloatTech/sqlite" + ctrl "github.com/FloatTech/zbpctrl" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" +) + +var ( + database streamDB + // 开启并检查数据库链接 + getDB = fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool { + database.db.DBPath = engine.DataFolder() + "steam.db" + err := database.db.Open(time.Hour * 24) + if err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err)) + return false + } + if err = database.db.Create(TableListenPlayer, &player{}); err != nil { + ctx.SendChain(message.Text("[steam] ERROR: ", err)) + return false + } + // 校验密钥是否初始化 + m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) + _ = m.Manager.Response(steamapikeygid) + _ = m.Manager.GetExtra(steamapikeygid, &apiKey) + if apiKey == "" { + ctx.SendChain(message.Text("ERROR: 未设置steam apikey")) + return false + } + return true + }) +) + +// streamDB 继承方法的存储结构 +type streamDB struct { + sync.RWMutex + db sql.Sqlite +} + +const ( + // TableListenPlayer 存储查询用户信息 + TableListenPlayer = "listen_player" +) + +// player 用户状态存储结构体 +type player struct { + SteamID int64 `json:"steam_id"` // 绑定用户标识ID + PersonaName string `json:"persona_name"` // 用户昵称 + Target string `json:"target"` // 信息推送群组 + GameID int64 `json:"game_id"` // 游戏ID + GameExtraInfo string `json:"game_extra_info"` // 游戏信息 + LastUpdate int64 `json:"last_update"` // 更新时间 +} + +// update 如果主键不存在则插入一条新的数据,如果主键存在直接复写 +func (sql *streamDB) update(dbInfo *player) error { + sql.Lock() + defer sql.Unlock() + return sql.db.Insert(TableListenPlayer, dbInfo) +} + +// find 根据主键查信息 +func (sql *streamDB) find(steamID int64) (dbInfo player, err error) { + sql.Lock() + defer sql.Unlock() + condition := "where steam_id = " + strconv.FormatInt(steamID, 10) + if !sql.db.CanFind(TableListenPlayer, condition) { + return player{}, nil // 规避没有该用户数据的报错 + } + err = sql.db.Find(TableListenPlayer, &dbInfo, condition) + return +} + +// findWithGroupID 根据用户steamID和groupID查询信息 +func (sql *streamDB) findWithGroupID(steamID int64, groupID string) (dbInfo player, err error) { + sql.Lock() + defer sql.Unlock() + condition := "where steam_id = " + strconv.FormatInt(steamID, 10) + " AND target LIKE '%" + groupID + "%'" + if !sql.db.CanFind(TableListenPlayer, condition) { + return player{}, nil // 规避没有该用户数据的报错 + } + err = sql.db.Find(TableListenPlayer, &dbInfo, condition) + return +} + +// findAll 查询所有库信息 +func (sql *streamDB) findAll() (dbInfos []*player, err error) { + sql.Lock() + defer sql.Unlock() + var info player + num, err := sql.db.Count(TableListenPlayer) + if err != nil || num == 0 { + return + } + dbInfos = make([]*player, 0, num) + err = sql.db.FindFor(TableListenPlayer, &info, "", func() error { + if info.SteamID != 0 { + dbInfos = append(dbInfos, &info) + } + return nil + }) + return +} + +// del 删除指定数据 +func (sql *streamDB) del(steamID int64) error { + sql.Lock() + defer sql.Unlock() + return sql.db.Del(TableListenPlayer, "where steam_id = "+strconv.FormatInt(steamID, 10)) +} From 6474b36ccdb049bc877bb18e71d7384f8e622c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E6=9F=B3=E7=85=9C?= <101934327+fangliuyu@users.noreply.github.com> Date: Sat, 18 Mar 2023 12:07:13 +0800 Subject: [PATCH 10/95] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BA=95=E9=83=A8?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E9=BB=91=E6=9D=A1=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#626)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/drawlots/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 // */ } From e9eb4c5602079699b850736d3029c7b16145c858 Mon Sep 17 00:00:00 2001 From: DreamZero <79574799+Jiang-Red@users.noreply.github.com> Date: Mon, 20 Mar 2023 11:57:46 +0800 Subject: [PATCH 11/95] Fix steam & lint (#630) * fix * make lint happy --- main.go | 13 +++++----- plugin/atri/atri.go | 2 +- plugin/saucenao/searcher.go | 38 ++++++++++++++--------------- plugin/setutime/setu_geter.go | 5 +--- plugin/sleep_manage/sleep_manage.go | 4 +-- plugin/steam/listenter.go | 6 ++--- plugin/steam/store.go | 6 ++--- 7 files changed, 35 insertions(+), 39 deletions(-) diff --git a/main.go b/main.go index b6edd3cd20..3126843741 100644 --- a/main.go +++ b/main.go @@ -234,13 +234,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 e2385f71ed..0b5331130f 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 false } diff --git a/plugin/saucenao/searcher.go b/plugin/saucenao/searcher.go index 10107efd75..e51b692d2b 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 b01370e0ff..b03c3328f9 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 0b346e2f5d..d7d5b2becc 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 9cf2ca3431..976826558e 100644 --- a/plugin/steam/listenter.go +++ b/plugin/steam/listenter.go @@ -53,9 +53,9 @@ func init() { // 收集这波用户的streamId,然后查当前的状态,并建立信息映射表 streamIds := make([]string, len(infos)) localPlayerMap := make(map[int64]*player) - for i, info := range infos { - streamIds[i] = strconv.FormatInt(info.SteamID, 10) - localPlayerMap[info.SteamID] = info + for i := 0; i < len(infos); i++ { + streamIds[i] = strconv.FormatInt(infos[i].SteamID, 10) + localPlayerMap[infos[i].SteamID] = &infos[i] } // 将所有用户状态查一遍 playerStatus, err := getPlayerStatus(streamIds...) diff --git a/plugin/steam/store.go b/plugin/steam/store.go index 16c934447e..171a60f7d6 100644 --- a/plugin/steam/store.go +++ b/plugin/steam/store.go @@ -91,7 +91,7 @@ func (sql *streamDB) findWithGroupID(steamID int64, groupID string) (dbInfo play } // findAll 查询所有库信息 -func (sql *streamDB) findAll() (dbInfos []*player, err error) { +func (sql *streamDB) findAll() (dbInfos []player, err error) { sql.Lock() defer sql.Unlock() var info player @@ -99,10 +99,10 @@ func (sql *streamDB) findAll() (dbInfos []*player, err error) { if err != nil || num == 0 { return } - dbInfos = make([]*player, 0, num) + dbInfos = make([]player, 0, num) err = sql.db.FindFor(TableListenPlayer, &info, "", func() error { if info.SteamID != 0 { - dbInfos = append(dbInfos, &info) + dbInfos = append(dbInfos, info) } return nil }) From 86b87c2b4e4863f2e68e8c6f69feed8006fb7cd1 Mon Sep 17 00:00:00 2001 From: DreamZero <79574799+Jiang-Red@users.noreply.github.com> Date: Mon, 20 Mar 2023 11:59:03 +0800 Subject: [PATCH 12/95] fix slow aifalse (#631) --- plugin/ai_false/ai_false.go | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/plugin/ai_false/ai_false.go b/plugin/ai_false/ai_false.go index c3f48aa1e6..230ebfae35 100644 --- a/plugin/ai_false/ai_false.go +++ b/plugin/ai_false/ai_false.go @@ -187,7 +187,13 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg back = imgfactory.Size(back, int(bw*cw/bw), int(bh*cw/bw)).Image() canvas.DrawImage(back, 0, 0) } - + var blurback image.Image + bwg := &sync.WaitGroup{} + bwg.Add(1) + go func() { + defer bwg.Done() + blurback = imaging.Blur(canvas.Image(), 8) + }() wg := &sync.WaitGroup{} wg.Add(5) @@ -200,8 +206,8 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg go func() { defer wg.Done() titlecard := gg.NewContext(cardw, titlecardh) - - titlecard.DrawImage(imaging.Blur(canvas.Image(), 8), -70, -70) + bwg.Wait() + titlecard.DrawImage(blurback, -70, -70) titlecard.DrawRoundedRectangle(1, 1, float64(titlecard.W()-1*2), float64(titlecardh-1*2), 16) titlecard.SetLineWidth(3) @@ -253,8 +259,8 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg go func() { defer wg.Done() basiccard := gg.NewContext(cardw, basiccardh) - - basiccard.DrawImage(imaging.Blur(canvas.Image(), 8), -70, -70-titlecardh-40) + bwg.Wait() + basiccard.DrawImage(blurback, -70, -70-titlecardh-40) basiccard.DrawRoundedRectangle(1, 1, float64(basiccard.W()-1*2), float64(basiccardh-1*2), 16) basiccard.SetLineWidth(3) @@ -317,7 +323,8 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg go func() { defer wg.Done() diskcard := gg.NewContext(cardw, diskcardh) - diskcard.DrawImage(imaging.Blur(canvas.Image(), 8), -70, -70-titlecardh-40-basiccardh-40) + bwg.Wait() + diskcard.DrawImage(blurback, -70, -70-titlecardh-40-basiccardh-40) diskcard.DrawRoundedRectangle(1, 1, float64(diskcard.W()-1*2), float64(diskcardh-1*2), 16) diskcard.SetLineWidth(3) @@ -335,6 +342,7 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg if dslen == 1 { diskcard.SetRGBA255(192, 192, 192, 255) diskcard.DrawRoundedRectangle(40, 40, float64(diskcard.W())-40-100, 50, 12) + diskcard.ClipPreserve() diskcard.Fill() switch { @@ -348,7 +356,7 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg diskcard.DrawRoundedRectangle(40, 40, (float64(diskcard.W())-40-100)*diskstate[0].precent*0.01, 50, 12) diskcard.Fill() - + diskcard.ResetClip() diskcard.SetRGBA255(30, 30, 30, 255) fw, _ := diskcard.MeasureString(diskstate[0].name) @@ -392,8 +400,8 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg go func() { defer wg.Done() moreinfocard := gg.NewContext(cardw, moreinfocardh) - - moreinfocard.DrawImage(imaging.Blur(canvas.Image(), 8), -70, -70-titlecardh-40-basiccardh-40-diskcardh-40) + bwg.Wait() + moreinfocard.DrawImage(blurback, -70, -70-titlecardh-40-basiccardh-40-diskcardh-40) moreinfocard.DrawRoundedRectangle(1, 1, float64(moreinfocard.W()-1*2), float64(moreinfocard.H()-1*2), 16) moreinfocard.SetLineWidth(3) @@ -430,7 +438,7 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg shadow.Stroke() shadow.DrawRoundedRectangle(70, float64(70+titlecardh+40), float64(cardw), float64(basiccardh), 16) shadow.Stroke() - shadow.DrawRoundedRectangle(70, float64(70+titlecardh+40+basiccardh+40), float64(cardw), float64(basiccardh), 16) + shadow.DrawRoundedRectangle(70, float64(70+titlecardh+40+basiccardh+40), float64(cardw), float64(diskcardh), 16) shadow.Stroke() shadow.DrawRoundedRectangle(70, float64(70+titlecardh+40+basiccardh+40+diskcardh+40), float64(cardw), float64(moreinfocardh), 16) shadow.Stroke() From 1734f1f7d43a52ca4f0155b631859c2fcdb29712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=B2=E5=AE=9D=E5=9D=8F=E5=9D=8F=E5=9D=8F?= <2758988938@qq.com> Date: Mon, 20 Mar 2023 12:23:52 +0800 Subject: [PATCH 13/95] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E7=99=BE=E5=BA=A6?= =?UTF-8?q?=E4=B8=80=E4=B8=8B=E4=B8=BA=E7=99=BE=E5=BA=A6=E7=99=BE=E7=A7=91?= =?UTF-8?q?=20(#627)?= 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, 42 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index b1a594aeca..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]
diff --git a/plugin/baidu/search.go b/plugin/baidu/search.go index 642804d458..853ab76725 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访问错误")) + } + }) } From 68386910c4a12f33008b19e4a4a19324453ed0bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 20 Mar 2023 12:28:19 +0800 Subject: [PATCH 14/95] =?UTF-8?q?=F0=9F=94=96=20v1.7.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kanban/banner/banner.go | 4 ++-- winres/winres.json | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) 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/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": "" } } From 1376803b076357cdb385326f0a082d6ea660681c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=AB=E6=80=9D=E6=BD=8B?= <55676105+shudorcl@users.noreply.github.com> Date: Wed, 22 Mar 2023 20:17:15 +0800 Subject: [PATCH 15/95] fix: always (#633) * update deps * update always * fix: always: broken images and fonts --- go.mod | 2 +- go.sum | 2 ++ plugin/gif/gif.go | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5d506aea45..46a0a90d71 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 201fa93ee7..0d1dd29eee 100644 --- a/go.sum +++ b/go.sum @@ -10,6 +10,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/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) From 500dcaa9ed389acff57e1851f0fff234ef7ba091 Mon Sep 17 00:00:00 2001 From: anyanfei <87066062@qq.com> Date: Fri, 24 Mar 2023 14:03:18 +0800 Subject: [PATCH 16/95] =?UTF-8?q?fix:=20baidu=20=E6=AD=A3=E5=88=99?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=20(#636)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 853ab76725..887bdeac1f 100644 --- a/plugin/baidu/search.go +++ b/plugin/baidu/search.go @@ -30,7 +30,7 @@ func init() { // 主函数 Help: "百度百科\n" + "- 百度/百科[关键字]", }) - en.OnRegex(`^[百度|百科]\s*(.+)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) { + 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)) From d693f988bb0ba42fe16b4e641e99efa4c0d7b639 Mon Sep 17 00:00:00 2001 From: Sora39 <36908878+Sora39831@users.noreply.github.com> Date: Fri, 24 Mar 2023 17:25:04 +0800 Subject: [PATCH 17/95] =?UTF-8?q?fix:=20steam=20=E3=83=98=E3=83=AB?= =?UTF-8?q?=E3=83=97=E3=81=AB=E3=81=82=E3=82=8B=20api=20=E3=81=AE=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E5=9C=B0=E5=9D=80=20(#637)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/steam/steam.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" + From 587d3967ef71d5cd8dafa0671958339cb5d02f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=B2=E5=AE=9D=E5=9D=8F=E5=9D=8F=E5=9D=8F?= <2758988938@qq.com> Date: Sat, 25 Mar 2023 11:06:00 +0800 Subject: [PATCH 18/95] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=AD=BE=E5=88=B0?= =?UTF-8?q?=E9=A2=84=E8=AE=BE=E5=88=87=E6=8D=A2=20(#634)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/score/draw.go | 176 +++++++++++++++++++++++ plugin/score/model.go | 11 ++ plugin/score/sign_in.go | 299 +++++++++++++++++----------------------- 3 files changed, 317 insertions(+), 169 deletions(-) create mode 100644 plugin/score/draw.go diff --git a/plugin/score/draw.go b/plugin/score/draw.go new file mode 100644 index 0000000000..33ae9f3da5 --- /dev/null +++ b/plugin/score/draw.go @@ -0,0 +1,176 @@ +// Package score 签到,答题得分 +package score + +import ( + "bytes" + "fmt" + "image" + "image/color" + "strconv" + "time" + + "github.com/FloatTech/ZeroBot-Plugin/kanban/banner" + "github.com/FloatTech/floatbox/file" + "github.com/FloatTech/gg" + "github.com/FloatTech/imgfactory" + "github.com/FloatTech/zbputils/control" + "github.com/FloatTech/zbputils/img/text" + "github.com/disintegration/imaging" +) + +func drawScore16(a *scdata) (image.Image, error) { + // 绘图 + getAvatar, err := initPic(a.picfile, a.uid) + if err != nil { + return nil, err + } + back, err := gg.LoadImage(a.picfile) + if err != nil { + return nil, err + } + // 避免图片过大,最大 1280*720 + back = imgfactory.Limit(back, 1280, 720) + imgDX := back.Bounds().Dx() + imgDY := back.Bounds().Dy() + canvas := gg.NewContext(imgDX, imgDY) + // draw Aero Style + aeroStyle := gg.NewContext(imgDX-202, imgDY-202) + aeroStyle.DrawImage(imaging.Blur(back, 2.5), -100, -100) + // aero draw image. + aeroStyle.DrawRoundedRectangle(0, 0, float64(imgDX-200), float64(imgDY-200), 16) + // SideLine + aeroStyle.SetLineWidth(3) + aeroStyle.SetRGBA255(255, 255, 255, 100) + aeroStyle.StrokePreserve() + aeroStyle.SetRGBA255(255, 255, 255, 140) + // fill + aeroStyle.Fill() + // draw background + canvas.DrawImage(back, 0, 0) + // Aero style combine + canvas.DrawImage(aeroStyle.Image(), 100, 100) + canvas.Fill() + hourWord := getHourWord(time.Now()) + avatar, _, err := image.Decode(bytes.NewReader(getAvatar)) + if err != nil { + return nil, err + } + avatarf := imgfactory.Size(avatar, 200, 200) + canvas.DrawImage(avatarf.Circle(0).Image(), 120, 120) + // draw info(name,coin,etc) + canvas.SetRGB255(0, 0, 0) + data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true) + if err != nil { + return nil, err + } + if err = canvas.ParseFontFace(data, 50); err != nil { + return nil, err + } + // draw head + canvas.DrawStringWrapped(a.nickname, 350, 180, 0.5, 0.5, 0.5, 0.5, gg.AlignLeft) + canvas.Fill() + // main draw + data, err = file.GetLazyData(text.FontFile, control.Md5File, true) + if err != nil { + return nil, err + } + if err = canvas.ParseFontFace(data, 30); err != nil { + return nil, err + } + canvas.DrawStringAnchored(hourWord, 350, 280, 0, 0) + canvas.DrawStringAnchored("ATRI币 + "+strconv.Itoa(a.inc), 350, 350, 0, 0) + canvas.DrawStringAnchored("当前ATRI币:"+strconv.Itoa(a.score), 350, 400, 0, 0) + canvas.DrawStringAnchored("LEVEL: "+strconv.Itoa(getrank(a.level)), 350, 450, 0, 0) + // draw Info(Time,etc.) + getTime := time.Now().Format("2006-01-02 15:04:05") + getTimeLengthWidth, getTimeLengthHight := canvas.MeasureString(getTime) + canvas.DrawStringAnchored(getTime, float64(imgDX)-100-20-getTimeLengthWidth/2, float64(imgDY)-100-getTimeLengthHight, 0.5, 0.5) // time + var nextrankScore int + if a.rank < 10 { + nextrankScore = rankArray[a.rank+1] + } else { + nextrankScore = SCOREMAX + } + nextLevelStyle := strconv.Itoa(a.level) + "/" + strconv.Itoa(nextrankScore) + getLevelLength, _ := canvas.MeasureString(nextLevelStyle) + canvas.DrawStringAnchored(nextLevelStyle, 100+getLevelLength, float64(imgDY)-100-getTimeLengthHight, 0.5, 0.5) // time + canvas.Fill() + canvas.SetRGB255(255, 255, 255) + if err = canvas.ParseFontFace(data, 20); err != nil { + return nil, err + } + canvas.DrawStringAnchored("Created By Zerobot-Plugin "+banner.Version, float64(imgDX)/2, float64(imgDY)-20, 0.5, 0.5) // zbp + canvas.SetRGB255(0, 0, 0) + canvas.DrawStringAnchored("Created By Zerobot-Plugin "+banner.Version, float64(imgDX)/2-3, float64(imgDY)-19, 0.5, 0.5) // zbp + canvas.SetRGB255(255, 255, 255) + // Gradient + grad := gg.NewLinearGradient(20, 320, 400, 20) + grad.AddColorStop(0, color.RGBA{G: 255, A: 255}) + grad.AddColorStop(1, color.RGBA{B: 255, A: 255}) + grad.AddColorStop(0.5, color.RGBA{R: 255, A: 255}) + canvas.SetStrokeStyle(grad) + canvas.SetLineWidth(4) + // level array with rectangle work. + gradLineLength := float64(imgDX-120) - 120 + renderLine := (float64(a.level) / float64(nextrankScore)) * gradLineLength + canvas.MoveTo(120, float64(imgDY)-102) + canvas.LineTo(120+renderLine, float64(imgDY)-102) + canvas.ClosePath() + canvas.Stroke() + return canvas.Image(), nil +} + +func drawScore15(a *scdata) (image.Image, error) { + // 绘图 + _, err := initPic(a.picfile, a.uid) + if err != nil { + return nil, err + } + back, err := gg.LoadImage(a.picfile) + if err != nil { + return nil, err + } + // 避免图片过大,最大 1280*720 + back = imgfactory.Limit(back, 1280, 720) + canvas := gg.NewContext(back.Bounds().Size().X, int(float64(back.Bounds().Size().Y)*1.7)) + canvas.SetRGB(1, 1, 1) + canvas.Clear() + canvas.DrawImage(back, 0, 0) + monthWord := time.Now().Format("01/02") + hourWord := getHourWord(time.Now()) + _, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true) + if err != nil { + return nil, err + } + if err = canvas.LoadFontFace(text.BoldFontFile, float64(back.Bounds().Size().X)*0.1); err != nil { + return nil, err + } + canvas.SetRGB(0, 0, 0) + canvas.DrawString(hourWord, float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.2) + canvas.DrawString(monthWord, float64(back.Bounds().Size().X)*0.6, float64(back.Bounds().Size().Y)*1.2) + _, err = file.GetLazyData(text.FontFile, control.Md5File, true) + if err != nil { + return nil, err + } + if err = canvas.LoadFontFace(text.FontFile, float64(back.Bounds().Size().X)*0.04); err != nil { + return nil, err + } + canvas.DrawString(a.nickname+fmt.Sprintf(" ATRI币+%d", a.inc), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.3) + canvas.DrawString("当前ATRI币:"+strconv.FormatInt(int64(a.score), 10), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.4) + canvas.DrawString("LEVEL:"+strconv.FormatInt(int64(a.rank), 10), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.5) + canvas.DrawRectangle(float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.55, float64(back.Bounds().Size().X)*0.6, float64(back.Bounds().Size().Y)*0.1) + canvas.SetRGB255(150, 150, 150) + canvas.Fill() + var nextrankScore int + if a.rank < 10 { + nextrankScore = rankArray[a.rank+1] + } else { + nextrankScore = SCOREMAX + } + canvas.SetRGB255(0, 0, 0) + canvas.DrawRectangle(float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.55, float64(back.Bounds().Size().X)*0.6*float64(a.level)/float64(nextrankScore), float64(back.Bounds().Size().Y)*0.1) + canvas.SetRGB255(102, 102, 102) + canvas.Fill() + canvas.DrawString(fmt.Sprintf("%d/%d", a.level, nextrankScore), float64(back.Bounds().Size().X)*0.75, float64(back.Bounds().Size().Y)*1.62) + return canvas.Image(), nil +} diff --git a/plugin/score/model.go b/plugin/score/model.go index 65145fbc2d..4c5ab6ef57 100644 --- a/plugin/score/model.go +++ b/plugin/score/model.go @@ -122,3 +122,14 @@ func (sdb *scoredb) GetScoreRankByTopN(n int) (st []scoretable, err error) { err = db.Model(&scoretable{}).Order("score desc").Limit(n).Find(&st).Error return } + +type scdata struct { + drawedfile string + picfile string + uid int64 + nickname string + inc int //增加币 + score int //钱包 + level int + rank int +} diff --git a/plugin/score/sign_in.go b/plugin/score/sign_in.go index 1b9aecb493..44974dbe85 100644 --- a/plugin/score/sign_in.go +++ b/plugin/score/sign_in.go @@ -2,25 +2,19 @@ package score import ( - "bytes" "image" - "image/color" "math" "math/rand" "os" "strconv" "time" - "github.com/disintegration/imaging" - - "github.com/FloatTech/ZeroBot-Plugin/kanban/banner" - "github.com/FloatTech/AnimeAPI/bilibili" "github.com/FloatTech/AnimeAPI/wallet" + fcext "github.com/FloatTech/floatbox/ctxext" "github.com/FloatTech/floatbox/file" "github.com/FloatTech/floatbox/process" "github.com/FloatTech/floatbox/web" - "github.com/FloatTech/gg" "github.com/FloatTech/imgfactory" ctrl "github.com/FloatTech/zbpctrl" "github.com/FloatTech/zbputils/control" @@ -37,7 +31,8 @@ const ( referer = "https://weibo.com/" signinMax = 1 // SCOREMAX 分数上限定为1200 - SCOREMAX = 1200 + SCOREMAX = 1200 + defKeyID int64 = -6 ) var ( @@ -48,6 +43,17 @@ var ( Help: "- 签到\n- 获得签到背景[@xxx] | 获得签到背景\n- 查看等级排名\n注:为跨群排名\n- 查看我的钱包\n- 查看钱包排名\n注:为本群排行,若群人数太多不建议使用该功能!!!", PrivateDataFolder: "score", }) + initDef = fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool { + var defkey string + m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) + _ = m.Manager.Response(defKeyID) + _ = m.Manager.GetExtra(defKeyID, &defkey) + if defkey == "" { + _ = m.Manager.SetExtra(defKeyID, "1") + return true + } + return true + }) ) func init() { @@ -60,185 +66,119 @@ func init() { } sdb = initialize(engine.DataFolder() + "score.db") }() - engine.OnFullMatch("签到").Limit(ctxext.LimitByUser).SetBlock(true). - Handle(func(ctx *zero.Ctx) { - uid := ctx.Event.UserID - now := time.Now() - today := now.Format("20060102") - // 签到图片 - drawedFile := cachePath + strconv.FormatInt(uid, 10) + today + "signin.png" - picFile := cachePath + strconv.FormatInt(uid, 10) + today + ".png" - // 获取签到时间 - si := sdb.GetSignInByUID(uid) - siUpdateTimeStr := si.UpdatedAt.Format("20060102") - switch { - case si.Count >= signinMax && siUpdateTimeStr == today: - // 如果签到时间是今天 - ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("今天你已经签到过了!")) - if file.IsExist(drawedFile) { - ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile)) - } - return - case siUpdateTimeStr != today: - // 如果是跨天签到就清数据 - err := sdb.InsertOrUpdateSignInCountByUID(uid, 0) - if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return - } - } - // 更新签到次数 - err := sdb.InsertOrUpdateSignInCountByUID(uid, si.Count+1) - if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return - } - // 更新经验 - level := sdb.GetScoreByUID(uid).Score + 1 - if level > SCOREMAX { - level = SCOREMAX - ctx.SendChain(message.At(uid), message.Text("你的等级已经达到上限")) - } - err = sdb.InsertOrUpdateScoreByUID(uid, level) - if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return - } - // 更新钱包 - rank := getrank(level) - add := 1 + rand.Intn(10) + rank*5 // 等级越高获得的钱越高 - err = wallet.InsertWalletOf(uid, add) - if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return - } - score := wallet.GetWalletOf(uid) - // 绘图 - getAvatar, err := initPic(picFile, uid) - if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return + engine.OnRegex(`^签到\s?(\d*)$`, initDef).Limit(ctxext.LimitByUser).SetBlock(true).Handle(func(ctx *zero.Ctx) { + //选择key + var key string + gid := ctx.Event.GroupID + if gid < 0 { + // 个人用户设为负数 + gid = -ctx.Event.UserID + } + if ctx.State["regex_matched"].([]string)[1] != "" { + key = ctx.State["regex_matched"].([]string)[1] + } else { + m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) + _ = m.Manager.GetExtra(gid, &key) + if key == "" { + _ = m.Manager.GetExtra(defKeyID, &key) } - back, err := gg.LoadImage(picFile) - if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return + } + uid := ctx.Event.UserID + today := time.Now().Format("20060102") + // 签到图片 + drawedFile := cachePath + strconv.FormatInt(uid, 10) + today + "signin.png" + picFile := cachePath + strconv.FormatInt(uid, 10) + today + ".png" + // 获取签到时间 + si := sdb.GetSignInByUID(uid) + siUpdateTimeStr := si.UpdatedAt.Format("20060102") + switch { + case si.Count >= signinMax && siUpdateTimeStr == today: + // 如果签到时间是今天 + ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("今天你已经签到过了!")) + if file.IsExist(drawedFile) { + ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile)) } - // 避免图片过大,最大 1280*720 - back = imgfactory.Limit(back, 1280, 720) - imgDX := back.Bounds().Dx() - imgDY := back.Bounds().Dy() - canvas := gg.NewContext(imgDX, imgDY) - // draw Aero Style - aeroStyle := gg.NewContext(imgDX-202, imgDY-202) - aeroStyle.DrawImage(imaging.Blur(back, 2.5), -100, -100) - // aero draw image. - aeroStyle.DrawRoundedRectangle(0, 0, float64(imgDX-200), float64(imgDY-200), 16) - // SideLine - aeroStyle.SetLineWidth(3) - aeroStyle.SetRGBA255(255, 255, 255, 100) - aeroStyle.StrokePreserve() - aeroStyle.SetRGBA255(255, 255, 255, 140) - // fill - aeroStyle.Fill() - // draw background - canvas.DrawImage(back, 0, 0) - // Aero style combine - canvas.DrawImage(aeroStyle.Image(), 100, 100) - canvas.Fill() - hourWord := getHourWord(now) - avatar, _, err := image.Decode(bytes.NewReader(getAvatar)) + return + case siUpdateTimeStr != today: + // 如果是跨天签到就清数据 + err := sdb.InsertOrUpdateSignInCountByUID(uid, 0) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return } - avatarf := imgfactory.Size(avatar, 200, 200) - canvas.DrawImage(avatarf.Circle(0).Image(), 120, 120) - // draw info(name,coin,etc) - canvas.SetRGB255(0, 0, 0) - data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true) + } + // 更新签到次数 + err := sdb.InsertOrUpdateSignInCountByUID(uid, si.Count+1) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + // 更新经验 + level := sdb.GetScoreByUID(uid).Score + 1 + if level > SCOREMAX { + level = SCOREMAX + ctx.SendChain(message.At(uid), message.Text("你的等级已经达到上限")) + } + err = sdb.InsertOrUpdateScoreByUID(uid, level) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + // 更新钱包 + rank := getrank(level) + add := 1 + rand.Intn(10) + rank*5 // 等级越高获得的钱越高 + err = wallet.InsertWalletOf(uid, add) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + alldata := scdata{ + drawedfile: drawedFile, + picfile: picFile, + uid: uid, + nickname: ctx.CardOrNickName(uid), + inc: add, + score: wallet.GetWalletOf(uid), + level: level, + rank: rank, + } + var drawimage image.Image + switch key { + case "1": + drawimage, err = drawScore16(&alldata) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return } - if err = canvas.ParseFontFace(data, 50); err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return - } - // draw head - nickName := ctx.CardOrNickName(uid) - canvas.DrawString(nickName, 350, 180) - canvas.Fill() - // main draw - data, err = file.GetLazyData(text.FontFile, control.Md5File, true) + case "2": + drawimage, err = drawScore15(&alldata) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return } - if err = canvas.ParseFontFace(data, 30); err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return - } - canvas.DrawStringAnchored(hourWord, 350, 280, 0, 0) - canvas.DrawStringAnchored("ATRI币 + "+strconv.Itoa(add), 350, 350, 0, 0) - canvas.DrawStringAnchored("当前ATRI币:"+strconv.Itoa(score), 350, 400, 0, 0) - canvas.DrawStringAnchored("LEVEL: "+strconv.Itoa(getrank(level)), 350, 450, 0, 0) - // draw Info(Time,etc.) - getTime := time.Now().Format("2006-01-02 15:04:05") - getTimeLengthWidth, getTimeLengthHight := canvas.MeasureString(getTime) - canvas.DrawStringAnchored(getTime, float64(imgDX)-100-20-getTimeLengthWidth/2, float64(imgDY)-100-getTimeLengthHight, 0.5, 0.5) // time - var nextrankScore int - if rank < 10 { - nextrankScore = rankArray[rank+1] - } else { - nextrankScore = SCOREMAX - } - nextLevelStyle := strconv.Itoa(level) + "/" + strconv.Itoa(nextrankScore) - getLevelLength, _ := canvas.MeasureString(nextLevelStyle) - canvas.DrawStringAnchored(nextLevelStyle, 100+getLevelLength, float64(imgDY)-100-getTimeLengthHight, 0.5, 0.5) // time - canvas.Fill() - canvas.SetRGB255(255, 255, 255) - if err = canvas.ParseFontFace(data, 20); err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return - } - canvas.DrawStringAnchored("Created By Zerobot-Plugin "+banner.Version, float64(imgDX)/2, float64(imgDY)-20, 0.5, 0.5) // zbp - canvas.SetRGB255(0, 0, 0) - canvas.DrawStringAnchored("Created By Zerobot-Plugin "+banner.Version, float64(imgDX)/2-3, float64(imgDY)-19, 0.5, 0.5) // zbp - canvas.SetRGB255(255, 255, 255) - // Gradient - grad := gg.NewLinearGradient(20, 320, 400, 20) - grad.AddColorStop(0, color.RGBA{G: 255, A: 255}) - grad.AddColorStop(1, color.RGBA{B: 255, A: 255}) - grad.AddColorStop(0.5, color.RGBA{R: 255, A: 255}) - canvas.SetStrokeStyle(grad) - canvas.SetLineWidth(4) - // level array with rectangle work. - gradLineLength := float64(imgDX-120) - 120 - renderLine := (float64(level) / float64(nextrankScore)) * gradLineLength - canvas.MoveTo(120, float64(imgDY)-102) - canvas.LineTo(120+renderLine, float64(imgDY)-102) - canvas.ClosePath() - canvas.Stroke() - // done. - f, err := os.Create(drawedFile) - if err != nil { - data, err := imgfactory.ToBytes(canvas.Image()) - if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return - } - ctx.SendChain(message.ImageBytes(data)) - return - } - _, err = imgfactory.WriteTo(canvas.Image(), f) - _ = f.Close() + default: + ctx.SendChain(message.Text("未找到签到设定:", key)) + return + } + // done. + f, err := os.Create(drawedFile) + if err != nil { + data, err := imgfactory.ToBytes(drawimage) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return } - ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile)) - }) + ctx.SendChain(message.ImageBytes(data)) + return + } + _, err = imgfactory.WriteTo(drawimage, f) + _ = f.Close() + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile)) + }) engine.OnPrefix("获得签到背景", zero.OnlyGroup).Limit(ctxext.LimitByGroup).SetBlock(true). Handle(func(ctx *zero.Ctx) { @@ -328,6 +268,27 @@ func init() { } ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile)) }) + engine.OnRegex(`^设置(默认)?签到预设\s?(\d*)$`, zero.SuperUserPermission).Limit(ctxext.LimitByUser).SetBlock(true).Handle(func(ctx *zero.Ctx) { + if ctx.State["regex_matched"].([]string)[2] == "" { + ctx.SendChain(message.Text("设置失败,数据为空")) + } else { + s := ctx.State["regex_matched"].([]string)[1] + key := ctx.State["regex_matched"].([]string)[2] + gid := ctx.Event.GroupID + if gid == 0 { + gid = -ctx.Event.UserID + } + if s != "" { + gid = defKeyID + } + err := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]).Manager.SetExtra(gid, key) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + ctx.SendChain(message.Text("设置成功,当前", s, "预设为:", key)) + } + }) } func getHourWord(t time.Time) string { From 1a0575af644e9e9f51c69a02f1872cb21d431a39 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 25 Mar 2023 11:07:00 +0800 Subject: [PATCH 19/95] =?UTF-8?q?=F0=9F=8E=A8=20=E6=94=B9=E8=BF=9B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=B7=E5=BC=8F=20(#638)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- plugin/score/draw.go | 3 ++- plugin/score/model.go | 4 ++-- plugin/score/sign_in.go | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/plugin/score/draw.go b/plugin/score/draw.go index 33ae9f3da5..7a67d45bea 100644 --- a/plugin/score/draw.go +++ b/plugin/score/draw.go @@ -9,13 +9,14 @@ import ( "strconv" "time" - "github.com/FloatTech/ZeroBot-Plugin/kanban/banner" "github.com/FloatTech/floatbox/file" "github.com/FloatTech/gg" "github.com/FloatTech/imgfactory" "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/img/text" "github.com/disintegration/imaging" + + "github.com/FloatTech/ZeroBot-Plugin/kanban/banner" ) func drawScore16(a *scdata) (image.Image, error) { diff --git a/plugin/score/model.go b/plugin/score/model.go index 4c5ab6ef57..e0e21d8a4f 100644 --- a/plugin/score/model.go +++ b/plugin/score/model.go @@ -128,8 +128,8 @@ type scdata struct { picfile string uid int64 nickname string - inc int //增加币 - score int //钱包 + inc int // 增加币 + score int // 钱包 level int rank int } diff --git a/plugin/score/sign_in.go b/plugin/score/sign_in.go index 44974dbe85..49dd44ff2e 100644 --- a/plugin/score/sign_in.go +++ b/plugin/score/sign_in.go @@ -67,7 +67,7 @@ func init() { sdb = initialize(engine.DataFolder() + "score.db") }() engine.OnRegex(`^签到\s?(\d*)$`, initDef).Limit(ctxext.LimitByUser).SetBlock(true).Handle(func(ctx *zero.Ctx) { - //选择key + // 选择key var key string gid := ctx.Event.GroupID if gid < 0 { From aa5c324592c840ef85415a8aa476d30d470ee374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sat, 25 Mar 2023 17:36:17 +0800 Subject: [PATCH 20/95] =?UTF-8?q?=E2=9C=A8=20=E6=8A=BD=E8=80=81=E5=A9=86?= =?UTF-8?q?=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 32 ++++++++++++++--------- data | 2 +- go.mod | 4 +-- go.sum | 6 ++--- main.go | 1 + plugin/shindan/shindan.go | 2 +- plugin/wife/main.go | 55 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 82 insertions(+), 20 deletions(-) create mode 100644 plugin/wife/main.go diff --git a/README.md b/README.md index c7e7cbe5eb..ff77d500d1 100644 --- a/README.md +++ b/README.md @@ -1279,7 +1279,7 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] 卖萌[@xxx] - - [x] 抽老婆[@xxx] + - [x] 今日老婆[@xxx] - [x] 黄油角色[@xxx] @@ -1459,19 +1459,11 @@ print("run[CQ:image,file="+j["img"]+"]")
- 月幕galgame图 - - `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal"` - - - [x] 随机galCG - - - [x] 随机gal表情包 + 抽老婆 - - [x] galCG[xxx] - - - [x] gal表情包[xxx] + `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wife"` - - [x] 更新gal + - [x] 抽老婆
@@ -1518,6 +1510,22 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] 查卡店 [卡名] -r [稀有度] - 注:卡店只支持单个稀有度查询 +
+
+ 月幕galgame图 + + `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal"` + + - [x] 随机galCG + + - [x] 随机gal表情包 + + - [x] galCG[xxx] + + - [x] gal表情包[xxx] + + - [x] 更新gal +
词典匹配回复 diff --git a/data b/data index b9848c9a4e..541c1dec93 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit b9848c9a4e53c3700bbfc9c1efcd3cc52ad400bc +Subproject commit 541c1dec93f480d295fc5463814a94c014a53512 diff --git a/go.mod b/go.mod index 46a0a90d71..d944c2c60d 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( github.com/Baidu-AIP/golang-sdk v1.1.1 github.com/FloatTech/AnimeAPI v1.6.1-0.20230316111643-46d40c9d80e3 - github.com/FloatTech/floatbox v0.0.0-20230316111222-7ffde57284cc + github.com/FloatTech/floatbox v0.0.0-20230325093157-844e210a5dab github.com/FloatTech/gg v1.1.2 github.com/FloatTech/imgfactory v0.2.2-0.20230322091809-b0ddbe44b94b github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9 @@ -24,6 +24,7 @@ require ( github.com/fumiama/go-base16384 v1.6.4 github.com/fumiama/go-registry v0.2.6 github.com/fumiama/gotracemoe v0.0.3 + github.com/fumiama/imgsz v0.0.2 github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565 github.com/fumiama/unibase2n v0.0.0-20221020155353-02876e777430 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 @@ -51,7 +52,6 @@ require ( github.com/faiface/beep v1.1.0 // indirect github.com/fumiama/go-simple-protobuf v0.1.0 // indirect github.com/fumiama/gofastTEA v0.0.10 // indirect - github.com/fumiama/imgsz v0.0.2 // indirect github.com/gabriel-vasile/mimetype v1.0.4 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect diff --git a/go.sum b/go.sum index 0d1dd29eee..7d4579178b 100644 --- a/go.sum +++ b/go.sum @@ -4,12 +4,10 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/FloatTech/AnimeAPI v1.6.1-0.20230316111643-46d40c9d80e3 h1:SyXS1YXrRuzO3YVCZB/5gSX7vaFbSMwzN+RXLNNKq5M= github.com/FloatTech/AnimeAPI v1.6.1-0.20230316111643-46d40c9d80e3/go.mod h1:h+22XrJTgcn0m4aM3o1pYo5G0+Mv4v7wW5xvZQ4LabY= -github.com/FloatTech/floatbox v0.0.0-20230316111222-7ffde57284cc h1:1yentlIEJImE0rla5xE7o73ZW37eS/byFhPEwx9WYEs= -github.com/FloatTech/floatbox v0.0.0-20230316111222-7ffde57284cc/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI= +github.com/FloatTech/floatbox v0.0.0-20230325093157-844e210a5dab h1:Tp+uRcdDBukeSowPDEo2iAux8rCd10VWqglC4a238TI= +github.com/FloatTech/floatbox v0.0.0-20230325093157-844e210a5dab/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI= 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= diff --git a/main.go b/main.go index 3126843741..50babd68f1 100644 --- a/main.go +++ b/main.go @@ -144,6 +144,7 @@ import ( _ "github.com/FloatTech/ZeroBot-Plugin/plugin/warframeapi" // warframeAPI插件 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenben" // 文本指令大全 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenxinAI" // 百度文心AI画图 + _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wife" // 抽老婆 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/word_count" // 聊天热词 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle" // 猜单词 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ygo" // 游戏王相关插件 diff --git a/plugin/shindan/shindan.go b/plugin/shindan/shindan.go index 2b85afcd61..9ce3c0e547 100644 --- a/plugin/shindan/shindan.go +++ b/plugin/shindan/shindan.go @@ -26,7 +26,7 @@ func init() { engine.OnPrefix("异世界转生", number(587874)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic) engine.OnPrefix("今天是什么少女", number(162207)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic) engine.OnPrefix("卖萌", number(360578)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handletxt) - engine.OnPrefix("抽老婆", number(1075116)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlecq) + engine.OnPrefix("今日老婆", number(1075116)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlecq) engine.OnPrefix("黄油角色", number(1115465)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic) } diff --git a/plugin/wife/main.go b/plugin/wife/main.go new file mode 100644 index 0000000000..a52a5638b6 --- /dev/null +++ b/plugin/wife/main.go @@ -0,0 +1,55 @@ +// Package wife 抽老婆 +package wife + +import ( + "encoding/json" + + fcext "github.com/FloatTech/floatbox/ctxext" + "github.com/FloatTech/floatbox/file" + ctrl "github.com/FloatTech/zbpctrl" + "github.com/FloatTech/zbputils/control" + "github.com/FloatTech/zbputils/ctxext" + "github.com/sirupsen/logrus" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" +) + +func init() { + engine := control.Register("wife", &ctrl.Options[*zero.Ctx]{ + DisableOnDefault: false, + Help: "抽老婆\n" + + "- 抽老婆", + PublicDataFolder: "Wife", + }).ApplySingle(ctxext.DefaultSingle) + cards := []string{} + uriprefix := "file:///" + file.BOTPATH + "/" + engine.DataFolder() + engine.OnFullMatch("抽老婆", fcext.DoOnceOnSuccess( + func(ctx *zero.Ctx) bool { + data, err := engine.GetLazyData("wife.json", true) + if err != nil { + ctx.SendChain(message.Text("ERROR:", err)) + return false + } + err = json.Unmarshal(data, &cards) + if err != nil { + ctx.SendChain(message.Text("ERROR:", err)) + return false + } + logrus.Infof("[wife]加载%d个老婆", len(cards)) + return true + }, + )).SetBlock(true). + Handle(func(ctx *zero.Ctx) { + card := cards[fcext.RandSenderPerDayN(ctx.Event.UserID, len(cards))] + if id := ctx.SendChain( + message.At(ctx.Event.UserID), + message.Text("今天的二次元老婆是~【", card, "】哒"), + message.Image(uriprefix+"wives/"+card), + ); id.ID() == 0 { + ctx.SendChain( + message.At(ctx.Event.UserID), + message.Text("今天的二次元老婆是~【", card, "】哒\n【图片发送失败, 请联系维护者】"), + ) + } + }) +} From f465e78460841cb50d6b7d1f559fd86d7ef6ba9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sat, 25 Mar 2023 20:06:49 +0800 Subject: [PATCH 21/95] =?UTF-8?q?=E6=81=A2=E5=A4=8Dthesaurus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 36 +++++++++++++++++------------------- go.mod | 2 +- go.sum | 4 ++-- main.go | 3 ++- plugin/thesaurus/chat.go | 5 +---- 5 files changed, 23 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index ff77d500d1..c6744c9bd2 100644 --- a/README.md +++ b/README.md @@ -571,14 +571,6 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] 随机书评 -
-
- 打断复读 - - `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/breakrepeat"` - - - [x] (打断三次以上的复读) -
藏头诗 @@ -1526,17 +1518,6 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] 更新gal -
-
- 词典匹配回复 - - `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/thesaurus"` - - - [x] 切换[kimo|傲娇|可爱]词库 - - [x] 设置词库触发概率0.x (0
鬼东西 @@ -1574,6 +1555,23 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] 设置 ChatGPT api key xxx +
+
+ 词典匹配回复 + + `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/thesaurus"` + + - [x] 切换[kimo|傲娇|可爱]词库 + - [x] 设置词库触发概率0.x (0 +
+ 打断复读 + + `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/breakrepeat"` + + - [x] (打断三次以上的复读) +
## 三种使用方法,推荐第一种 diff --git a/go.mod b/go.mod index d944c2c60d..352611d3d1 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( github.com/Baidu-AIP/golang-sdk v1.1.1 github.com/FloatTech/AnimeAPI v1.6.1-0.20230316111643-46d40c9d80e3 - github.com/FloatTech/floatbox v0.0.0-20230325093157-844e210a5dab + github.com/FloatTech/floatbox v0.0.0-20230325120101-d69494a7cc95 github.com/FloatTech/gg v1.1.2 github.com/FloatTech/imgfactory v0.2.2-0.20230322091809-b0ddbe44b94b github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9 diff --git a/go.sum b/go.sum index 7d4579178b..d6b4ffbc21 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/FloatTech/AnimeAPI v1.6.1-0.20230316111643-46d40c9d80e3 h1:SyXS1YXrRuzO3YVCZB/5gSX7vaFbSMwzN+RXLNNKq5M= github.com/FloatTech/AnimeAPI v1.6.1-0.20230316111643-46d40c9d80e3/go.mod h1:h+22XrJTgcn0m4aM3o1pYo5G0+Mv4v7wW5xvZQ4LabY= -github.com/FloatTech/floatbox v0.0.0-20230325093157-844e210a5dab h1:Tp+uRcdDBukeSowPDEo2iAux8rCd10VWqglC4a238TI= -github.com/FloatTech/floatbox v0.0.0-20230325093157-844e210a5dab/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI= +github.com/FloatTech/floatbox v0.0.0-20230325120101-d69494a7cc95 h1:wRcdulvceh55bzjXPtqHsKTTil6ipnvAo+uvf4w9LTI= +github.com/FloatTech/floatbox v0.0.0-20230325120101-d69494a7cc95/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI= 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.20230322091809-b0ddbe44b94b h1:VMNci4SWBySdw/6poqF9Dn9zlT5ntTFSJOEEBjRnJ/4= diff --git a/main.go b/main.go index 50babd68f1..0ac64b99e8 100644 --- a/main.go +++ b/main.go @@ -150,7 +150,6 @@ import ( _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ygo" // 游戏王相关插件 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal" // 月幕galgame - // _ "github.com/FloatTech/ZeroBot-Plugin/plugin/thesaurus" // 词典匹配回复 // _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wtf" // 鬼东西 // ^^^^ // @@ -175,6 +174,8 @@ import ( _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ai_reply" // 人工智能回复 + _ "github.com/FloatTech/ZeroBot-Plugin/plugin/thesaurus" // 词典匹配回复 + _ "github.com/FloatTech/ZeroBot-Plugin/plugin/breakrepeat" // 打断复读 // ^^^^ // diff --git a/plugin/thesaurus/chat.go b/plugin/thesaurus/chat.go index b124856c89..3da6280003 100644 --- a/plugin/thesaurus/chat.go +++ b/plugin/thesaurus/chat.go @@ -146,10 +146,7 @@ const ( func match(l []string, seg *jieba.Segmenter) zero.Rule { return func(ctx *zero.Ctx) bool { - if zero.FullMatchRule(l...)(ctx) { - return true - } - return ctxext.JiebaFullMatch(seg, func(ctx *zero.Ctx) string { + return ctxext.JiebaSimilarity(0.5, seg, func(ctx *zero.Ctx) string { return ctx.ExtractPlainText() }, l...)(ctx) } From 309afecadde42d618cc2fbaf5d8e7647664f5086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sat, 25 Mar 2023 20:09:04 +0800 Subject: [PATCH 22/95] wife add brief --- plugin/wife/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/wife/main.go b/plugin/wife/main.go index a52a5638b6..6bb2e0a18f 100644 --- a/plugin/wife/main.go +++ b/plugin/wife/main.go @@ -17,8 +17,8 @@ import ( func init() { engine := control.Register("wife", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, - Help: "抽老婆\n" + - "- 抽老婆", + Help: "- 抽老婆", + Brief: "从老婆库抽每日老婆", PublicDataFolder: "Wife", }).ApplySingle(ctxext.DefaultSingle) cards := []string{} From 14c596be1fdeda0246b4a2121122ee03eda3b189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sat, 25 Mar 2023 20:10:19 +0800 Subject: [PATCH 23/95] =?UTF-8?q?=F0=9F=94=96=20v1.7.1-beta1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kanban/banner/banner.go | 4 ++-- winres/gen/json.go | 2 +- winres/winres.json | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/kanban/banner/banner.go b/kanban/banner/banner.go index b372b83865..745d7dad03 100644 --- a/kanban/banner/banner.go +++ b/kanban/banner/banner.go @@ -3,13 +3,13 @@ package banner // Version ... -var Version = "v1.7.0" +var Version = "v1.7.1-beta1" // Copyright ... var Copyright = "© 2020 - 2023 FloatTech" // Banner ... var Banner = "* OneBot + ZeroBot + Golang\n" + - "* Version " + Version + " - 2023-03-20 12:27:42 +0800 CST\n" + + "* Version " + Version + " - 2023-03-25 20:09:29 +0800 CST\n" + "* Copyright " + Copyright + ". All Rights Reserved.\n" + "* Project: https://github.com/FloatTech/ZeroBot-Plugin" diff --git a/winres/gen/json.go b/winres/gen/json.go index 3fe9d8fea1..4b5203f4bb 100644 --- a/winres/gen/json.go +++ b/winres/gen/json.go @@ -89,7 +89,7 @@ func main() { commitcnt := strings.Builder{} commitcnt.WriteString(banner.Version[1:i]) commitcnt.WriteByte('.') - commitcntcmd := exec.Command("git", "rev-list", "--count", "master") + commitcntcmd := exec.Command("git", "rev-list", "--count", "HEAD") commitcntcmd.Stdout = &commitcnt err = commitcntcmd.Run() if err != nil { diff --git a/winres/winres.json b/winres/winres.json index 48c0ede1d5..67536e6786 100644 --- a/winres/winres.json +++ b/winres/winres.json @@ -12,7 +12,7 @@ "0409": { "identity": { "name": "ZeroBot-Plugin", - "version": "1.7.0.1760" + "version": "1.7.1.1769" }, "description": "", "minimum-os": "vista", @@ -36,23 +36,23 @@ "#1": { "0000": { "fixed": { - "file_version": "1.7.0.1760", - "product_version": "v1.7.0", - "timestamp": "2023-03-20T12:28:01+08:00" + "file_version": "1.7.1.1769", + "product_version": "v1.7.1-beta1", + "timestamp": "2023-03-25T20:09:59+08:00" }, "info": { "0409": { "Comments": "OneBot plugins based on ZeroBot", "CompanyName": "FloatTech", "FileDescription": "https://github.com/FloatTech/ZeroBot-Plugin", - "FileVersion": "1.7.0.1760", + "FileVersion": "1.7.1.1769", "InternalName": "", "LegalCopyright": "© 2020 - 2023 FloatTech. All Rights Reserved.", "LegalTrademarks": "", "OriginalFilename": "ZBP.EXE", "PrivateBuild": "", "ProductName": "ZeroBot-Plugin", - "ProductVersion": "v1.7.0", + "ProductVersion": "v1.7.1-beta1", "SpecialBuild": "" } } From 1aa11879dcf233ef1ce6a1048594a94735872339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sat, 25 Mar 2023 20:21:44 +0800 Subject: [PATCH 24/95] fix wife --- plugin/wife/main.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugin/wife/main.go b/plugin/wife/main.go index 6bb2e0a18f..21e19b5153 100644 --- a/plugin/wife/main.go +++ b/plugin/wife/main.go @@ -5,7 +5,6 @@ import ( "encoding/json" fcext "github.com/FloatTech/floatbox/ctxext" - "github.com/FloatTech/floatbox/file" ctrl "github.com/FloatTech/zbpctrl" "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" @@ -22,7 +21,6 @@ func init() { PublicDataFolder: "Wife", }).ApplySingle(ctxext.DefaultSingle) cards := []string{} - uriprefix := "file:///" + file.BOTPATH + "/" + engine.DataFolder() engine.OnFullMatch("抽老婆", fcext.DoOnceOnSuccess( func(ctx *zero.Ctx) bool { data, err := engine.GetLazyData("wife.json", true) @@ -41,10 +39,18 @@ func init() { )).SetBlock(true). Handle(func(ctx *zero.Ctx) { card := cards[fcext.RandSenderPerDayN(ctx.Event.UserID, len(cards))] + data, err := engine.GetLazyData(engine.DataFolder()+"wives/"+card, true) + if err != nil { + ctx.SendChain( + message.At(ctx.Event.UserID), + message.Text("今天的二次元老婆是~【", card, "】哒\n【图片下载失败: ", err, "】"), + ) + return + } if id := ctx.SendChain( message.At(ctx.Event.UserID), message.Text("今天的二次元老婆是~【", card, "】哒"), - message.Image(uriprefix+"wives/"+card), + message.ImageBytes(data), ); id.ID() == 0 { ctx.SendChain( message.At(ctx.Event.UserID), From 0c8dfb3f9c20fa18489ec214855f4de29ff18a42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sat, 25 Mar 2023 20:23:56 +0800 Subject: [PATCH 25/95] =?UTF-8?q?=E4=BC=98=E5=8C=96=20ctx=20ERROR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/dailynews/dailynews.go | 2 +- plugin/drawlots/main.go | 16 ++++++++-------- plugin/wife/main.go | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/plugin/dailynews/dailynews.go b/plugin/dailynews/dailynews.go index 8b34fbb4fd..3ed761c298 100644 --- a/plugin/dailynews/dailynews.go +++ b/plugin/dailynews/dailynews.go @@ -29,7 +29,7 @@ func init() { } picURL := gjson.Get(binary.BytesToString(data), "imageUrl").String() if err != nil { - ctx.SendChain(message.Text("ERROR:", err)) + ctx.SendChain(message.Text("ERROR: ", err)) return } ctx.SendChain(message.Image(picURL)) diff --git a/plugin/drawlots/main.go b/plugin/drawlots/main.go index 096dcff875..9d77e675cc 100644 --- a/plugin/drawlots/main.go +++ b/plugin/drawlots/main.go @@ -55,7 +55,7 @@ func init() { en.OnFullMatchGroup([]string{"抽签列表", "刷新抽签列表"}).SetBlock(true).Handle(func(ctx *zero.Ctx) { lotsList, err := getList() // 刷新列表 if err != nil { - ctx.SendChain(message.Text("ERROR:", err)) + ctx.SendChain(message.Text("ERROR: ", err)) return } messageText := &strings.Builder{} @@ -67,7 +67,7 @@ func init() { } textPic, err := text.RenderToBase64(messageText.String(), text.BoldFontFile, 400, 50) if err != nil { - ctx.SendChain(message.Text("ERROR:", err)) + ctx.SendChain(message.Text("ERROR: ", err)) return } ctx.SendChain(message.Image("base64://" + helper.BytesToString(textPic))) @@ -82,7 +82,7 @@ func init() { if fileInfo.lotsType == "folder" { picPath, err := randFile(lotsType, 3) if err != nil { - ctx.SendChain(message.Text("ERROR:", err)) + ctx.SendChain(message.Text("ERROR: ", err)) return } ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("file:///"+picPath)) @@ -90,13 +90,13 @@ func init() { } lotsImg, err := randGif(lotsType + "." + fileInfo.lotsType) if err != nil { - ctx.SendChain(message.Text("ERROR:", err)) + ctx.SendChain(message.Text("ERROR: ", err)) return } // 生成图片 data, err := imgfactory.ToBytes(lotsImg) if err != nil { - ctx.SendChain(message.Text("ERROR:", err)) + ctx.SendChain(message.Text("ERROR: ", err)) return } ctx.SendChain(message.Reply(ctx.Event.MessageID), message.ImageBytes(data)) @@ -129,13 +129,13 @@ func init() { } im, err := gif.DecodeAll(bytes.NewReader(gifdata)) if err != nil { - ctx.SendChain(message.Text("ERROR:", err)) + ctx.SendChain(message.Text("ERROR: ", err)) return } fileName := datapath + "/" + lotsName + ".gif" err = file.DownloadTo(picURL, fileName) if err != nil { - ctx.SendChain(message.Text("ERROR:", err)) + ctx.SendChain(message.Text("ERROR: ", err)) return } lotsList[lotsName] = info{ @@ -158,7 +158,7 @@ func init() { } err := os.Remove(datapath + lotsName + "." + fileInfo.lotsType) if err != nil { - ctx.SendChain(message.Text("ERROR:", err)) + ctx.SendChain(message.Text("ERROR: ", err)) return } delete(lotsList, lotsName) diff --git a/plugin/wife/main.go b/plugin/wife/main.go index 21e19b5153..e86b41d536 100644 --- a/plugin/wife/main.go +++ b/plugin/wife/main.go @@ -25,12 +25,12 @@ func init() { func(ctx *zero.Ctx) bool { data, err := engine.GetLazyData("wife.json", true) if err != nil { - ctx.SendChain(message.Text("ERROR:", err)) + ctx.SendChain(message.Text("ERROR: ", err)) return false } err = json.Unmarshal(data, &cards) if err != nil { - ctx.SendChain(message.Text("ERROR:", err)) + ctx.SendChain(message.Text("ERROR: ", err)) return false } logrus.Infof("[wife]加载%d个老婆", len(cards)) From b4a1f9399329ca0fd968ec666daeb14761deb054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sat, 25 Mar 2023 21:47:24 +0800 Subject: [PATCH 26/95] fix wifw --- plugin/wife/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/wife/main.go b/plugin/wife/main.go index e86b41d536..5a2385acc2 100644 --- a/plugin/wife/main.go +++ b/plugin/wife/main.go @@ -39,7 +39,7 @@ func init() { )).SetBlock(true). Handle(func(ctx *zero.Ctx) { card := cards[fcext.RandSenderPerDayN(ctx.Event.UserID, len(cards))] - data, err := engine.GetLazyData(engine.DataFolder()+"wives/"+card, true) + data, err := engine.GetLazyData("wives/"+card, true) if err != nil { ctx.SendChain( message.At(ctx.Event.UserID), From 4a15326977480da2d81ec426a5f820c8c50e4ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sat, 25 Mar 2023 21:51:52 +0800 Subject: [PATCH 27/95] =?UTF-8?q?=E4=BC=98=E5=8C=96wife?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/wife/main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin/wife/main.go b/plugin/wife/main.go index 5a2385acc2..f105ae86f3 100644 --- a/plugin/wife/main.go +++ b/plugin/wife/main.go @@ -3,6 +3,7 @@ package wife import ( "encoding/json" + "strings" fcext "github.com/FloatTech/floatbox/ctxext" ctrl "github.com/FloatTech/zbpctrl" @@ -40,6 +41,7 @@ func init() { Handle(func(ctx *zero.Ctx) { card := cards[fcext.RandSenderPerDayN(ctx.Event.UserID, len(cards))] data, err := engine.GetLazyData("wives/"+card, true) + card, _, _ = strings.Cut(card, ".") if err != nil { ctx.SendChain( message.At(ctx.Event.UserID), From d66dd9b7fab767fed78e6e65b6298fa426358edf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sat, 25 Mar 2023 21:56:43 +0800 Subject: [PATCH 28/95] fix wifw --- plugin/wife/main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin/wife/main.go b/plugin/wife/main.go index f105ae86f3..1658f876ff 100644 --- a/plugin/wife/main.go +++ b/plugin/wife/main.go @@ -3,6 +3,7 @@ package wife import ( "encoding/json" + "os" "strings" fcext "github.com/FloatTech/floatbox/ctxext" @@ -21,6 +22,7 @@ func init() { Brief: "从老婆库抽每日老婆", PublicDataFolder: "Wife", }).ApplySingle(ctxext.DefaultSingle) + _ = os.MkdirAll(engine.DataFolder()+"wives", 0755) cards := []string{} engine.OnFullMatch("抽老婆", fcext.DoOnceOnSuccess( func(ctx *zero.Ctx) bool { From 6ea50cf8b70348f7690e8c0e50e618c9cf69c00a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sat, 25 Mar 2023 22:09:27 +0800 Subject: [PATCH 29/95] =?UTF-8?q?=E9=99=8D=E4=BD=8Esimi=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E6=A6=82=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/thesaurus/chat.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/thesaurus/chat.go b/plugin/thesaurus/chat.go index 3da6280003..190eb013dd 100644 --- a/plugin/thesaurus/chat.go +++ b/plugin/thesaurus/chat.go @@ -146,7 +146,7 @@ const ( func match(l []string, seg *jieba.Segmenter) zero.Rule { return func(ctx *zero.Ctx) bool { - return ctxext.JiebaSimilarity(0.5, seg, func(ctx *zero.Ctx) string { + return ctxext.JiebaSimilarity(0.8, seg, func(ctx *zero.Ctx) string { return ctx.ExtractPlainText() }, l...)(ctx) } From 864f92a728acc0e99f6823b2fcbd90eb6b257282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=9C=E8=93=BF=E7=B4=AB?= <68104673+medicago087@users.noreply.github.com> Date: Mon, 27 Mar 2023 22:43:19 +0800 Subject: [PATCH 30/95] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=AD=BE=E5=88=B03=20(?= =?UTF-8?q?#644)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + go.mod | 4 +- go.sum | 2 + plugin/score/draw.go | 96 ++++++++++++++++++++++++++++++++++++++++- plugin/score/sign_in.go | 27 ++++++++++-- 5 files changed, 124 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c6744c9bd2..248e1b1dab 100644 --- a/README.md +++ b/README.md @@ -1239,6 +1239,7 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] 签到 - [x] 获得签到背景[@xxx] | 获得签到背景 + - [x] 设置[默认]签到预设(1~9) - [x] 查看等级排名 - 注:跨群排行 - [x] 查看我的钱包 diff --git a/go.mod b/go.mod index 352611d3d1..33cdff9c14 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/FloatTech/sqlite v1.5.7 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b github.com/FloatTech/zbpctrl v1.5.3-0.20230316111343-dd078fa43fe3 - github.com/FloatTech/zbputils v1.6.2-0.20230316111555-2d1ec958de04 + github.com/FloatTech/zbputils v1.6.2-0.20230320041820-731f824ff8f4 github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 @@ -24,7 +24,6 @@ require ( github.com/fumiama/go-base16384 v1.6.4 github.com/fumiama/go-registry v0.2.6 github.com/fumiama/gotracemoe v0.0.3 - github.com/fumiama/imgsz v0.0.2 github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565 github.com/fumiama/unibase2n v0.0.0-20221020155353-02876e777430 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 @@ -52,6 +51,7 @@ require ( github.com/faiface/beep v1.1.0 // indirect github.com/fumiama/go-simple-protobuf v0.1.0 // indirect github.com/fumiama/gofastTEA v0.0.10 // indirect + github.com/fumiama/imgsz v0.0.2 // indirect github.com/gabriel-vasile/mimetype v1.0.4 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect diff --git a/go.sum b/go.sum index d6b4ffbc21..b541ca8c87 100644 --- a/go.sum +++ b/go.sum @@ -20,6 +20,8 @@ github.com/FloatTech/zbpctrl v1.5.3-0.20230316111343-dd078fa43fe3 h1:mCVrTvS2LMN github.com/FloatTech/zbpctrl v1.5.3-0.20230316111343-dd078fa43fe3/go.mod h1:IagyEhY38VcbbQgVRzAM9f9mhaUn90rM5BTPfudtl1g= github.com/FloatTech/zbputils v1.6.2-0.20230316111555-2d1ec958de04 h1:ovL+7SAPTBCXy6XNRSdJhNvHtbueWCwEb/jtztmizAc= github.com/FloatTech/zbputils v1.6.2-0.20230316111555-2d1ec958de04/go.mod h1:jUmX4WBgGRcfjGeIobmVao10AHmXtL3gT00qLbx3/yo= +github.com/FloatTech/zbputils v1.6.2-0.20230320041820-731f824ff8f4 h1:OrqldcPSJWnPxZtmkOd9HJmFFD3rl0Qrob89rHHpoXw= +github.com/FloatTech/zbputils v1.6.2-0.20230320041820-731f824ff8f4/go.mod h1:jUmX4WBgGRcfjGeIobmVao10AHmXtL3gT00qLbx3/yo= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= diff --git a/plugin/score/draw.go b/plugin/score/draw.go index 7a67d45bea..f1c724aed2 100644 --- a/plugin/score/draw.go +++ b/plugin/score/draw.go @@ -1,4 +1,4 @@ -// Package score 签到,答题得分 +// Package score 签到 package score import ( @@ -175,3 +175,97 @@ func drawScore15(a *scdata) (image.Image, error) { canvas.DrawString(fmt.Sprintf("%d/%d", a.level, nextrankScore), float64(back.Bounds().Size().X)*0.75, float64(back.Bounds().Size().Y)*1.62) return canvas.Image(), nil } + +func drawScore17(a *scdata) (image.Image, error) { + getAvatar, err := initPic(a.picfile, a.uid) + if err != nil { + return nil, err + } + back, err := gg.LoadImage(a.picfile) + if err != nil { + return nil, err + } + // 避免图片过大,最大 1280*720 + back = imgfactory.Limit(back, 1280, 720) + imgDX := back.Bounds().Dx() + imgDY := back.Bounds().Dy() + canvas := gg.NewContext(imgDX, imgDY) + + // draw background + canvas.DrawImage(back, 0, 0) + + // Create smaller Aero Style boxes + createAeroBox := func(x, y, width, height float64) { + aeroStyle := gg.NewContext(int(width), int(height)) + aeroStyle.DrawRoundedRectangle(0, 0, width, height, 8) + aeroStyle.SetLineWidth(2) + aeroStyle.SetRGBA255(255, 255, 255, 100) + aeroStyle.StrokePreserve() + aeroStyle.SetRGBA255(255, 255, 255, 140) + aeroStyle.Fill() + canvas.DrawImage(aeroStyle.Image(), int(x), int(y)) + } + + // draw aero boxes for text + createAeroBox(20, float64(imgDY-120), 280, 100) // left bottom + createAeroBox(float64(imgDX-272), float64(imgDY-60), 252, 40) // right bottom + + // draw info(name, coin, etc) + hourWord := getHourWord(time.Now()) + canvas.SetRGB255(0, 0, 0) + data, err := file.GetLazyData(text.MaokenFontFile, control.Md5File, true) + if err != nil { + return nil, err + } + if err = canvas.ParseFontFace(data, 24); err != nil { + return nil, err + } + getNameLengthWidth, _ := canvas.MeasureString(a.nickname) + // draw aero box + if getNameLengthWidth > 140 { + createAeroBox(20, 40, 140+getNameLengthWidth, 100) // left top + } else { + createAeroBox(20, 40, 280, 100) // left top + } + + // draw avatar + avatar, _, err := image.Decode(bytes.NewReader(getAvatar)) + if err != nil { + return nil, err + } + avatarf := imgfactory.Size(avatar, 100, 100) + canvas.DrawImage(avatarf.Circle(0).Image(), 30, 20) + + canvas.DrawString(a.nickname, 140, 80) + canvas.DrawStringAnchored(hourWord, 140, 120, 0, 0) + + if err = canvas.ParseFontFace(data, 20); err != nil { + return nil, err + } + canvas.DrawStringAnchored("ATRI币 + "+strconv.Itoa(a.inc), 40, float64(imgDY-90), 0, 0) + canvas.DrawStringAnchored("当前ATRI币:"+strconv.Itoa(a.score), 40, float64(imgDY-60), 0, 0) + canvas.DrawStringAnchored("LEVEL: "+strconv.Itoa(getrank(a.level)), 40, float64(imgDY-30), 0, 0) + + // Draw Info(Time, etc.) + getTime := time.Now().Format("2006-01-02 15:04:05") + canvas.DrawStringAnchored(getTime, float64(imgDX)-146, float64(imgDY)-40, 0.5, 0.5) // time + var nextrankScore int + if a.rank < 10 { + nextrankScore = rankArray[a.rank+1] + } else { + nextrankScore = SCOREMAX + } + nextLevelStyle := strconv.Itoa(a.level) + "/" + strconv.Itoa(nextrankScore) + canvas.DrawStringAnchored(nextLevelStyle, 190, float64(imgDY-30), 0, 0) // time + + // Draw Zerobot-Plugin information + canvas.SetRGB255(255, 255, 255) + if err = canvas.ParseFontFace(data, 20); err != nil { + return nil, err + } + canvas.DrawStringAnchored("Created By Zerobot-Plugin "+banner.Version, float64(imgDX)/2, float64(imgDY)-20, 0.5, 0.5) // zbp + canvas.SetRGB255(0, 0, 0) + canvas.DrawStringAnchored("Created By Zerobot-Plugin "+banner.Version, float64(imgDX)/2-3, float64(imgDY)-19, 0.5, 0.5) // zbp + canvas.SetRGB255(255, 255, 255) + return canvas.Image(), nil +} diff --git a/plugin/score/sign_in.go b/plugin/score/sign_in.go index 49dd44ff2e..02ea2024cc 100644 --- a/plugin/score/sign_in.go +++ b/plugin/score/sign_in.go @@ -1,4 +1,4 @@ -// Package score 签到,答题得分 +// Package score 签到 package score import ( @@ -40,7 +40,7 @@ var ( engine = control.Register("score", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, Brief: "签到", - Help: "- 签到\n- 获得签到背景[@xxx] | 获得签到背景\n- 查看等级排名\n注:为跨群排名\n- 查看我的钱包\n- 查看钱包排名\n注:为本群排行,若群人数太多不建议使用该功能!!!", + Help: "- 签到\n- 获得签到背景[@xxx] | 获得签到背景\n- 设置[默认]签到预设(1~9)\n- 查看等级排名\n注:为跨群排名\n- 查看我的钱包\n- 查看钱包排名\n注:为本群排行,若群人数太多不建议使用该功能!!!", PrivateDataFolder: "score", }) initDef = fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool { @@ -83,6 +83,10 @@ func init() { _ = m.Manager.GetExtra(defKeyID, &key) } } + if !isExist(key) { + ctx.SendChain(message.Text("未找到签到设定:", key)) // 避免签到配置错误造成无图发送,但是已经签到的情况 + return + } uid := ctx.Event.UserID today := time.Now().Format("20060102") // 签到图片 @@ -156,8 +160,14 @@ func init() { ctx.SendChain(message.Text("ERROR: ", err)) return } + case "3": + drawimage, err = drawScore17(&alldata) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } default: - ctx.SendChain(message.Text("未找到签到设定:", key)) + ctx.SendChain(message.Text("未添加签到设定:", key)) return } // done. @@ -274,6 +284,10 @@ func init() { } else { s := ctx.State["regex_matched"].([]string)[1] key := ctx.State["regex_matched"].([]string)[2] + if !isExist(key) { + ctx.SendChain(message.Text("未找到签到设定:", key)) // 避免签到配置错误 + return + } gid := ctx.Event.GroupID if gid == 0 { gid = -ctx.Event.UserID @@ -339,3 +353,10 @@ func initPic(picFile string, uid int64) (avatar []byte, err error) { } return avatar, os.WriteFile(picFile, data, 0644) } + +func isExist(key string) bool { + if key != "1" && key != "2" && key != "3" { + return false + } + return true +} From df4c0438a2f079998fc7fd21394b18ea82aba307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=B2=E5=AE=9D=E5=9D=8F=E5=9D=8F=E5=9D=8F?= <2758988938@qq.com> Date: Thu, 30 Mar 2023 13:13:27 +0800 Subject: [PATCH 31/95] =?UTF-8?q?=E6=8A=96=E5=8A=A8=E6=96=87=E5=AD=97=20(#?= =?UTF-8?q?647)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- plugin/font/main.go | 65 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 61 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 248e1b1dab..6cfbbddb5b 100644 --- a/README.md +++ b/README.md @@ -719,7 +719,7 @@ print("run[CQ:image,file="+j["img"]+"]") `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/font"` - - [x] (用[终末体|终末变体|紫罗兰体|樱酥体|Consolas体|苹方体])渲染文字xxx + - [x] (用[终末体|终末变体|紫罗兰体|樱酥体|Consolas体|苹方体])渲染(抖动)文字xxx
每日运势 diff --git a/plugin/font/main.go b/plugin/font/main.go index d77553c110..06657a8c46 100644 --- a/plugin/font/main.go +++ b/plugin/font/main.go @@ -2,7 +2,17 @@ package font import ( + "bytes" + "image" + "image/color" + "image/gif" + "math/rand" + "strings" + "github.com/FloatTech/floatbox/binary" + "github.com/FloatTech/floatbox/file" + "github.com/FloatTech/gg" + "github.com/FloatTech/imgfactory" ctrl "github.com/FloatTech/zbpctrl" "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" @@ -15,10 +25,10 @@ func init() { control.Register("font", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, Brief: "渲染任意文字到图片", - Help: "- (用[字体])渲染文字xxx\n可选字体: [终末体|终末变体|紫罗兰体|樱酥体|Consolas体|苹方体]", - }).OnRegex(`^(用.+)?渲染文字([\s\S]+)$`).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { + Help: "- (用[字体])渲染(抖动)文字xxx\n可选字体: [终末体|终末变体|紫罗兰体|樱酥体|Consolas体|苹方体]", + }).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] + txt := ctx.State["regex_matched"].([]string)[3] switch fnt { case "用终末体": fnt = text.SyumatuFontFile @@ -35,11 +45,56 @@ func init() { default: fnt = text.FontFile } - b, err := text.RenderToBase64(txt, fnt, 400, 20) + if ctx.State["regex_matched"].([]string)[2] == "" { + 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))) + return + } + nilx, nily := 1.0, 8.0 + s := []*image.NRGBA{} + strlist := strings.Split(txt, "\n") + data, err := file.GetLazyData(fnt, control.Md5File, true) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return } - ctx.SendChain(message.Image("base64://" + binary.BytesToString(b))) + //获得画布预计 + testcov := gg.NewContext(1, 1) + if err = testcov.ParseFontFace(data, 30); err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + //取最长段 + txt = "" + for _, v := range strlist { + if len([]rune(v)) > len([]rune(txt)) { + txt = v + } + } + w, h := testcov.MeasureString(txt) + for i := 0; i < 10; i++ { + cov := gg.NewContext(int(w+float64(len([]rune(txt)))*nilx)+40, int(h+nily)*len(strlist)+30) + cov.SetRGB(1, 1, 1) + cov.Clear() + if err = cov.ParseFontFace(data, 30); err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + cov.SetColor(color.NRGBA{R: 0, G: 0, B: 0, A: 127}) + for k, v := range strlist { + for kk, vv := range []rune(v) { + x, y := cov.MeasureString(string([]rune(v)[:kk])) + cov.DrawString(string(vv), x+float64(rand.Intn(5))+10+nilx, y+float64(rand.Intn(5))+15+float64(k)*(y+nily)) + } + } + s = append(s, imgfactory.Size(cov.Image(), 0, 0).Image()) + } + var buf bytes.Buffer + _ = gif.EncodeAll(&buf, imgfactory.MergeGif(5, s)) + ctx.SendChain(message.ImageBytes(buf.Bytes())) }) } From 52ef28cd6a6c128e9c3d8ab677e200991cdeda75 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 30 Mar 2023 15:24:15 +0800 Subject: [PATCH 32/95] =?UTF-8?q?=F0=9F=8E=A8=20=E6=94=B9=E8=BF=9B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=B7=E5=BC=8F=20(#648)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- plugin/font/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/font/main.go b/plugin/font/main.go index 06657a8c46..97845a5851 100644 --- a/plugin/font/main.go +++ b/plugin/font/main.go @@ -62,13 +62,13 @@ func init() { ctx.SendChain(message.Text("ERROR: ", err)) return } - //获得画布预计 + // 获得画布预计 testcov := gg.NewContext(1, 1) if err = testcov.ParseFontFace(data, 30); err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return } - //取最长段 + // 取最长段 txt = "" for _, v := range strlist { if len([]rune(v)) > len([]rune(txt)) { From 2964986ee5915fc0c08376a682f73e7b0727b31a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Fri, 31 Mar 2023 15:52:52 +0800 Subject: [PATCH 33/95] =?UTF-8?q?font=E5=A2=9E=E5=8A=A0=E6=9B=B4=E5=A4=9A?= =?UTF-8?q?=E5=AD=97=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- go.mod | 8 ++++---- go.sum | 14 ++++++-------- plugin/font/main.go | 14 +++++++++++++- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 6cfbbddb5b..4d1176f5ac 100644 --- a/README.md +++ b/README.md @@ -719,7 +719,8 @@ print("run[CQ:image,file="+j["img"]+"]") `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/font"` - - [x] (用[终末体|终末变体|紫罗兰体|樱酥体|Consolas体|苹方体])渲染(抖动)文字xxx + - [x] (用[终末体|终末变体|紫罗兰体|樱酥体|Consolas体|粗苹方体|未来荧黑体|Gugi体|八丸体|Impact体|猫啃体|苹方体])渲染(抖动)文字xxx +
每日运势 diff --git a/go.mod b/go.mod index 33cdff9c14..00237f423d 100644 --- a/go.mod +++ b/go.mod @@ -4,15 +4,15 @@ go 1.20 require ( github.com/Baidu-AIP/golang-sdk v1.1.1 - github.com/FloatTech/AnimeAPI v1.6.1-0.20230316111643-46d40c9d80e3 - github.com/FloatTech/floatbox v0.0.0-20230325120101-d69494a7cc95 + github.com/FloatTech/AnimeAPI v1.6.1-0.20230331074616-e33f890df71e + github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 github.com/FloatTech/gg v1.1.2 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 github.com/FloatTech/zbpctrl v1.5.3-0.20230316111343-dd078fa43fe3 - github.com/FloatTech/zbputils v1.6.2-0.20230320041820-731f824ff8f4 + github.com/FloatTech/zbputils v1.6.2-0.20230331074541-89a5b4840e92 github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 @@ -24,6 +24,7 @@ require ( github.com/fumiama/go-base16384 v1.6.4 github.com/fumiama/go-registry v0.2.6 github.com/fumiama/gotracemoe v0.0.3 + github.com/fumiama/imgsz v0.0.2 github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565 github.com/fumiama/unibase2n v0.0.0-20221020155353-02876e777430 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 @@ -51,7 +52,6 @@ require ( github.com/faiface/beep v1.1.0 // indirect github.com/fumiama/go-simple-protobuf v0.1.0 // indirect github.com/fumiama/gofastTEA v0.0.10 // indirect - github.com/fumiama/imgsz v0.0.2 // indirect github.com/gabriel-vasile/mimetype v1.0.4 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect diff --git a/go.sum b/go.sum index b541ca8c87..6e274944c0 100644 --- a/go.sum +++ b/go.sum @@ -2,10 +2,10 @@ github.com/Baidu-AIP/golang-sdk v1.1.1 h1:RQsAmgDSAkiq22I6n7XJ2t3afgzFeqjY46FGhv github.com/Baidu-AIP/golang-sdk v1.1.1/go.mod h1:bXnGw7xPeKt8aF7UCELKrV6UZ/46spItONK1RQBQj1Y= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= -github.com/FloatTech/AnimeAPI v1.6.1-0.20230316111643-46d40c9d80e3 h1:SyXS1YXrRuzO3YVCZB/5gSX7vaFbSMwzN+RXLNNKq5M= -github.com/FloatTech/AnimeAPI v1.6.1-0.20230316111643-46d40c9d80e3/go.mod h1:h+22XrJTgcn0m4aM3o1pYo5G0+Mv4v7wW5xvZQ4LabY= -github.com/FloatTech/floatbox v0.0.0-20230325120101-d69494a7cc95 h1:wRcdulvceh55bzjXPtqHsKTTil6ipnvAo+uvf4w9LTI= -github.com/FloatTech/floatbox v0.0.0-20230325120101-d69494a7cc95/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI= +github.com/FloatTech/AnimeAPI v1.6.1-0.20230331074616-e33f890df71e h1:4V7UZyLZKmjXUDtmYFK5+EWIrrkSuN+jHjKXkWsqQ/A= +github.com/FloatTech/AnimeAPI v1.6.1-0.20230331074616-e33f890df71e/go.mod h1:LSJN8VkJXBhyAdOolVNeUptJz6l1TZ+/CfXN1OafyEY= +github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 h1:/eQoMa6Aj3coF5F7yhzZe1+SzX6SItul7MW8//pl18o= +github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI= 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.20230322091809-b0ddbe44b94b h1:VMNci4SWBySdw/6poqF9Dn9zlT5ntTFSJOEEBjRnJ/4= @@ -18,10 +18,8 @@ github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJG github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= github.com/FloatTech/zbpctrl v1.5.3-0.20230316111343-dd078fa43fe3 h1:mCVrTvS2LMNaI2bNA1Gu/B4F5MnfGaTaJClgR6+rhdA= github.com/FloatTech/zbpctrl v1.5.3-0.20230316111343-dd078fa43fe3/go.mod h1:IagyEhY38VcbbQgVRzAM9f9mhaUn90rM5BTPfudtl1g= -github.com/FloatTech/zbputils v1.6.2-0.20230316111555-2d1ec958de04 h1:ovL+7SAPTBCXy6XNRSdJhNvHtbueWCwEb/jtztmizAc= -github.com/FloatTech/zbputils v1.6.2-0.20230316111555-2d1ec958de04/go.mod h1:jUmX4WBgGRcfjGeIobmVao10AHmXtL3gT00qLbx3/yo= -github.com/FloatTech/zbputils v1.6.2-0.20230320041820-731f824ff8f4 h1:OrqldcPSJWnPxZtmkOd9HJmFFD3rl0Qrob89rHHpoXw= -github.com/FloatTech/zbputils v1.6.2-0.20230320041820-731f824ff8f4/go.mod h1:jUmX4WBgGRcfjGeIobmVao10AHmXtL3gT00qLbx3/yo= +github.com/FloatTech/zbputils v1.6.2-0.20230331074541-89a5b4840e92 h1:yp2hYvK+FaaozRG9+KPgoknbdvp5ZbrNHOjMfES0lEM= +github.com/FloatTech/zbputils v1.6.2-0.20230331074541-89a5b4840e92/go.mod h1:3bpENp0t2puKC4Kwp+ksEcMPkuw/8pWI4G6/+/e3jCA= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= diff --git a/plugin/font/main.go b/plugin/font/main.go index 97845a5851..b3b2f61bf5 100644 --- a/plugin/font/main.go +++ b/plugin/font/main.go @@ -25,7 +25,7 @@ func init() { control.Register("font", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, Brief: "渲染任意文字到图片", - Help: "- (用[字体])渲染(抖动)文字xxx\n可选字体: [终末体|终末变体|紫罗兰体|樱酥体|Consolas体|苹方体]", + Help: "- (用[字体])渲染(抖动)文字xxx\n可选字体: [终末体|终末变体|紫罗兰体|樱酥体|Consolas体|粗苹方体|未来荧黑体|Gugi体|八丸体|Impact体|猫啃体|苹方体]", }).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)[3] @@ -40,6 +40,18 @@ func init() { fnt = text.SakuraFontFile case "用Consolas体": fnt = text.ConsolasFontFile + case "用粗苹方体": + fnt = text.BoldFontFile + case "用未来荧黑体": + fnt = text.GlowSansFontFile + case "用Gugi体": + fnt = text.GugiRegularFontFile + case "用八丸体": + fnt = text.HachiMaruPopRegularFontFile + case "用Impact体": + fnt = text.ImpactFontFile + case "用猫啃体": + fnt = text.MaokenFontFile case "用苹方体": fallthrough default: From f1ea658c7d4f98a4aea71ecb243f32bbb46c95d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Fri, 31 Mar 2023 15:53:35 +0800 Subject: [PATCH 34/95] =?UTF-8?q?=F0=9F=94=96=20v1.7.1-beta1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kanban/banner/banner.go | 2 +- winres/winres.json | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kanban/banner/banner.go b/kanban/banner/banner.go index 745d7dad03..b0b0b47a56 100644 --- a/kanban/banner/banner.go +++ b/kanban/banner/banner.go @@ -10,6 +10,6 @@ var Copyright = "© 2020 - 2023 FloatTech" // Banner ... var Banner = "* OneBot + ZeroBot + Golang\n" + - "* Version " + Version + " - 2023-03-25 20:09:29 +0800 CST\n" + + "* Version " + Version + " - 2023-03-31 15:53:05 +0800 CST\n" + "* Copyright " + Copyright + ". All Rights Reserved.\n" + "* Project: https://github.com/FloatTech/ZeroBot-Plugin" diff --git a/winres/winres.json b/winres/winres.json index 67536e6786..1089ff04df 100644 --- a/winres/winres.json +++ b/winres/winres.json @@ -12,7 +12,7 @@ "0409": { "identity": { "name": "ZeroBot-Plugin", - "version": "1.7.1.1769" + "version": "1.7.1.1780" }, "description": "", "minimum-os": "vista", @@ -36,16 +36,16 @@ "#1": { "0000": { "fixed": { - "file_version": "1.7.1.1769", + "file_version": "1.7.1.1780", "product_version": "v1.7.1-beta1", - "timestamp": "2023-03-25T20:09:59+08:00" + "timestamp": "2023-03-31T15:53:17+08:00" }, "info": { "0409": { "Comments": "OneBot plugins based on ZeroBot", "CompanyName": "FloatTech", "FileDescription": "https://github.com/FloatTech/ZeroBot-Plugin", - "FileVersion": "1.7.1.1769", + "FileVersion": "1.7.1.1780", "InternalName": "", "LegalCopyright": "© 2020 - 2023 FloatTech. All Rights Reserved.", "LegalTrademarks": "", From 76dbf5a4b690713d6ed6692efbc264567a74338e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Fri, 31 Mar 2023 15:54:28 +0800 Subject: [PATCH 35/95] =?UTF-8?q?=E6=8F=90=E9=AB=98the=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E6=A6=82=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/thesaurus/chat.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/thesaurus/chat.go b/plugin/thesaurus/chat.go index 190eb013dd..5f011f9c2d 100644 --- a/plugin/thesaurus/chat.go +++ b/plugin/thesaurus/chat.go @@ -146,7 +146,7 @@ const ( func match(l []string, seg *jieba.Segmenter) zero.Rule { return func(ctx *zero.Ctx) bool { - return ctxext.JiebaSimilarity(0.8, seg, func(ctx *zero.Ctx) string { + return ctxext.JiebaSimilarity(0.66, seg, func(ctx *zero.Ctx) string { return ctx.ExtractPlainText() }, l...)(ctx) } From ed26d31326e5f830c9bb3ff5ea182bf6a0973383 Mon Sep 17 00:00:00 2001 From: Jiang-Red <79574799+Jiang-Red@users.noreply.github.com> Date: Tue, 4 Apr 2023 23:32:29 +0800 Subject: [PATCH 36/95] add: score new style (#655) * newstyle * make lint happy --- go.mod | 4 +- go.sum | 4 +- plugin/score/draw.go | 219 ++++++++++++++++++++++++++++++++++++++++ plugin/score/sign_in.go | 117 ++++++++++----------- 4 files changed, 279 insertions(+), 65 deletions(-) diff --git a/go.mod b/go.mod index 00237f423d..bd0279989e 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/Baidu-AIP/golang-sdk v1.1.1 github.com/FloatTech/AnimeAPI v1.6.1-0.20230331074616-e33f890df71e github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 - github.com/FloatTech/gg v1.1.2 + github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 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 @@ -24,7 +24,6 @@ require ( github.com/fumiama/go-base16384 v1.6.4 github.com/fumiama/go-registry v0.2.6 github.com/fumiama/gotracemoe v0.0.3 - github.com/fumiama/imgsz v0.0.2 github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565 github.com/fumiama/unibase2n v0.0.0-20221020155353-02876e777430 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 @@ -52,6 +51,7 @@ require ( github.com/faiface/beep v1.1.0 // indirect github.com/fumiama/go-simple-protobuf v0.1.0 // indirect github.com/fumiama/gofastTEA v0.0.10 // indirect + github.com/fumiama/imgsz v0.0.2 // indirect github.com/gabriel-vasile/mimetype v1.0.4 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect diff --git a/go.sum b/go.sum index 6e274944c0..0acaa553c5 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/FloatTech/AnimeAPI v1.6.1-0.20230331074616-e33f890df71e h1:4V7UZyLZKm github.com/FloatTech/AnimeAPI v1.6.1-0.20230331074616-e33f890df71e/go.mod h1:LSJN8VkJXBhyAdOolVNeUptJz6l1TZ+/CfXN1OafyEY= github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 h1:/eQoMa6Aj3coF5F7yhzZe1+SzX6SItul7MW8//pl18o= github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI= -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/gg v1.1.3-0.20230226151425-6ea91286ba08 h1:dPLeoiTVSBlgls+66EB/UJ2e38BaASmBN5nANaycSBU= +github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08/go.mod h1:uzPzAeT35egARdRuu+1oyjU3CmTwCceoq3Vvje7LpcI= 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= diff --git a/plugin/score/draw.go b/plugin/score/draw.go index f1c724aed2..4709e5499b 100644 --- a/plugin/score/draw.go +++ b/plugin/score/draw.go @@ -3,15 +3,18 @@ package score import ( "bytes" + "errors" "fmt" "image" "image/color" "strconv" + "sync" "time" "github.com/FloatTech/floatbox/file" "github.com/FloatTech/gg" "github.com/FloatTech/imgfactory" + "github.com/FloatTech/rendercard" "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/img/text" "github.com/disintegration/imaging" @@ -269,3 +272,219 @@ func drawScore17(a *scdata) (image.Image, error) { canvas.SetRGB255(255, 255, 255) return canvas.Image(), nil } + +func drawScore17b2(a *scdata) (img image.Image, err error) { + fontdata, err := file.GetLazyData(text.GlowSansFontFile, control.Md5File, false) + if err != nil { + return + } + + getAvatar, err := initPic(a.picfile, a.uid) + if err != nil { + return + } + + back, err := gg.LoadImage(a.picfile) + if err != nil { + return + } + + bx, by := float64(back.Bounds().Dx()), float64(back.Bounds().Dy()) + + sc := 1280 / bx + + colors := gg.TakeColor(back, 3) + + canvas := gg.NewContext(1280, 1280*int(by)/int(bx)) + + cw, ch := float64(canvas.W()), float64(canvas.H()) + + sch := ch * 6 / 10 + + var blurback, scbackimg, backshadowimg, avatarimg, avatarbackimg, avatarshadowimg, whitetext, blacktext image.Image + var wg sync.WaitGroup + wg.Add(8) + + go func() { + defer wg.Done() + scback := gg.NewContext(canvas.W(), canvas.H()) + scback.ScaleAbout(sc, sc, cw/2, ch/2) + scback.DrawImageAnchored(back, canvas.W()/2, canvas.H()/2, 0.5, 0.5) + scback.Identity() + + go func() { + defer wg.Done() + blurback = imaging.Blur(scback.Image(), 20) + }() + + scbackimg = rendercard.Fillet(scback.Image(), 12) + }() + + go func() { + defer wg.Done() + pureblack := gg.NewContext(canvas.W(), canvas.H()) + pureblack.SetRGBA255(0, 0, 0, 255) + pureblack.Clear() + + shadow := gg.NewContext(canvas.W(), canvas.H()) + shadow.ScaleAbout(0.6, 0.6, cw-cw/3, ch/2) + shadow.DrawImageAnchored(pureblack.Image(), canvas.W()-canvas.W()/3, canvas.H()/2, 0.5, 0.5) + shadow.Identity() + + backshadowimg = imaging.Blur(shadow.Image(), 8) + }() + + aw, ah := (ch-sch)/2/2/2*3, (ch-sch)/2/2/2*3 + + go func() { + defer wg.Done() + avatar, _, err := image.Decode(bytes.NewReader(getAvatar)) + if err != nil { + return + } + + isc := (ch - sch) / 2 / 2 / 2 * 3 / float64(avatar.Bounds().Dy()) + + scavatar := gg.NewContext(int(aw), int(ah)) + + scavatar.ScaleAbout(isc, isc, aw/2, ah/2) + scavatar.DrawImageAnchored(avatar, scavatar.W()/2, scavatar.H()/2, 0.5, 0.5) + scavatar.Identity() + + avatarimg = rendercard.Fillet(scavatar.Image(), 8) + }() + + err = canvas.ParseFontFace(fontdata, (ch-sch)/2/2/2) + if err != nil { + return + } + namew, _ := canvas.MeasureString(a.nickname) + + go func() { + defer wg.Done() + avatarshadowimg = imaging.Blur(customrectangle(cw, ch, aw, ah, namew, color.Black), 8) + }() + + go func() { + defer wg.Done() + avatarbackimg = customrectangle(cw, ch, aw, ah, namew, colors[0]) + }() + + go func() { + defer wg.Done() + whitetext, err = customtext(a, fontdata, cw, ch, aw, color.White) + if err != nil { + return + } + }() + + go func() { + defer wg.Done() + blacktext, err = customtext(a, fontdata, cw, ch, aw, color.Black) + if err != nil { + return + } + }() + + wg.Wait() + if scbackimg == nil || backshadowimg == nil || avatarimg == nil || avatarbackimg == nil || avatarshadowimg == nil || whitetext == nil || blacktext == nil { + err = errors.New("图片渲染失败") + return + } + + canvas.DrawImageAnchored(blurback, canvas.W()/2, canvas.H()/2, 0.5, 0.5) + + canvas.DrawImage(backshadowimg, 0, 0) + + canvas.ScaleAbout(0.6, 0.6, cw-cw/3, ch/2) + canvas.DrawImageAnchored(scbackimg, canvas.W()-canvas.W()/3, canvas.H()/2, 0.5, 0.5) + canvas.Identity() + + canvas.DrawImage(avatarshadowimg, 0, 0) + canvas.DrawImage(avatarbackimg, 0, 0) + canvas.DrawImageAnchored(avatarimg, int((ch-sch)/2/2), int((ch-sch)/2/2), 0.5, 0.5) + + canvas.DrawImage(blacktext, 2, 2) + canvas.DrawImage(whitetext, 0, 0) + + img = canvas.Image() + return +} + +func customrectangle(cw, ch, aw, ah, namew float64, rtgcolor color.Color) (img image.Image) { + canvas := gg.NewContext(int(cw), int(ch)) + sch := ch * 6 / 10 + canvas.DrawRoundedRectangle((ch-sch)/2/2-aw/2-aw/40, (ch-sch)/2/2-aw/2-ah/40, aw+aw/40*2, ah+ah/40*2, 8) + canvas.SetColor(rtgcolor) + canvas.Fill() + canvas.DrawRoundedRectangle((ch-sch)/2/2, (ch-sch)/2/2-ah/4, aw/2+aw/40*5+namew, ah/2, 8) + canvas.Fill() + + img = canvas.Image() + return +} + +func customtext(a *scdata, fontdata []byte, cw, ch, aw float64, textcolor color.Color) (img image.Image, err error) { + canvas := gg.NewContext(int(cw), int(ch)) + canvas.SetColor(textcolor) + scw, sch := cw*6/10, ch*6/10 + err = canvas.ParseFontFace(fontdata, (ch-sch)/2/2/2) + if err != nil { + return + } + canvas.DrawStringAnchored(a.nickname, (ch-sch)/2/2+aw/2+aw/40*2, (ch-sch)/2/2, 0, 0.5) + err = canvas.ParseFontFace(fontdata, (ch-sch)/2/2/3*2) + if err != nil { + return + } + canvas.DrawStringAnchored(time.Now().Format("2006/01/02"), cw-cw/6, ch/2-sch/2-canvas.FontHeight(), 0.5, 0.5) + + err = canvas.ParseFontFace(fontdata, (ch-sch)/2/2/2) + if err != nil { + return + } + nextrankScore := 0 + if a.rank < 10 { + nextrankScore = rankArray[a.rank+1] + } else { + nextrankScore = SCOREMAX + } + nextLevelStyle := strconv.Itoa(a.level) + "/" + strconv.Itoa(nextrankScore) + + canvas.DrawStringAnchored("Level "+strconv.Itoa(a.rank), cw/3*2-scw/2, ch/2+sch/2+canvas.FontHeight(), 0, 0.5) + canvas.DrawStringAnchored(nextLevelStyle, cw/3*2+scw/2, ch/2+sch/2+canvas.FontHeight(), 1, 0.5) + + err = canvas.ParseFontFace(fontdata, (ch-sch)/2/2/3) + if err != nil { + return + } + + canvas.DrawStringAnchored("Create By ZeroBot-Plugin "+banner.Version, 0+4, ch, 0, -0.5) + + err = canvas.ParseFontFace(fontdata, (ch-sch)/2/5*3) + if err != nil { + return + } + + tempfh := canvas.FontHeight() + + canvas.DrawStringAnchored(getHourWord(time.Now()), ((cw-scw)-(cw/3-scw/2))/8, (ch-sch)/2+sch/4, 0, 0.5) + + err = canvas.ParseFontFace(fontdata, (ch-sch)/2/5) + if err != nil { + return + } + + canvas.DrawStringAnchored("ATRI币 + "+strconv.Itoa(a.inc), ((cw-scw)-(cw/3-scw/2))/8, (ch-sch)/2+sch/4+tempfh, 0, 0.5) + canvas.DrawStringAnchored("EXP + 1", ((cw-scw)-(cw/3-scw/2))/8, (ch-sch)/2+sch/4+tempfh+canvas.FontHeight(), 0, 1) + + err = canvas.ParseFontFace(fontdata, (ch-sch)/2/4) + if err != nil { + return + } + + canvas.DrawStringAnchored("你有 "+strconv.Itoa(a.score)+" 枚ATRI币", ((cw-scw)-(cw/3-scw/2))/8, (ch-sch)/2+sch/4*3, 0, 0.5) + + img = canvas.Image() + return +} diff --git a/plugin/score/sign_in.go b/plugin/score/sign_in.go index 02ea2024cc..8ce971a8c4 100644 --- a/plugin/score/sign_in.go +++ b/plugin/score/sign_in.go @@ -7,6 +7,7 @@ import ( "math/rand" "os" "strconv" + "strings" "time" "github.com/FloatTech/AnimeAPI/bilibili" @@ -54,37 +55,53 @@ var ( } return true }) + stylemap = map[string]func(a *scdata) (image.Image, error){ + "1": drawScore15, + "2": drawScore16, + "3": drawScore17, + "4": drawScore17b2, + } ) func init() { cachePath := engine.DataFolder() + "cache/" go func() { - _ = os.RemoveAll(cachePath) - err := os.MkdirAll(cachePath, 0755) - if err != nil { - panic(err) + ok := file.IsExist(cachePath) + if !ok { + err := os.MkdirAll(cachePath, 0777) + if err != nil { + panic(err) + } + return + } + files, err := os.ReadDir(cachePath) + if err == nil { + for _, f := range files { + if !strings.Contains(f.Name(), time.Now().Format("20060102")) { + _ = os.Remove(cachePath + f.Name()) + } + } } sdb = initialize(engine.DataFolder() + "score.db") }() engine.OnRegex(`^签到\s?(\d*)$`, initDef).Limit(ctxext.LimitByUser).SetBlock(true).Handle(func(ctx *zero.Ctx) { // 选择key - var key string + key := ctx.State["regex_matched"].([]string)[1] gid := ctx.Event.GroupID if gid < 0 { // 个人用户设为负数 gid = -ctx.Event.UserID } - if ctx.State["regex_matched"].([]string)[1] != "" { - key = ctx.State["regex_matched"].([]string)[1] - } else { + if key == "" { m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) _ = m.Manager.GetExtra(gid, &key) if key == "" { _ = m.Manager.GetExtra(defKeyID, &key) } } - if !isExist(key) { - ctx.SendChain(message.Text("未找到签到设定:", key)) // 避免签到配置错误造成无图发送,但是已经签到的情况 + drawfunc, ok := stylemap[key] + if !ok { + ctx.SendChain(message.Text("ERROR: 未找到签到设定: ", key)) return } uid := ctx.Event.UserID @@ -131,12 +148,14 @@ func init() { // 更新钱包 rank := getrank(level) add := 1 + rand.Intn(10) + rank*5 // 等级越高获得的钱越高 - err = wallet.InsertWalletOf(uid, add) - if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return - } - alldata := scdata{ + go func() { + err = wallet.InsertWalletOf(uid, add) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + }() + alldata := &scdata{ drawedfile: drawedFile, picfile: picFile, uid: uid, @@ -146,28 +165,9 @@ func init() { level: level, rank: rank, } - var drawimage image.Image - switch key { - case "1": - drawimage, err = drawScore16(&alldata) - if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return - } - case "2": - drawimage, err = drawScore15(&alldata) - if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return - } - case "3": - drawimage, err = drawScore17(&alldata) - if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return - } - default: - ctx.SendChain(message.Text("未添加签到设定:", key)) + drawimage, err := drawfunc(alldata) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) return } // done. @@ -182,7 +182,7 @@ func init() { return } _, err = imgfactory.WriteTo(drawimage, f) - _ = f.Close() + defer f.Close() if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return @@ -204,7 +204,9 @@ func init() { ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("请先签到!")) return } - ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + picFile)) + if id := ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + picFile)); id.ID() == 0 { + ctx.SendChain(message.Text("ERROR: 消息发送失败, 账号可能被风控")) + } }) engine.OnFullMatch("查看等级排名", zero.OnlyGroup).Limit(ctxext.LimitByGroup).SetBlock(true). Handle(func(ctx *zero.Ctx) { @@ -279,13 +281,13 @@ func init() { ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile)) }) engine.OnRegex(`^设置(默认)?签到预设\s?(\d*)$`, zero.SuperUserPermission).Limit(ctxext.LimitByUser).SetBlock(true).Handle(func(ctx *zero.Ctx) { - if ctx.State["regex_matched"].([]string)[2] == "" { - ctx.SendChain(message.Text("设置失败,数据为空")) + if key := ctx.State["regex_matched"].([]string)[2]; key == "" { + ctx.SendChain(message.Text("设置失败, 数据为空")) } else { s := ctx.State["regex_matched"].([]string)[1] - key := ctx.State["regex_matched"].([]string)[2] - if !isExist(key) { - ctx.SendChain(message.Text("未找到签到设定:", key)) // 避免签到配置错误 + _, ok := stylemap[key] + if !ok { + ctx.SendChain(message.Text("ERROR: 未找到签到设定: ", key)) // 避免签到配置错误 return } gid := ctx.Event.GroupID @@ -300,7 +302,7 @@ func init() { ctx.SendChain(message.Text("ERROR: ", err)) return } - ctx.SendChain(message.Text("设置成功,当前", s, "预设为:", key)) + ctx.SendChain(message.Text("设置成功, 当前", s, "预设为:", key)) } }) } @@ -335,28 +337,21 @@ func getrank(count int) int { } func initPic(picFile string, uid int64) (avatar []byte, err error) { + defer process.SleepAbout1sTo2s() + avatar, err = web.GetData("http://q4.qlogo.cn/g?b=qq&nk=" + strconv.FormatInt(uid, 10) + "&s=640") + if err != nil { + return + } if file.IsExist(picFile) { - return nil, nil + return } - defer process.SleepAbout1sTo2s() url, err := bilibili.GetRealURL(backgroundURL) if err != nil { - return nil, err + return } data, err := web.RequestDataWith(web.NewDefaultClient(), url, "", referer, "", nil) if err != nil { - return nil, err - } - avatar, err = web.GetData("http://q4.qlogo.cn/g?b=qq&nk=" + strconv.FormatInt(uid, 10) + "&s=640") - if err != nil { - return nil, err + return } return avatar, os.WriteFile(picFile, data, 0644) } - -func isExist(key string) bool { - if key != "1" && key != "2" && key != "3" { - return false - } - return true -} From e8b61b39f02f0dc365c0a5e4697515bb29e5616f Mon Sep 17 00:00:00 2001 From: Sunist <46150583+sunist-c@users.noreply.github.com> Date: Thu, 6 Apr 2023 19:28:14 +0800 Subject: [PATCH 37/95] HowToCook function Integration (#650) --- README.md | 10 ++++ main.go | 1 + plugin/dish/dish.go | 114 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 plugin/dish/dish.go diff --git a/README.md b/README.md index 4d1176f5ac..619054faba 100644 --- a/README.md +++ b/README.md @@ -651,6 +651,16 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] 教你一篇小作文[作文] +
+
+ 程序员做饭指南 + + `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/dish"` + + - [x] 怎么做 | 烹饪[菜名] + + - [x] 随机菜谱 | 随便做点菜 +
多功能抽签 diff --git a/main.go b/main.go index 0ac64b99e8..2086330ea2 100644 --- a/main.go +++ b/main.go @@ -82,6 +82,7 @@ import ( _ "github.com/FloatTech/ZeroBot-Plugin/plugin/dailynews" // 今日早报 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/danbooru" // DeepDanbooru二次元图标签识别 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/diana" // 嘉心糖发病 + _ "github.com/FloatTech/ZeroBot-Plugin/plugin/dish" // 程序员做饭指南 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/drawlots" // 多功能抽签 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/dress" // 女装 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/drift_bottle" // 漂流瓶 diff --git a/plugin/dish/dish.go b/plugin/dish/dish.go new file mode 100644 index 0000000000..72a7f75ab0 --- /dev/null +++ b/plugin/dish/dish.go @@ -0,0 +1,114 @@ +// Package dish 程序员做饭指南zbp版,数据来源Anduin2017/HowToCook +package dish + +import ( + "fmt" + "github.com/sirupsen/logrus" + "strings" + "time" + + sql "github.com/FloatTech/sqlite" + ctrl "github.com/FloatTech/zbpctrl" + zero "github.com/wdvxdr1123/ZeroBot" + + "github.com/FloatTech/zbputils/control" + "github.com/FloatTech/zbputils/ctxext" + "github.com/wdvxdr1123/ZeroBot/message" +) + +type dish struct { + ID uint32 `db:"id"` + Name string `db:"name"` + Materials string `db:"materials"` + Steps string `db:"steps"` +} + +var ( + db = &sql.Sqlite{} + initialized = false +) + +func init() { + en := control.Register("dish", &ctrl.Options[*zero.Ctx]{ + DisableOnDefault: false, + Brief: "程序员做饭指南", + Help: "-怎么做[xxx]|烹饪[xxx]|随机菜谱|随便做点菜", + PublicDataFolder: "Dish", + }) + + db.DBPath = en.DataFolder() + "dishes.db" + + if _, err := en.GetLazyData("dishes.db", true); err != nil { + logrus.Warnln("[dish]获取菜谱数据库文件失败") + } else if err = db.Open(time.Hour * 24); err != nil { + logrus.Warnln("[dish]连接菜谱数据库失败") + } else if err = db.Create("dishes", &dish{}); err != nil { + logrus.Warnln("[dish]同步菜谱数据表失败") + } else if count, err := db.Count("dishes"); err != nil { + logrus.Warnln("[dish]统计菜谱数据失败") + } else { + logrus.Infoln("[dish]加载", count, "条菜谱") + initialized = true + } + + if !initialized { + logrus.Warnln("[dish]插件未能成功初始化") + } + + en.OnPrefixGroup([]string{"怎么做", "烹饪"}).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { + if !initialized { + ctx.SendChain(message.Text("客官,本店暂未开业")) + return + } + + name := ctx.NickName() + dishName := ctx.State["args"].(string) + + if dishName == "" { + return + } + + if strings.Contains(dishName, "'") || + strings.Contains(dishName, "\"") || + strings.Contains(dishName, "\\") || + strings.Contains(dishName, ";") { + return + } + + var d dish + if err := db.Find("dishes", &d, fmt.Sprintf("WHERE name like %%%s%%", dishName)); err != nil { + return + } + + ctx.SendChain(message.Text(fmt.Sprintf( + "已为客官%s找到%s的做法辣!\n"+ + "原材料:%s\n"+ + "步骤:\n"+ + "%s", + name, dishName, d.Materials, d.Steps), + )) + }) + + en.OnPrefixGroup([]string{"随机菜谱", "随便做点菜"}).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { + if !initialized { + ctx.SendChain(message.Text("客官,本店暂未开业")) + return + } + + name := ctx.NickName() + var d dish + if err := db.Pick("dishes", &d); err != nil { + ctx.SendChain(message.Text("小店好像出错了,暂时端不出菜来惹")) + logrus.Warnln("[dish]随机菜谱请求出错:" + err.Error()) + return + } + + ctx.SendChain(message.Text(fmt.Sprintf( + "已为客官%s送上%s的做法:\n"+ + "原材料:%s\n"+ + "步骤:\n"+ + "%s", + name, d.Name, d.Materials, d.Steps), + )) + }) +} From 573c942a9d734a1b2dba68eede2a05c7b86cac55 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 6 Apr 2023 19:43:24 +0800 Subject: [PATCH 38/95] =?UTF-8?q?=F0=9F=8E=A8=20=E6=94=B9=E8=BF=9B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=B7=E5=BC=8F=20(#657)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- plugin/dish/dish.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/dish/dish.go b/plugin/dish/dish.go index 72a7f75ab0..714715f17b 100644 --- a/plugin/dish/dish.go +++ b/plugin/dish/dish.go @@ -3,10 +3,11 @@ package dish import ( "fmt" - "github.com/sirupsen/logrus" "strings" "time" + "github.com/sirupsen/logrus" + sql "github.com/FloatTech/sqlite" ctrl "github.com/FloatTech/zbpctrl" zero "github.com/wdvxdr1123/ZeroBot" From f1e49dc02e449ef355e4af6efc5f125b369545a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Fri, 7 Apr 2023 17:52:55 +0800 Subject: [PATCH 39/95] =?UTF-8?q?remove=20=E6=8B=9F=E5=A3=B0=E9=B8=9F,=20a?= =?UTF-8?q?dd=20TTSCN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data | 2 +- go.mod | 10 +++++----- go.sum | 16 ++++++++-------- plugin/ai_reply/ai_tts.go | 39 ++++++++++++++++++++++++++++----------- plugin/ai_reply/main.go | 4 ++-- 5 files changed, 44 insertions(+), 27 deletions(-) diff --git a/data b/data index 541c1dec93..1e64e7cf82 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit 541c1dec93f480d295fc5463814a94c014a53512 +Subproject commit 1e64e7cf82a24b6d0a231f3cfd474dcbd4d52781 diff --git a/go.mod b/go.mod index bd0279989e..c131aa02a3 100644 --- a/go.mod +++ b/go.mod @@ -4,15 +4,15 @@ go 1.20 require ( github.com/Baidu-AIP/golang-sdk v1.1.1 - github.com/FloatTech/AnimeAPI v1.6.1-0.20230331074616-e33f890df71e + github.com/FloatTech/AnimeAPI v1.6.1-0.20230407094656-35c90555daf6 github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 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/sqlite v1.6.2 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b - github.com/FloatTech/zbpctrl v1.5.3-0.20230316111343-dd078fa43fe3 - github.com/FloatTech/zbputils v1.6.2-0.20230331074541-89a5b4840e92 + github.com/FloatTech/zbpctrl v1.5.3-0.20230406055807-cb5f5edad2c7 + github.com/FloatTech/zbputils v1.6.2-0.20230407083549-931d7968df13 github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 @@ -24,6 +24,7 @@ require ( github.com/fumiama/go-base16384 v1.6.4 github.com/fumiama/go-registry v0.2.6 github.com/fumiama/gotracemoe v0.0.3 + github.com/fumiama/imgsz v0.0.2 github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565 github.com/fumiama/unibase2n v0.0.0-20221020155353-02876e777430 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 @@ -51,7 +52,6 @@ require ( github.com/faiface/beep v1.1.0 // indirect github.com/fumiama/go-simple-protobuf v0.1.0 // indirect github.com/fumiama/gofastTEA v0.0.10 // indirect - github.com/fumiama/imgsz v0.0.2 // indirect github.com/gabriel-vasile/mimetype v1.0.4 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect diff --git a/go.sum b/go.sum index 0acaa553c5..87fba9b652 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/Baidu-AIP/golang-sdk v1.1.1 h1:RQsAmgDSAkiq22I6n7XJ2t3afgzFeqjY46FGhv github.com/Baidu-AIP/golang-sdk v1.1.1/go.mod h1:bXnGw7xPeKt8aF7UCELKrV6UZ/46spItONK1RQBQj1Y= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= -github.com/FloatTech/AnimeAPI v1.6.1-0.20230331074616-e33f890df71e h1:4V7UZyLZKmjXUDtmYFK5+EWIrrkSuN+jHjKXkWsqQ/A= -github.com/FloatTech/AnimeAPI v1.6.1-0.20230331074616-e33f890df71e/go.mod h1:LSJN8VkJXBhyAdOolVNeUptJz6l1TZ+/CfXN1OafyEY= +github.com/FloatTech/AnimeAPI v1.6.1-0.20230407094656-35c90555daf6 h1:hS5U1Xz6JtVyGdXOl50j9ubQxP446+TjIAhaGapGUpU= +github.com/FloatTech/AnimeAPI v1.6.1-0.20230407094656-35c90555daf6/go.mod h1:UnCPjtpIzpNBZ02yeGYp+oYVxgoi5aF2yAK2bkOVxtI= github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 h1:/eQoMa6Aj3coF5F7yhzZe1+SzX6SItul7MW8//pl18o= github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI= github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 h1:dPLeoiTVSBlgls+66EB/UJ2e38BaASmBN5nANaycSBU= @@ -12,14 +12,14 @@ github.com/FloatTech/imgfactory v0.2.2-0.20230322091809-b0ddbe44b94b h1:VMNci4SW 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= -github.com/FloatTech/sqlite v1.5.7/go.mod h1:zFbHzRfB+CJ+VidfjuVbrcin3DAz283F7hF1hIeHzpY= +github.com/FloatTech/sqlite v1.6.2 h1:FytbExjpvYalZxxITtmSenHiPGLPUvlz47LY/P0SCCw= +github.com/FloatTech/sqlite v1.6.2/go.mod h1:zFbHzRfB+CJ+VidfjuVbrcin3DAz283F7hF1hIeHzpY= github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJGLDNIdRX3BI546D3O7k7vrVueZw= github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= -github.com/FloatTech/zbpctrl v1.5.3-0.20230316111343-dd078fa43fe3 h1:mCVrTvS2LMNaI2bNA1Gu/B4F5MnfGaTaJClgR6+rhdA= -github.com/FloatTech/zbpctrl v1.5.3-0.20230316111343-dd078fa43fe3/go.mod h1:IagyEhY38VcbbQgVRzAM9f9mhaUn90rM5BTPfudtl1g= -github.com/FloatTech/zbputils v1.6.2-0.20230331074541-89a5b4840e92 h1:yp2hYvK+FaaozRG9+KPgoknbdvp5ZbrNHOjMfES0lEM= -github.com/FloatTech/zbputils v1.6.2-0.20230331074541-89a5b4840e92/go.mod h1:3bpENp0t2puKC4Kwp+ksEcMPkuw/8pWI4G6/+/e3jCA= +github.com/FloatTech/zbpctrl v1.5.3-0.20230406055807-cb5f5edad2c7 h1:ii/HjRAAH1Ot1mwg4r+kabiI0H8EZ/PwTZryEbN4Jvg= +github.com/FloatTech/zbpctrl v1.5.3-0.20230406055807-cb5f5edad2c7/go.mod h1:IagyEhY38VcbbQgVRzAM9f9mhaUn90rM5BTPfudtl1g= +github.com/FloatTech/zbputils v1.6.2-0.20230407083549-931d7968df13 h1:7HX4TP7/ihnoCvD/XyM2nxi4EI0wClQB7SSDCSgfx8I= +github.com/FloatTech/zbputils v1.6.2-0.20230407083549-931d7968df13/go.mod h1:iPlPghAE6SSDBZPHA6ZiPyspfeVDNQqtfLDkftHlD4I= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= diff --git a/plugin/ai_reply/ai_tts.go b/plugin/ai_reply/ai_tts.go index 1b02e5e270..365337f69a 100644 --- a/plugin/ai_reply/ai_tts.go +++ b/plugin/ai_reply/ai_tts.go @@ -12,28 +12,28 @@ import ( "github.com/FloatTech/AnimeAPI/tts" "github.com/FloatTech/AnimeAPI/tts/baidutts" "github.com/FloatTech/AnimeAPI/tts/genshin" - "github.com/FloatTech/AnimeAPI/tts/mockingbird" + "github.com/FloatTech/AnimeAPI/tts/ttscn" ctrl "github.com/FloatTech/zbpctrl" "github.com/FloatTech/zbputils/control" ) // 数据结构: [4 bits] [4 bits] [8 bits] [8 bits] -// [拟声鸟模式] [百度模式] [tts模式] [回复模式] +// [ttscn模式] [百度模式] [tts模式] [回复模式] // defaultttsindexkey // 数据结构: [4 bits] [4 bits] [8 bits] -// [拟声鸟模式] [百度模式] [tts模式] +// [ttscn模式] [百度模式] [tts模式] -// [tts模式]: 0~63 genshin 64 baidu 65 mockingbird +// [tts模式]: 0~63 genshin 64 baidu 65 ttscn const ( lastgsttsindex = 63 + iota baiduttsindex - mockingbirdttsindex + ttscnttsindex ) // extrattsname is the tts other than genshin vits -var extrattsname = []string{"百度", "拟声鸟"} +var extrattsname = []string{"百度", "TTSCN"} const ( defaultttsindexkey = -2905 @@ -148,7 +148,7 @@ func newttsmode() *ttsmode { if ok { index := m.GetData(defaultttsindexkey) msk := index & 0xff - if msk >= 0 && (msk < int64(len(genshin.SoundList)) || msk == baiduttsindex || msk == mockingbirdttsindex) { + if msk >= 0 && (msk < int64(len(genshin.SoundList)) || msk == baiduttsindex || msk == ttscnttsindex) { t.mode.Store(defaultttsindexkey, index) } } @@ -191,7 +191,7 @@ func (t *ttsmode) setSoundMode(ctx *zero.Ctx, name string, baiduper, mockingsynt case extrattsname[0]: index = baiduttsindex case extrattsname[1]: - index = mockingbirdttsindex + index = ttscnttsindex default: return errors.New("语音人物" + name + "未注册index") } @@ -212,7 +212,7 @@ func (t *ttsmode) getSoundMode(ctx *zero.Ctx) (tts.TTS, error) { i = m.GetData(gid) >> 8 } m := i & 0xff - if m < 0 || (m >= int64(len(genshin.SoundList)) && m != baiduttsindex && m != mockingbirdttsindex) { + if m < 0 || (m >= int64(len(genshin.SoundList)) && m != baiduttsindex && m != ttscnttsindex) { i, _ = t.mode.Load(defaultttsindexkey) m = i & 0xff } @@ -224,7 +224,24 @@ func (t *ttsmode) getSoundMode(ctx *zero.Ctx) (tts.TTS, error) { ins = baidutts.NewBaiduTTS(int(i&0x0f00) >> 8) case extrattsname[1]: var err error - ins, err = mockingbird.NewMockingBirdTTS(int(i&0xf000) >> 12) + ins, err = ttscn.NewTTSCN("中文(普通话,简体)", [...]string{ + "晓晓(女 - 年轻人)", + "云扬(男 - 年轻人)", + "晓辰(女 - 年轻人 - 抖音热门)", + "晓涵(女 - 年轻人)", + "晓墨(女 - 年轻人)", + "晓秋(女 - 中年人)", + "晓睿(女 - 老年)", + "晓双(女 - 儿童)", + "晓萱(女 - 年轻人)", + "晓颜(女 - 年轻人)", + "晓悠(女 - 儿童)", + "云希(男 - 年轻人 - 抖音热门)", + "云野(男 - 中年人)", + "晓梦(女 - 年轻人)", + "晓伊(女 - 儿童)", + "晓甄(女 - 年轻人)", + }[int(i&0xf000)>>12], ttscn.KBRates[0]) if err != nil { return nil, err } @@ -268,7 +285,7 @@ func (t *ttsmode) setDefaultSoundMode(name string, baiduper, mockingsynt int) er case extrattsname[0]: index = baiduttsindex case extrattsname[1]: - index = mockingbirdttsindex + index = ttscnttsindex default: return errors.New("语音人物" + name + "未注册index") } diff --git a/plugin/ai_reply/main.go b/plugin/ai_reply/main.go index c58faadafb..f00b09b8b8 100644 --- a/plugin/ai_reply/main.go +++ b/plugin/ai_reply/main.go @@ -26,8 +26,8 @@ func init() { // 插件主体 DisableOnDefault: true, Brief: "人工智能语音回复", Help: "- @Bot 任意文本(任意一句话回复)\n" + - "- 设置语音模式[原神人物/百度/拟声鸟] 数字(百度/拟声鸟模式)\n" + - "- 设置默认语音模式[原神人物/百度/拟声鸟] 数字(百度/拟声鸟模式)\n" + + "- 设置语音模式[原神人物/百度/ttscn] 数字(百度/ttscn模式)\n" + + "- 设置默认语音模式[原神人物/百度/ttscn] 数字(百度/ttscn模式)\n" + "- 恢复成默认语音模式\n" + "- 设置原神语音 api key xxxxxx (key请加开发群获得)\n" + "当前适用的原神人物含有以下:\n" + list(genshin.SoundList[:], 5), From 635eb9832a7783e373575beff0970cfd95bdb3de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Fri, 7 Apr 2023 17:56:49 +0800 Subject: [PATCH 40/95] fix help --- plugin/ai_reply/ai_tts.go | 38 ++++++++++++++++++++------------------ plugin/ai_reply/main.go | 7 ++++--- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/plugin/ai_reply/ai_tts.go b/plugin/ai_reply/ai_tts.go index 365337f69a..f84eb7febb 100644 --- a/plugin/ai_reply/ai_tts.go +++ b/plugin/ai_reply/ai_tts.go @@ -35,6 +35,25 @@ const ( // extrattsname is the tts other than genshin vits var extrattsname = []string{"百度", "TTSCN"} +var ttscnspeakers = [...]string{ + "晓晓(女 - 年轻人)", + "云扬(男 - 年轻人)", + "晓辰(女 - 年轻人 - 抖音热门)", + "晓涵(女 - 年轻人)", + "晓墨(女 - 年轻人)", + "晓秋(女 - 中年人)", + "晓睿(女 - 老年)", + "晓双(女 - 儿童)", + "晓萱(女 - 年轻人)", + "晓颜(女 - 年轻人)", + "晓悠(女 - 儿童)", + "云希(男 - 年轻人 - 抖音热门)", + "云野(男 - 中年人)", + "晓梦(女 - 年轻人)", + "晓伊(女 - 儿童)", + "晓甄(女 - 年轻人)", +} + const ( defaultttsindexkey = -2905 gsapikeyextragrp = -1 @@ -224,24 +243,7 @@ func (t *ttsmode) getSoundMode(ctx *zero.Ctx) (tts.TTS, error) { ins = baidutts.NewBaiduTTS(int(i&0x0f00) >> 8) case extrattsname[1]: var err error - ins, err = ttscn.NewTTSCN("中文(普通话,简体)", [...]string{ - "晓晓(女 - 年轻人)", - "云扬(男 - 年轻人)", - "晓辰(女 - 年轻人 - 抖音热门)", - "晓涵(女 - 年轻人)", - "晓墨(女 - 年轻人)", - "晓秋(女 - 中年人)", - "晓睿(女 - 老年)", - "晓双(女 - 儿童)", - "晓萱(女 - 年轻人)", - "晓颜(女 - 年轻人)", - "晓悠(女 - 儿童)", - "云希(男 - 年轻人 - 抖音热门)", - "云野(男 - 中年人)", - "晓梦(女 - 年轻人)", - "晓伊(女 - 儿童)", - "晓甄(女 - 年轻人)", - }[int(i&0xf000)>>12], ttscn.KBRates[0]) + ins, err = ttscn.NewTTSCN("中文(普通话,简体)", ttscnspeakers[int(i&0xf000)>>12], ttscn.KBRates[0]) if err != nil { return nil, err } diff --git a/plugin/ai_reply/main.go b/plugin/ai_reply/main.go index f00b09b8b8..58e583e45f 100644 --- a/plugin/ai_reply/main.go +++ b/plugin/ai_reply/main.go @@ -26,11 +26,12 @@ func init() { // 插件主体 DisableOnDefault: true, Brief: "人工智能语音回复", Help: "- @Bot 任意文本(任意一句话回复)\n" + - "- 设置语音模式[原神人物/百度/ttscn] 数字(百度/ttscn模式)\n" + - "- 设置默认语音模式[原神人物/百度/ttscn] 数字(百度/ttscn模式)\n" + + "- 设置语音模式[原神人物/百度/TTSCN] 数字(百度/TTSCN说话人)\n" + + "- 设置默认语音模式[原神人物/百度/TTSCN] 数字(百度/TTSCN说话人)\n" + "- 恢复成默认语音模式\n" + "- 设置原神语音 api key xxxxxx (key请加开发群获得)\n" + - "当前适用的原神人物含有以下:\n" + list(genshin.SoundList[:], 5), + "当前适用的原神人物含有以下: \n" + list(genshin.SoundList[:], 5) + + "\n当前适用的TTSCN人物含有以下(以数字顺序代表): \n" + list(ttscnspeakers[:], 5), }) enr := control.Register("aireply", &ctrl.Options[*zero.Ctx]{ From 5c8ead8b1d0c49001f4578d74fdf48ac7bddddf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sat, 8 Apr 2023 17:18:36 +0800 Subject: [PATCH 41/95] fix extra --- README.md | 2 +- go.mod | 4 +- go.sum | 8 ++-- plugin/ai_reply/ai_tts.go | 76 ++++++++------------------------ plugin/ai_reply/main.go | 9 ++-- plugin/ai_reply/model.go | 29 +++++++++++++ plugin/moegoe/main.go | 20 +++------ plugin/moegoe/model.go | 24 +++++++++++ plugin/novel/qianbi.go | 14 ++++-- plugin/score/draw.go | 2 + plugin/score/sign_in.go | 91 +++++++++++++++++---------------------- plugin/steam/listenter.go | 24 +++++++---- plugin/steam/steam.go | 1 + plugin/steam/store.go | 71 +++++++++++++----------------- 14 files changed, 187 insertions(+), 188 deletions(-) create mode 100644 plugin/ai_reply/model.go create mode 100644 plugin/moegoe/model.go diff --git a/README.md b/README.md index 619054faba..c85f4c8e1a 100644 --- a/README.md +++ b/README.md @@ -1250,7 +1250,7 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] 签到 - [x] 获得签到背景[@xxx] | 获得签到背景 - - [x] 设置[默认]签到预设(1~9) + - [x] 设置签到预设(0~3) - [x] 查看等级排名 - 注:跨群排行 - [x] 查看我的钱包 diff --git a/go.mod b/go.mod index c131aa02a3..38f1fae239 100644 --- a/go.mod +++ b/go.mod @@ -11,8 +11,8 @@ require ( github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9 github.com/FloatTech/sqlite v1.6.2 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b - github.com/FloatTech/zbpctrl v1.5.3-0.20230406055807-cb5f5edad2c7 - github.com/FloatTech/zbputils v1.6.2-0.20230407083549-931d7968df13 + github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849 + github.com/FloatTech/zbputils v1.6.2-0.20230408085317-f2f525cff6fc github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 diff --git a/go.sum b/go.sum index 87fba9b652..1adbf92300 100644 --- a/go.sum +++ b/go.sum @@ -16,10 +16,10 @@ github.com/FloatTech/sqlite v1.6.2 h1:FytbExjpvYalZxxITtmSenHiPGLPUvlz47LY/P0SCC github.com/FloatTech/sqlite v1.6.2/go.mod h1:zFbHzRfB+CJ+VidfjuVbrcin3DAz283F7hF1hIeHzpY= github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJGLDNIdRX3BI546D3O7k7vrVueZw= github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= -github.com/FloatTech/zbpctrl v1.5.3-0.20230406055807-cb5f5edad2c7 h1:ii/HjRAAH1Ot1mwg4r+kabiI0H8EZ/PwTZryEbN4Jvg= -github.com/FloatTech/zbpctrl v1.5.3-0.20230406055807-cb5f5edad2c7/go.mod h1:IagyEhY38VcbbQgVRzAM9f9mhaUn90rM5BTPfudtl1g= -github.com/FloatTech/zbputils v1.6.2-0.20230407083549-931d7968df13 h1:7HX4TP7/ihnoCvD/XyM2nxi4EI0wClQB7SSDCSgfx8I= -github.com/FloatTech/zbputils v1.6.2-0.20230407083549-931d7968df13/go.mod h1:iPlPghAE6SSDBZPHA6ZiPyspfeVDNQqtfLDkftHlD4I= +github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849 h1:ARKWV3tXJLENWY6vcwTStEDwJckYnxoHXgZMsuJ3gUw= +github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849/go.mod h1:IagyEhY38VcbbQgVRzAM9f9mhaUn90rM5BTPfudtl1g= +github.com/FloatTech/zbputils v1.6.2-0.20230408085317-f2f525cff6fc h1:myLvTVYvTaBgKoXJW1rHPFfr0W4wWPlJQ5DlKBhfHuw= +github.com/FloatTech/zbputils v1.6.2-0.20230408085317-f2f525cff6fc/go.mod h1:GLuSpLdTOCpqkR1oxqjuDz/rOif/ZrH4zGhtMzBqlqo= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= diff --git a/plugin/ai_reply/ai_tts.go b/plugin/ai_reply/ai_tts.go index f84eb7febb..e6a27e41cd 100644 --- a/plugin/ai_reply/ai_tts.go +++ b/plugin/ai_reply/ai_tts.go @@ -2,10 +2,8 @@ package aireply import ( "errors" - "net/url" "github.com/RomiChan/syncx" - "github.com/sirupsen/logrus" zero "github.com/wdvxdr1123/ZeroBot" "github.com/FloatTech/AnimeAPI/aireply" @@ -54,25 +52,23 @@ var ttscnspeakers = [...]string{ "晓甄(女 - 年轻人)", } -const ( - defaultttsindexkey = -2905 - gsapikeyextragrp = -1 - chatgptapikeyextragrp = -2 +const defaultttsindexkey = -2905 + +var ( + 原 = newapikeystore("./data/tts/o.txt") + ཆཏ = newapikeystore("./data/tts/c.txt") ) -type replymode struct { - APIKey string // APIKey is for chatgpt - replyModes []string `json:"-"` -} +type replymode []string -func (r *replymode) setReplyMode(ctx *zero.Ctx, name string) error { +func (r replymode) setReplyMode(ctx *zero.Ctx, name string) error { gid := ctx.Event.GroupID if gid == 0 { gid = -ctx.Event.UserID } var ok bool var index int64 - for i, s := range r.replyModes { + for i, s := range r { if s == name { ok = true index = int64(i) @@ -89,7 +85,7 @@ func (r *replymode) setReplyMode(ctx *zero.Ctx, name string) error { return m.SetData(gid, (m.GetData(index)&^0xff)|(index&0xff)) } -func (r *replymode) getReplyMode(ctx *zero.Ctx) aireply.AIReply { +func (r replymode) getReplyMode(ctx *zero.Ctx) aireply.AIReply { gid := ctx.Event.GroupID if gid == 0 { gid = -ctx.Event.UserID @@ -102,7 +98,7 @@ func (r *replymode) getReplyMode(ctx *zero.Ctx) aireply.AIReply { case 1: return aireply.NewXiaoAi(aireply.XiaoAiURL, aireply.XiaoAiBotName) case 2: - k := r.getAPIKey(ctx) + k := ཆཏ.k if k != "" { return aireply.NewChatGPT(aireply.ChatGPTURL, k) } @@ -112,21 +108,6 @@ func (r *replymode) getReplyMode(ctx *zero.Ctx) aireply.AIReply { return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName) } -func (r *replymode) getAPIKey(ctx *zero.Ctx) string { - if r.APIKey == "" { - m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) - _ = m.Manager.GetExtra(chatgptapikeyextragrp, &r) - logrus.Debugln("[tts] get api key:", r.APIKey) - } - return r.APIKey -} - -func (r *replymode) setAPIKey(m *ctrl.Control[*zero.Ctx], key string) error { - r.APIKey = key - _ = m.Manager.Response(chatgptapikeyextragrp) - return m.Manager.SetExtra(chatgptapikeyextragrp, r) -} - var ttsins = func() map[string]tts.TTS { m := make(map[string]tts.TTS, 128) for _, mode := range append(genshin.SoundList[:], extrattsname...) { @@ -141,10 +122,7 @@ var ttsModes = func() []string { return s }() -type ttsmode struct { - APIKey string // APIKey is for genshin vits - mode syncx.Map[int64, int64] `json:"-"` // mode grp index -} +type ttsmode syncx.Map[int64, int64] func list(list []string, num int) string { s := "" @@ -162,33 +140,17 @@ func list(list []string, num int) string { func newttsmode() *ttsmode { t := &ttsmode{} m, ok := control.Lookup("tts") - t.mode = syncx.Map[int64, int64]{} - t.mode.Store(defaultttsindexkey, 0) + (*syncx.Map[int64, int64])(t).Store(defaultttsindexkey, 0) if ok { index := m.GetData(defaultttsindexkey) msk := index & 0xff if msk >= 0 && (msk < int64(len(genshin.SoundList)) || msk == baiduttsindex || msk == ttscnttsindex) { - t.mode.Store(defaultttsindexkey, index) + (*syncx.Map[int64, int64])(t).Store(defaultttsindexkey, index) } } return t } -func (t *ttsmode) getAPIKey(ctx *zero.Ctx) string { - if t.APIKey == "" { - m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) - _ = m.Manager.GetExtra(gsapikeyextragrp, &t) - logrus.Debugln("[tts] get api key:", t.APIKey) - } - return url.QueryEscape(t.APIKey) -} - -func (t *ttsmode) setAPIKey(m *ctrl.Control[*zero.Ctx], key string) error { - t.APIKey = key - _ = m.Manager.Response(gsapikeyextragrp) - return m.Manager.SetExtra(gsapikeyextragrp, t) -} - func (t *ttsmode) setSoundMode(ctx *zero.Ctx, name string, baiduper, mockingsynt int) error { gid := ctx.Event.GroupID if gid == 0 { @@ -216,7 +178,7 @@ func (t *ttsmode) setSoundMode(ctx *zero.Ctx, name string, baiduper, mockingsynt } } m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) - t.mode.Store(gid, index) + (*syncx.Map[int64, int64])(t).Store(gid, index) return m.SetData(gid, (m.GetData(gid)&^0xffff00)|((index<<8)&0xff00)|((int64(baiduper)<<16)&0x0f0000)|((int64(mockingsynt)<<20)&0xf00000)) } @@ -225,14 +187,14 @@ func (t *ttsmode) getSoundMode(ctx *zero.Ctx) (tts.TTS, error) { if gid == 0 { gid = -ctx.Event.UserID } - i, ok := t.mode.Load(gid) + i, ok := (*syncx.Map[int64, int64])(t).Load(gid) if !ok { m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) i = m.GetData(gid) >> 8 } m := i & 0xff if m < 0 || (m >= int64(len(genshin.SoundList)) && m != baiduttsindex && m != ttscnttsindex) { - i, _ = t.mode.Load(defaultttsindexkey) + i, _ = (*syncx.Map[int64, int64])(t).Load(defaultttsindexkey) m = i & 0xff } mode := ttsModes[m] @@ -248,9 +210,9 @@ func (t *ttsmode) getSoundMode(ctx *zero.Ctx) (tts.TTS, error) { return nil, err } default: // 原神 - k := t.getAPIKey(ctx) + k := 原.k if k != "" { - ins = genshin.NewGenshin(int(m), t.getAPIKey(ctx)) + ins = genshin.NewGenshin(int(m), 原.k) ttsins[mode] = ins } else { return nil, errors.New("no valid speaker") @@ -296,6 +258,6 @@ func (t *ttsmode) setDefaultSoundMode(name string, baiduper, mockingsynt int) er if !ok { return errors.New("[tts] service not found") } - t.mode.Store(defaultttsindexkey, index) + (*syncx.Map[int64, int64])(t).Store(defaultttsindexkey, index) return m.SetData(defaultttsindexkey, (index&0xff)|((int64(baiduper)<<8)&0x0f00)|((int64(mockingsynt)<<12)&0xf000)) } diff --git a/plugin/ai_reply/main.go b/plugin/ai_reply/main.go index 58e583e45f..fa4fb98848 100644 --- a/plugin/ai_reply/main.go +++ b/plugin/ai_reply/main.go @@ -15,9 +15,7 @@ import ( "github.com/wdvxdr1123/ZeroBot/message" ) -var replmd = replymode{ - replyModes: []string{"青云客", "小爱", "ChatGPT"}, -} +var replmd = replymode([]string{"青云客", "小爱", "ChatGPT"}) var ttsmd = newttsmode() @@ -32,6 +30,7 @@ func init() { // 插件主体 "- 设置原神语音 api key xxxxxx (key请加开发群获得)\n" + "当前适用的原神人物含有以下: \n" + list(genshin.SoundList[:], 5) + "\n当前适用的TTSCN人物含有以下(以数字顺序代表): \n" + list(ttscnspeakers[:], 5), + PrivateDataFolder: "tts", }) enr := control.Register("aireply", &ctrl.Options[*zero.Ctx]{ @@ -66,7 +65,7 @@ func init() { // 插件主体 }) enr.OnRegex(`^设置\s*ChatGPT\s*api\s*key\s*(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) { - err := replmd.setAPIKey(ctx.State["manager"].(*ctrl.Control[*zero.Ctx]), ctx.State["regex_matched"].([]string)[1]) + err := ཆཏ.set(ctx.State["regex_matched"].([]string)[1]) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return @@ -184,7 +183,7 @@ func init() { // 插件主体 }) ent.OnRegex(`^设置原神语音\s*api\s*key\s*([0-9a-zA-Z-_]{54}==)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) { - err := ttsmd.setAPIKey(ctx.State["manager"].(*ctrl.Control[*zero.Ctx]), ctx.State["regex_matched"].([]string)[1]) + err := 原.set(ctx.State["regex_matched"].([]string)[1]) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return diff --git a/plugin/ai_reply/model.go b/plugin/ai_reply/model.go new file mode 100644 index 0000000000..1e79d5e3ff --- /dev/null +++ b/plugin/ai_reply/model.go @@ -0,0 +1,29 @@ +package aireply + +import ( + "os" + + "github.com/FloatTech/floatbox/binary" + "github.com/FloatTech/floatbox/file" +) + +type apikeystore struct { + k string + p string +} + +func newapikeystore(p string) (s apikeystore) { + s.p = p + if file.IsExist(p) { + data, err := os.ReadFile(p) + if err == nil { + s.k = binary.BytesToString(data) + } + } + return +} + +func (s *apikeystore) set(k string) error { + s.k = k + return os.WriteFile(s.p, binary.StringToBytes(k), 0644) +} diff --git a/plugin/moegoe/main.go b/plugin/moegoe/main.go index 1233e80063..6a4f3e8b35 100644 --- a/plugin/moegoe/main.go +++ b/plugin/moegoe/main.go @@ -25,6 +25,8 @@ var speakers = map[string]uint{ "派蒙": 0, "凯亚": 1, "安柏": 2, "丽莎": 3, "琴": 4, "香菱": 5, "枫原万叶": 6, "迪卢克": 7, "温迪": 8, "可莉": 9, "早柚": 10, "托马": 11, "芭芭拉": 12, "优菈": 13, "云堇": 14, "钟离": 15, "魈": 16, "凝光": 17, "雷电将军": 18, "北斗": 19, "甘雨": 20, "七七": 21, "刻晴": 22, "神里绫华": 23, "戴因斯雷布": 24, "雷泽": 25, "神里绫人": 26, "罗莎莉亚": 27, "阿贝多": 28, "八重神子": 29, "宵宫": 30, "荒泷一斗": 31, "九条裟罗": 32, "夜兰": 33, "珊瑚宫心海": 34, "五郎": 35, "散兵": 36, "女士": 37, "达达利亚": 38, "莫娜": 39, "班尼特": 40, "申鹤": 41, "行秋": 42, "烟绯": 43, "久岐忍": 44, "辛焱": 45, "砂糖": 46, "胡桃": 47, "重云": 48, "菲谢尔": 49, "诺艾尔": 50, "迪奥娜": 51, "鹿野院平藏": 52, } +var 原 = newapikeystore("./data/tts/o.txt") + func init() { en := control.Register("moegoe", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, @@ -47,21 +49,11 @@ func init() { }) en.OnRegex("^让(派蒙|凯亚|安柏|丽莎|琴|香菱|枫原万叶|迪卢克|温迪|可莉|早柚|托马|芭芭拉|优菈|云堇|钟离|魈|凝光|雷电将军|北斗|甘雨|七七|刻晴|神里绫华|雷泽|神里绫人|罗莎莉亚|阿贝多|八重神子|宵宫|荒泷一斗|九条裟罗|夜兰|珊瑚宫心海|五郎|达达利亚|莫娜|班尼特|申鹤|行秋|烟绯|久岐忍|辛焱|砂糖|胡桃|重云|菲谢尔|诺艾尔|迪奥娜|鹿野院平藏)说([\\s\u4e00-\u9fa5\\pP]+)$").Limit(ctxext.LimitByGroup).SetBlock(true). Handle(func(ctx *zero.Ctx) { - text := ctx.State["regex_matched"].([]string)[2] - id := speakers[ctx.State["regex_matched"].([]string)[1]] - c, ok := control.Lookup("tts") - if !ok { - ctx.SendChain(message.Text("ERROR: plugin tts not found")) - return - } - var key struct { - APIKey string - } - err := c.Manager.GetExtra(-1, &key) - if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) + if 原.k == "" { return } - ctx.SendChain(message.Record(fmt.Sprintf(genshin.CNAPI, id, url.QueryEscape(text), url.QueryEscape(key.APIKey)))) + text := ctx.State["regex_matched"].([]string)[2] + id := speakers[ctx.State["regex_matched"].([]string)[1]] + ctx.SendChain(message.Record(fmt.Sprintf(genshin.CNAPI, id, url.QueryEscape(text), url.QueryEscape(原.k)))) }) } diff --git a/plugin/moegoe/model.go b/plugin/moegoe/model.go new file mode 100644 index 0000000000..cd09b72acd --- /dev/null +++ b/plugin/moegoe/model.go @@ -0,0 +1,24 @@ +package moegoe + +import ( + "os" + + "github.com/FloatTech/floatbox/binary" + "github.com/FloatTech/floatbox/file" +) + +type apikeystore struct { + k string + p string +} + +func newapikeystore(p string) (s apikeystore) { + s.p = p + if file.IsExist(p) { + data, err := os.ReadFile(p) + if err == nil { + s.k = binary.BytesToString(data) + } + } + return +} diff --git a/plugin/novel/qianbi.go b/plugin/novel/qianbi.go index 529fe05a16..964b9c8af6 100644 --- a/plugin/novel/qianbi.go +++ b/plugin/novel/qianbi.go @@ -9,6 +9,7 @@ import ( "path/filepath" "regexp" "strings" + "sync" "github.com/antchfx/htmlquery" "github.com/sirupsen/logrus" @@ -42,12 +43,14 @@ const ( var ( cachePath string // apikey 由账号和密码拼接而成, 例: zerobot,123456 - apikey string + apikey string + apikeymu sync.Mutex ) func init() { engine := control.Register("novel", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, + Extra: control.ExtraFromString("novel"), Brief: "铅笔小说网搜索", Help: "- 小说[xxx]\n" + "- 设置小说配置 zerobot 123456\n" + @@ -290,16 +293,19 @@ func download(id string, cookie string) (downloadHTML string, err error) { } func getAPIKey(ctx *zero.Ctx) string { + apikeymu.Lock() + defer apikeymu.Unlock() if apikey == "" { m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) - _ = m.Manager.GetExtra(-1, &apikey) + _ = m.GetExtra(&apikey) logrus.Debugln("[novel] get api key:", apikey) } return apikey } func setAPIKey(m *ctrl.Control[*zero.Ctx], key string) error { + apikeymu.Lock() + defer apikeymu.Unlock() apikey = key - _ = m.Manager.Response(-1) - return m.Manager.SetExtra(-1, apikey) + return m.SetExtra(apikey) } diff --git a/plugin/score/draw.go b/plugin/score/draw.go index 4709e5499b..33cc58b451 100644 --- a/plugin/score/draw.go +++ b/plugin/score/draw.go @@ -22,6 +22,8 @@ import ( "github.com/FloatTech/ZeroBot-Plugin/kanban/banner" ) +type scoredrawer func(a *scdata) (image.Image, error) + func drawScore16(a *scdata) (image.Image, error) { // 绘图 getAvatar, err := initPic(a.picfile, a.uid) diff --git a/plugin/score/sign_in.go b/plugin/score/sign_in.go index 8ce971a8c4..17185d44eb 100644 --- a/plugin/score/sign_in.go +++ b/plugin/score/sign_in.go @@ -2,7 +2,6 @@ package score import ( - "image" "math" "math/rand" "os" @@ -12,7 +11,6 @@ import ( "github.com/FloatTech/AnimeAPI/bilibili" "github.com/FloatTech/AnimeAPI/wallet" - fcext "github.com/FloatTech/floatbox/ctxext" "github.com/FloatTech/floatbox/file" "github.com/FloatTech/floatbox/process" "github.com/FloatTech/floatbox/web" @@ -32,8 +30,7 @@ const ( referer = "https://weibo.com/" signinMax = 1 // SCOREMAX 分数上限定为1200 - SCOREMAX = 1200 - defKeyID int64 = -6 + SCOREMAX = 1200 ) var ( @@ -41,25 +38,14 @@ var ( engine = control.Register("score", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, Brief: "签到", - Help: "- 签到\n- 获得签到背景[@xxx] | 获得签到背景\n- 设置[默认]签到预设(1~9)\n- 查看等级排名\n注:为跨群排名\n- 查看我的钱包\n- 查看钱包排名\n注:为本群排行,若群人数太多不建议使用该功能!!!", + Help: "- 签到\n- 获得签到背景[@xxx] | 获得签到背景\n- 设置签到预设(0~3)\n- 查看等级排名\n注:为跨群排名\n- 查看我的钱包\n- 查看钱包排名\n注:为本群排行,若群人数太多不建议使用该功能!!!", PrivateDataFolder: "score", }) - initDef = fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool { - var defkey string - m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) - _ = m.Manager.Response(defKeyID) - _ = m.Manager.GetExtra(defKeyID, &defkey) - if defkey == "" { - _ = m.Manager.SetExtra(defKeyID, "1") - return true - } - return true - }) - stylemap = map[string]func(a *scdata) (image.Image, error){ - "1": drawScore15, - "2": drawScore16, - "3": drawScore17, - "4": drawScore17b2, + styles = []scoredrawer{ + drawScore15, + drawScore16, + drawScore17, + drawScore17b2, } ) @@ -84,7 +70,7 @@ func init() { } sdb = initialize(engine.DataFolder() + "score.db") }() - engine.OnRegex(`^签到\s?(\d*)$`, initDef).Limit(ctxext.LimitByUser).SetBlock(true).Handle(func(ctx *zero.Ctx) { + engine.OnRegex(`^签到\s?(\d*)$`).Limit(ctxext.LimitByUser).SetBlock(true).Handle(func(ctx *zero.Ctx) { // 选择key key := ctx.State["regex_matched"].([]string)[1] gid := ctx.Event.GroupID @@ -92,15 +78,18 @@ func init() { // 个人用户设为负数 gid = -ctx.Event.UserID } + k := uint8(0) if key == "" { - m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) - _ = m.Manager.GetExtra(gid, &key) - if key == "" { - _ = m.Manager.GetExtra(defKeyID, &key) + k = uint8(ctx.State["manager"].(*ctrl.Control[*zero.Ctx]).GetData(gid)) + } else { + kn, err := strconv.Atoi(key) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return } + k = uint8(kn) } - drawfunc, ok := stylemap[key] - if !ok { + if int(k) >= len(styles) { ctx.SendChain(message.Text("ERROR: 未找到签到设定: ", key)) return } @@ -165,7 +154,7 @@ func init() { level: level, rank: rank, } - drawimage, err := drawfunc(alldata) + drawimage, err := styles[k](alldata) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return @@ -280,30 +269,28 @@ func init() { } ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile)) }) - engine.OnRegex(`^设置(默认)?签到预设\s?(\d*)$`, zero.SuperUserPermission).Limit(ctxext.LimitByUser).SetBlock(true).Handle(func(ctx *zero.Ctx) { - if key := ctx.State["regex_matched"].([]string)[2]; key == "" { - ctx.SendChain(message.Text("设置失败, 数据为空")) - } else { - s := ctx.State["regex_matched"].([]string)[1] - _, ok := stylemap[key] - if !ok { - ctx.SendChain(message.Text("ERROR: 未找到签到设定: ", key)) // 避免签到配置错误 - return - } - gid := ctx.Event.GroupID - if gid == 0 { - gid = -ctx.Event.UserID - } - if s != "" { - gid = defKeyID - } - err := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]).Manager.SetExtra(gid, key) - if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return - } - ctx.SendChain(message.Text("设置成功, 当前", s, "预设为:", key)) + engine.OnRegex(`^设置签到预设\s*(\d+)$`, zero.SuperUserPermission).Limit(ctxext.LimitByUser).SetBlock(true).Handle(func(ctx *zero.Ctx) { + key := ctx.State["regex_matched"].([]string)[1] + kn, err := strconv.Atoi(key) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + k := uint8(kn) + if int(k) >= len(styles) { + ctx.SendChain(message.Text("ERROR: 未找到签到设定: ", key)) + return + } + gid := ctx.Event.GroupID + if gid == 0 { + gid = -ctx.Event.UserID + } + err = ctx.State["manager"].(*ctrl.Control[*zero.Ctx]).SetData(gid, int64(k)) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return } + ctx.SendChain(message.Text("设置成功")) }) } diff --git a/plugin/steam/listenter.go b/plugin/steam/listenter.go index 976826558e..25032f983d 100644 --- a/plugin/steam/listenter.go +++ b/plugin/steam/listenter.go @@ -4,6 +4,7 @@ import ( "fmt" "strconv" "strings" + "sync" "time" "github.com/FloatTech/floatbox/binary" @@ -16,19 +17,22 @@ import ( // ----------------------- 远程调用 ---------------------- const ( - URL = "https://api.steampowered.com/" // steam API 调用地址 - StatusURL = "ISteamUser/GetPlayerSummaries/v2/?key=%+v&steamids=%+v" // 根据用户steamID获取用户状态 - steamapikeygid = 3 + apiurl = "https://api.steampowered.com/" // steam API 调用地址 + statusurl = "ISteamUser/GetPlayerSummaries/v2/?key=%+v&steamids=%+v" // 根据用户steamID获取用户状态 ) -var apiKey string +var ( + apiKey string + apiKeyMu sync.Mutex +) func init() { engine.OnRegex(`^steam绑定\s*api\s*key\s*(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) { + apiKeyMu.Lock() + defer apiKeyMu.Unlock() apiKey = ctx.State["regex_matched"].([]string)[1] m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) - _ = m.Manager.Response(steamapikeygid) - err := m.Manager.SetExtra(steamapikeygid, apiKey) + err := m.SetExtra(apiKey) if err != nil { ctx.SendChain(message.Text("[steam] ERROR: 保存apikey失败!")) return @@ -36,6 +40,8 @@ func init() { ctx.SendChain(message.Text("保存apikey成功!")) }) engine.OnFullMatch("查看apikey", zero.OnlyPrivate, zero.SuperUserPermission, getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) { + apiKeyMu.Lock() + defer apiKeyMu.Unlock() ctx.SendChain(message.Text("apikey为: ", apiKey)) }) engine.OnFullMatch("拉取steam订阅", getDB).SetBlock(true).Handle(func(ctx *zero.Ctx) { @@ -55,7 +61,7 @@ func init() { localPlayerMap := make(map[int64]*player) for i := 0; i < len(infos); i++ { streamIds[i] = strconv.FormatInt(infos[i].SteamID, 10) - localPlayerMap[infos[i].SteamID] = &infos[i] + localPlayerMap[infos[i].SteamID] = infos[i] } // 将所有用户状态查一遍 playerStatus, err := getPlayerStatus(streamIds...) @@ -114,7 +120,9 @@ func init() { func getPlayerStatus(streamIds ...string) ([]*player, error) { players := make([]*player, 0) // 拼接请求地址 - url := fmt.Sprintf(URL+StatusURL, apiKey, strings.Join(streamIds, ",")) + apiKeyMu.Lock() + url := fmt.Sprintf(apiurl+statusurl, apiKey, strings.Join(streamIds, ",")) + apiKeyMu.Unlock() // 拉取并解析数据 data, err := web.GetData(url) if err != nil { diff --git a/plugin/steam/steam.go b/plugin/steam/steam.go index db51b2b5f0..fe913fa797 100644 --- a/plugin/steam/steam.go +++ b/plugin/steam/steam.go @@ -19,6 +19,7 @@ import ( var ( engine = control.Register("steam", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, + Extra: control.ExtraFromString("steam"), Brief: "steam相关插件", Help: "- steam添加订阅 xxxxxxx (可输入需要绑定的 steamid)\n" + "- steam删除订阅 xxxxxxx (删除你创建的对于 steamid 的绑定)\n" + diff --git a/plugin/steam/store.go b/plugin/steam/store.go index 171a60f7d6..e68aa71994 100644 --- a/plugin/steam/store.go +++ b/plugin/steam/store.go @@ -22,14 +22,15 @@ var ( ctx.SendChain(message.Text("[steam] ERROR: ", err)) return false } - if err = database.db.Create(TableListenPlayer, &player{}); err != nil { + if err = database.db.Create(tableListenPlayer, &player{}); err != nil { ctx.SendChain(message.Text("[steam] ERROR: ", err)) return false } // 校验密钥是否初始化 m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) - _ = m.Manager.Response(steamapikeygid) - _ = m.Manager.GetExtra(steamapikeygid, &apiKey) + apiKeyMu.Lock() + defer apiKeyMu.Unlock() + _ = m.GetExtra(&apiKey) if apiKey == "" { ctx.SendChain(message.Text("ERROR: 未设置steam apikey")) return false @@ -45,8 +46,8 @@ type streamDB struct { } const ( - // TableListenPlayer 存储查询用户信息 - TableListenPlayer = "listen_player" + // tableListenPlayer 存储查询用户信息 + tableListenPlayer = "listen_player" ) // player 用户状态存储结构体 @@ -60,58 +61,46 @@ type player struct { } // update 如果主键不存在则插入一条新的数据,如果主键存在直接复写 -func (sql *streamDB) update(dbInfo *player) error { - sql.Lock() - defer sql.Unlock() - return sql.db.Insert(TableListenPlayer, dbInfo) +func (sdb *streamDB) update(dbInfo *player) error { + sdb.Lock() + defer sdb.Unlock() + return sdb.db.Insert(tableListenPlayer, dbInfo) } // find 根据主键查信息 -func (sql *streamDB) find(steamID int64) (dbInfo player, err error) { - sql.Lock() - defer sql.Unlock() +func (sdb *streamDB) find(steamID int64) (dbInfo player, err error) { + sdb.Lock() + defer sdb.Unlock() condition := "where steam_id = " + strconv.FormatInt(steamID, 10) - if !sql.db.CanFind(TableListenPlayer, condition) { - return player{}, nil // 规避没有该用户数据的报错 + err = sdb.db.Find(tableListenPlayer, &dbInfo, condition) + if err == sql.ErrNullResult { // 规避没有该用户数据的报错 + err = nil } - err = sql.db.Find(TableListenPlayer, &dbInfo, condition) return } // findWithGroupID 根据用户steamID和groupID查询信息 -func (sql *streamDB) findWithGroupID(steamID int64, groupID string) (dbInfo player, err error) { - sql.Lock() - defer sql.Unlock() +func (sdb *streamDB) findWithGroupID(steamID int64, groupID string) (dbInfo player, err error) { + sdb.Lock() + defer sdb.Unlock() condition := "where steam_id = " + strconv.FormatInt(steamID, 10) + " AND target LIKE '%" + groupID + "%'" - if !sql.db.CanFind(TableListenPlayer, condition) { - return player{}, nil // 规避没有该用户数据的报错 + err = sdb.db.Find(tableListenPlayer, &dbInfo, condition) + if err == sql.ErrNullResult { // 规避没有该用户数据的报错 + err = nil } - err = sql.db.Find(TableListenPlayer, &dbInfo, condition) return } // findAll 查询所有库信息 -func (sql *streamDB) findAll() (dbInfos []player, err error) { - sql.Lock() - defer sql.Unlock() - var info player - num, err := sql.db.Count(TableListenPlayer) - if err != nil || num == 0 { - return - } - dbInfos = make([]player, 0, num) - err = sql.db.FindFor(TableListenPlayer, &info, "", func() error { - if info.SteamID != 0 { - dbInfos = append(dbInfos, info) - } - return nil - }) - return +func (sdb *streamDB) findAll() (dbInfos []*player, err error) { + sdb.Lock() + defer sdb.Unlock() + return sql.FindAll[player](&sdb.db, tableListenPlayer, "") } // del 删除指定数据 -func (sql *streamDB) del(steamID int64) error { - sql.Lock() - defer sql.Unlock() - return sql.db.Del(TableListenPlayer, "where steam_id = "+strconv.FormatInt(steamID, 10)) +func (sdb *streamDB) del(steamID int64) error { + sdb.Lock() + defer sdb.Unlock() + return sdb.db.Del(tableListenPlayer, "where steam_id = "+strconv.FormatInt(steamID, 10)) } From c1702c5d5e4b63c7b6cab7cde601c89b78065a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 9 Apr 2023 11:01:14 +0800 Subject: [PATCH 42/95] =?UTF-8?q?=E7=99=BE=E5=BA=A6tts=E8=87=AA=E8=A1=8C?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=20id&secret?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 2 ++ plugin/ai_reply/ai_tts.go | 5 ++++- plugin/ai_reply/main.go | 12 +++++++++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 38f1fae239..db2b2fa8a3 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/Baidu-AIP/golang-sdk v1.1.1 - github.com/FloatTech/AnimeAPI v1.6.1-0.20230407094656-35c90555daf6 + github.com/FloatTech/AnimeAPI v1.6.1-0.20230409024643-f25135dee0da github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 github.com/FloatTech/imgfactory v0.2.2-0.20230322091809-b0ddbe44b94b diff --git a/go.sum b/go.sum index 1adbf92300..c567ef1db6 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/FloatTech/AnimeAPI v1.6.1-0.20230407094656-35c90555daf6 h1:hS5U1Xz6JtVyGdXOl50j9ubQxP446+TjIAhaGapGUpU= github.com/FloatTech/AnimeAPI v1.6.1-0.20230407094656-35c90555daf6/go.mod h1:UnCPjtpIzpNBZ02yeGYp+oYVxgoi5aF2yAK2bkOVxtI= +github.com/FloatTech/AnimeAPI v1.6.1-0.20230409024643-f25135dee0da h1:QyH0zpWt3YspNNfZ+5f8+QStvtmxrzld/DoocKjF+rc= +github.com/FloatTech/AnimeAPI v1.6.1-0.20230409024643-f25135dee0da/go.mod h1:UnCPjtpIzpNBZ02yeGYp+oYVxgoi5aF2yAK2bkOVxtI= github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 h1:/eQoMa6Aj3coF5F7yhzZe1+SzX6SItul7MW8//pl18o= github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI= github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 h1:dPLeoiTVSBlgls+66EB/UJ2e38BaASmBN5nANaycSBU= diff --git a/plugin/ai_reply/ai_tts.go b/plugin/ai_reply/ai_tts.go index e6a27e41cd..ae1abd0535 100644 --- a/plugin/ai_reply/ai_tts.go +++ b/plugin/ai_reply/ai_tts.go @@ -2,6 +2,7 @@ package aireply import ( "errors" + "strings" "github.com/RomiChan/syncx" zero "github.com/wdvxdr1123/ZeroBot" @@ -57,6 +58,7 @@ const defaultttsindexkey = -2905 var ( 原 = newapikeystore("./data/tts/o.txt") ཆཏ = newapikeystore("./data/tts/c.txt") + 百 = newapikeystore("./data/tts/b.txt") ) type replymode []string @@ -202,7 +204,8 @@ func (t *ttsmode) getSoundMode(ctx *zero.Ctx) (tts.TTS, error) { if !ok || ins == nil { switch mode { case extrattsname[0]: - ins = baidutts.NewBaiduTTS(int(i&0x0f00) >> 8) + id, sec, _ := strings.Cut(百.k, ",") + ins = baidutts.NewBaiduTTS(int(i&0x0f00)>>8, id, sec) case extrattsname[1]: var err error ins, err = ttscn.NewTTSCN("中文(普通话,简体)", ttscnspeakers[int(i&0xf000)>>12], ttscn.KBRates[0]) diff --git a/plugin/ai_reply/main.go b/plugin/ai_reply/main.go index fa4fb98848..2585b8c26d 100644 --- a/plugin/ai_reply/main.go +++ b/plugin/ai_reply/main.go @@ -28,6 +28,7 @@ func init() { // 插件主体 "- 设置默认语音模式[原神人物/百度/TTSCN] 数字(百度/TTSCN说话人)\n" + "- 恢复成默认语音模式\n" + "- 设置原神语音 api key xxxxxx (key请加开发群获得)\n" + + "- 设置百度语音 api id xxxxxx secret xxxxxx (请自行获得)\n" + "当前适用的原神人物含有以下: \n" + list(genshin.SoundList[:], 5) + "\n当前适用的TTSCN人物含有以下(以数字顺序代表): \n" + list(ttscnspeakers[:], 5), PrivateDataFolder: "tts", @@ -103,7 +104,7 @@ func init() { // 插件主体 } }) - ent.OnRegex(`^设置语音模式\s*([\S\D]*)\s*(\d*)$`, zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) { + ent.OnRegex(`^设置语音模式\s*(.*)\s+(\d*)$`, zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) { param := ctx.State["regex_matched"].([]string)[1] num := ctx.State["regex_matched"].([]string)[2] n := 0 @@ -190,4 +191,13 @@ func init() { // 插件主体 } ctx.SendChain(message.Text("设置成功")) }) + + ent.OnRegex(`^设置百度语音\s*api\s*id\s*(.*)\s*secret\s*(.*)\s*$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) { + err := 百.set(ctx.State["regex_matched"].([]string)[1] + "," + ctx.State["regex_matched"].([]string)[2]) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + ctx.SendChain(message.Text("设置成功")) + }) } From 2b1caafa16ee12498275be17690dbb7c57759aed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 9 Apr 2023 11:02:35 +0800 Subject: [PATCH 43/95] =?UTF-8?q?=F0=9F=94=96=20v1.7.1-beta2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kanban/banner/banner.go | 4 ++-- winres/winres.json | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kanban/banner/banner.go b/kanban/banner/banner.go index b0b0b47a56..4da7690735 100644 --- a/kanban/banner/banner.go +++ b/kanban/banner/banner.go @@ -3,13 +3,13 @@ package banner // Version ... -var Version = "v1.7.1-beta1" +var Version = "v1.7.1-beta2" // Copyright ... var Copyright = "© 2020 - 2023 FloatTech" // Banner ... var Banner = "* OneBot + ZeroBot + Golang\n" + - "* Version " + Version + " - 2023-03-31 15:53:05 +0800 CST\n" + + "* Version " + Version + " - 2023-04-09 11:01:54 +0800 CST\n" + "* Copyright " + Copyright + ". All Rights Reserved.\n" + "* Project: https://github.com/FloatTech/ZeroBot-Plugin" diff --git a/winres/winres.json b/winres/winres.json index 1089ff04df..322c0446e9 100644 --- a/winres/winres.json +++ b/winres/winres.json @@ -12,7 +12,7 @@ "0409": { "identity": { "name": "ZeroBot-Plugin", - "version": "1.7.1.1780" + "version": "1.7.1.1789" }, "description": "", "minimum-os": "vista", @@ -36,23 +36,23 @@ "#1": { "0000": { "fixed": { - "file_version": "1.7.1.1780", - "product_version": "v1.7.1-beta1", - "timestamp": "2023-03-31T15:53:17+08:00" + "file_version": "1.7.1.1789", + "product_version": "v1.7.1-beta2", + "timestamp": "2023-04-09T11:02:07+08:00" }, "info": { "0409": { "Comments": "OneBot plugins based on ZeroBot", "CompanyName": "FloatTech", "FileDescription": "https://github.com/FloatTech/ZeroBot-Plugin", - "FileVersion": "1.7.1.1780", + "FileVersion": "1.7.1.1789", "InternalName": "", "LegalCopyright": "© 2020 - 2023 FloatTech. All Rights Reserved.", "LegalTrademarks": "", "OriginalFilename": "ZBP.EXE", "PrivateBuild": "", "ProductName": "ZeroBot-Plugin", - "ProductVersion": "v1.7.1-beta1", + "ProductVersion": "v1.7.1-beta2", "SpecialBuild": "" } } From e224bf92528055a2c952684068f42b935ff4b4dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 10 Apr 2023 11:50:52 +0800 Subject: [PATCH 44/95] =?UTF-8?q?=E2=9C=A8=20add=20=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E5=86=B2=E7=AA=81=E9=81=BF=E5=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index db2b2fa8a3..ba40375bef 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/FloatTech/sqlite v1.6.2 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849 - github.com/FloatTech/zbputils v1.6.2-0.20230408085317-f2f525cff6fc + github.com/FloatTech/zbputils v1.6.2-0.20230410034904-df805a768c67 github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 diff --git a/go.sum b/go.sum index c567ef1db6..93ff605917 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ github.com/Baidu-AIP/golang-sdk v1.1.1 h1:RQsAmgDSAkiq22I6n7XJ2t3afgzFeqjY46FGhv github.com/Baidu-AIP/golang-sdk v1.1.1/go.mod h1:bXnGw7xPeKt8aF7UCELKrV6UZ/46spItONK1RQBQj1Y= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= -github.com/FloatTech/AnimeAPI v1.6.1-0.20230407094656-35c90555daf6 h1:hS5U1Xz6JtVyGdXOl50j9ubQxP446+TjIAhaGapGUpU= -github.com/FloatTech/AnimeAPI v1.6.1-0.20230407094656-35c90555daf6/go.mod h1:UnCPjtpIzpNBZ02yeGYp+oYVxgoi5aF2yAK2bkOVxtI= github.com/FloatTech/AnimeAPI v1.6.1-0.20230409024643-f25135dee0da h1:QyH0zpWt3YspNNfZ+5f8+QStvtmxrzld/DoocKjF+rc= github.com/FloatTech/AnimeAPI v1.6.1-0.20230409024643-f25135dee0da/go.mod h1:UnCPjtpIzpNBZ02yeGYp+oYVxgoi5aF2yAK2bkOVxtI= github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 h1:/eQoMa6Aj3coF5F7yhzZe1+SzX6SItul7MW8//pl18o= @@ -20,8 +18,8 @@ github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJG github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849 h1:ARKWV3tXJLENWY6vcwTStEDwJckYnxoHXgZMsuJ3gUw= github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849/go.mod h1:IagyEhY38VcbbQgVRzAM9f9mhaUn90rM5BTPfudtl1g= -github.com/FloatTech/zbputils v1.6.2-0.20230408085317-f2f525cff6fc h1:myLvTVYvTaBgKoXJW1rHPFfr0W4wWPlJQ5DlKBhfHuw= -github.com/FloatTech/zbputils v1.6.2-0.20230408085317-f2f525cff6fc/go.mod h1:GLuSpLdTOCpqkR1oxqjuDz/rOif/ZrH4zGhtMzBqlqo= +github.com/FloatTech/zbputils v1.6.2-0.20230410034904-df805a768c67 h1:YJZA/BRbjW7VnJnMrZUSntF+OeFGaPpf+uZC5OEX8Rk= +github.com/FloatTech/zbputils v1.6.2-0.20230410034904-df805a768c67/go.mod h1:GLuSpLdTOCpqkR1oxqjuDz/rOif/ZrH4zGhtMzBqlqo= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= From 7ced79c6bbdd180cd9c707c85001be500c06e846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 10 Apr 2023 11:56:24 +0800 Subject: [PATCH 45/95] =?UTF-8?q?fix=20=E8=AE=BE=E7=BD=AE=E8=AF=AD?= =?UTF-8?q?=E9=9F=B3=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/ai_reply/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/ai_reply/main.go b/plugin/ai_reply/main.go index 2585b8c26d..d94a354983 100644 --- a/plugin/ai_reply/main.go +++ b/plugin/ai_reply/main.go @@ -104,7 +104,7 @@ func init() { // 插件主体 } }) - ent.OnRegex(`^设置语音模式\s*(.*)\s+(\d*)$`, zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) { + ent.OnRegex(`^设置语音模式\s*(\S\D*)\s+(\d*)$`, zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) { param := ctx.State["regex_matched"].([]string)[1] num := ctx.State["regex_matched"].([]string)[2] n := 0 From 7b1d2b7eaa0f25c63bdcd777eaaf39cd46970ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 10 Apr 2023 11:57:10 +0800 Subject: [PATCH 46/95] =?UTF-8?q?fix=20=E8=AE=BE=E7=BD=AE=E8=AF=AD?= =?UTF-8?q?=E9=9F=B3=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/ai_reply/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/ai_reply/main.go b/plugin/ai_reply/main.go index d94a354983..40d30d130f 100644 --- a/plugin/ai_reply/main.go +++ b/plugin/ai_reply/main.go @@ -104,7 +104,7 @@ func init() { // 插件主体 } }) - ent.OnRegex(`^设置语音模式\s*(\S\D*)\s+(\d*)$`, zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) { + ent.OnRegex(`^设置语音模式\s*([\S\D]*)\s+(\d*)$`, zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) { param := ctx.State["regex_matched"].([]string)[1] num := ctx.State["regex_matched"].([]string)[2] n := 0 @@ -147,7 +147,7 @@ func init() { // 插件主体 ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置成功")) }) - ent.OnRegex(`^设置默认语音模式\s*([\S\D]*)\s*(\d*)$`, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) { + ent.OnRegex(`^设置默认语音模式\s*([\S\D]*)\s+(\d*)$`, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) { param := ctx.State["regex_matched"].([]string)[1] num := ctx.State["regex_matched"].([]string)[2] n := 0 From 8a6b7f65c723f1402c8b645337772ed6c62bc9ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 10 Apr 2023 12:21:18 +0800 Subject: [PATCH 47/95] =?UTF-8?q?=F0=9F=90=9B=20fix=20ca?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ba40375bef..cf3f46ef4d 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/FloatTech/sqlite v1.6.2 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849 - github.com/FloatTech/zbputils v1.6.2-0.20230410034904-df805a768c67 + github.com/FloatTech/zbputils v1.6.2-0.20230410042038-a0edcffb78dc github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 diff --git a/go.sum b/go.sum index 93ff605917..095ebbd7ba 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJG github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849 h1:ARKWV3tXJLENWY6vcwTStEDwJckYnxoHXgZMsuJ3gUw= github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849/go.mod h1:IagyEhY38VcbbQgVRzAM9f9mhaUn90rM5BTPfudtl1g= -github.com/FloatTech/zbputils v1.6.2-0.20230410034904-df805a768c67 h1:YJZA/BRbjW7VnJnMrZUSntF+OeFGaPpf+uZC5OEX8Rk= -github.com/FloatTech/zbputils v1.6.2-0.20230410034904-df805a768c67/go.mod h1:GLuSpLdTOCpqkR1oxqjuDz/rOif/ZrH4zGhtMzBqlqo= +github.com/FloatTech/zbputils v1.6.2-0.20230410042038-a0edcffb78dc h1:UHFFiG1VG2XmVhFeZ/hGDtryDvu4gSRM1UabT2vleE0= +github.com/FloatTech/zbputils v1.6.2-0.20230410042038-a0edcffb78dc/go.mod h1:GLuSpLdTOCpqkR1oxqjuDz/rOif/ZrH4zGhtMzBqlqo= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= From 35f8458d67d19b092f00387f277937489696a23f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 10 Apr 2023 12:46:51 +0800 Subject: [PATCH 48/95] =?UTF-8?q?=F0=9F=90=9B=20fix=20ca?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index cf3f46ef4d..212f31581f 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/FloatTech/sqlite v1.6.2 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849 - github.com/FloatTech/zbputils v1.6.2-0.20230410042038-a0edcffb78dc + github.com/FloatTech/zbputils v1.6.2-0.20230410044605-e29b18e837d6 github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 diff --git a/go.sum b/go.sum index 095ebbd7ba..c90a1a7be9 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJG github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849 h1:ARKWV3tXJLENWY6vcwTStEDwJckYnxoHXgZMsuJ3gUw= github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849/go.mod h1:IagyEhY38VcbbQgVRzAM9f9mhaUn90rM5BTPfudtl1g= -github.com/FloatTech/zbputils v1.6.2-0.20230410042038-a0edcffb78dc h1:UHFFiG1VG2XmVhFeZ/hGDtryDvu4gSRM1UabT2vleE0= -github.com/FloatTech/zbputils v1.6.2-0.20230410042038-a0edcffb78dc/go.mod h1:GLuSpLdTOCpqkR1oxqjuDz/rOif/ZrH4zGhtMzBqlqo= +github.com/FloatTech/zbputils v1.6.2-0.20230410044605-e29b18e837d6 h1:HudMAKOnRz/TmDGE2VTl9Ud0lSp8N7dEaPivAE4rJfo= +github.com/FloatTech/zbputils v1.6.2-0.20230410044605-e29b18e837d6/go.mod h1:GLuSpLdTOCpqkR1oxqjuDz/rOif/ZrH4zGhtMzBqlqo= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= From 2324837052bf64c50f035c4673ff04de52e97ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 10 Apr 2023 13:52:48 +0800 Subject: [PATCH 49/95] =?UTF-8?q?=F0=9F=90=9B=20fix=20ca?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 212f31581f..a8a1abf0b6 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/FloatTech/sqlite v1.6.2 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849 - github.com/FloatTech/zbputils v1.6.2-0.20230410044605-e29b18e837d6 + github.com/FloatTech/zbputils v1.6.2-0.20230410055211-f3613fe56d77 github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 diff --git a/go.sum b/go.sum index c90a1a7be9..e78b1adbc3 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJG github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849 h1:ARKWV3tXJLENWY6vcwTStEDwJckYnxoHXgZMsuJ3gUw= github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849/go.mod h1:IagyEhY38VcbbQgVRzAM9f9mhaUn90rM5BTPfudtl1g= -github.com/FloatTech/zbputils v1.6.2-0.20230410044605-e29b18e837d6 h1:HudMAKOnRz/TmDGE2VTl9Ud0lSp8N7dEaPivAE4rJfo= -github.com/FloatTech/zbputils v1.6.2-0.20230410044605-e29b18e837d6/go.mod h1:GLuSpLdTOCpqkR1oxqjuDz/rOif/ZrH4zGhtMzBqlqo= +github.com/FloatTech/zbputils v1.6.2-0.20230410055211-f3613fe56d77 h1:D0wY+mcPnM8WxX1YWRV0MN4uGG1vfjpOLMRr49RSWoI= +github.com/FloatTech/zbputils v1.6.2-0.20230410055211-f3613fe56d77/go.mod h1:GLuSpLdTOCpqkR1oxqjuDz/rOif/ZrH4zGhtMzBqlqo= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= From d49224fd5073e66aa1859cc27fe84bae61cf079e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 10 Apr 2023 14:16:00 +0800 Subject: [PATCH 50/95] =?UTF-8?q?=F0=9F=90=9B=20fix=20ca?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a8a1abf0b6..ee633571bc 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/FloatTech/sqlite v1.6.2 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849 - github.com/FloatTech/zbputils v1.6.2-0.20230410055211-f3613fe56d77 + github.com/FloatTech/zbputils v1.6.2-0.20230410061454-ebe31ef5cae8 github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 diff --git a/go.sum b/go.sum index e78b1adbc3..095a36944e 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJG github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849 h1:ARKWV3tXJLENWY6vcwTStEDwJckYnxoHXgZMsuJ3gUw= github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849/go.mod h1:IagyEhY38VcbbQgVRzAM9f9mhaUn90rM5BTPfudtl1g= -github.com/FloatTech/zbputils v1.6.2-0.20230410055211-f3613fe56d77 h1:D0wY+mcPnM8WxX1YWRV0MN4uGG1vfjpOLMRr49RSWoI= -github.com/FloatTech/zbputils v1.6.2-0.20230410055211-f3613fe56d77/go.mod h1:GLuSpLdTOCpqkR1oxqjuDz/rOif/ZrH4zGhtMzBqlqo= +github.com/FloatTech/zbputils v1.6.2-0.20230410061454-ebe31ef5cae8 h1:JvS9yJs4apTKamrk+af/wMNjMCovXLiyDBGVKgVABTU= +github.com/FloatTech/zbputils v1.6.2-0.20230410061454-ebe31ef5cae8/go.mod h1:GLuSpLdTOCpqkR1oxqjuDz/rOif/ZrH4zGhtMzBqlqo= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= From 1bad611018cc2e93676f95436d9ef13ff97ddef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 10 Apr 2023 14:21:27 +0800 Subject: [PATCH 51/95] =?UTF-8?q?=F0=9F=8E=A8=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ee633571bc..2e329a8b87 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/FloatTech/sqlite v1.6.2 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849 - github.com/FloatTech/zbputils v1.6.2-0.20230410061454-ebe31ef5cae8 + github.com/FloatTech/zbputils v1.6.2-0.20230410061920-5cc4e86b882b github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 diff --git a/go.sum b/go.sum index 095a36944e..9e62f147f6 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJG github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849 h1:ARKWV3tXJLENWY6vcwTStEDwJckYnxoHXgZMsuJ3gUw= github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849/go.mod h1:IagyEhY38VcbbQgVRzAM9f9mhaUn90rM5BTPfudtl1g= -github.com/FloatTech/zbputils v1.6.2-0.20230410061454-ebe31ef5cae8 h1:JvS9yJs4apTKamrk+af/wMNjMCovXLiyDBGVKgVABTU= -github.com/FloatTech/zbputils v1.6.2-0.20230410061454-ebe31ef5cae8/go.mod h1:GLuSpLdTOCpqkR1oxqjuDz/rOif/ZrH4zGhtMzBqlqo= +github.com/FloatTech/zbputils v1.6.2-0.20230410061920-5cc4e86b882b h1:SKiGdj1CpeBAmIFF5OvdgdDbSA+nUKj4zcZF/Jb4D2k= +github.com/FloatTech/zbputils v1.6.2-0.20230410061920-5cc4e86b882b/go.mod h1:GLuSpLdTOCpqkR1oxqjuDz/rOif/ZrH4zGhtMzBqlqo= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= From 28cb0491f7c79307bf444865f34ec66f16cebbd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 10 Apr 2023 23:28:21 +0800 Subject: [PATCH 52/95] =?UTF-8?q?=F0=9F=90=9B=20fix=20ca?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2e329a8b87..d77fc8bbf2 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/FloatTech/sqlite v1.6.2 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849 - github.com/FloatTech/zbputils v1.6.2-0.20230410061920-5cc4e86b882b + github.com/FloatTech/zbputils v1.6.2-0.20230410152717-6fc617e7c2fb github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 diff --git a/go.sum b/go.sum index 9e62f147f6..63a3dd434a 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJG github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849 h1:ARKWV3tXJLENWY6vcwTStEDwJckYnxoHXgZMsuJ3gUw= github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849/go.mod h1:IagyEhY38VcbbQgVRzAM9f9mhaUn90rM5BTPfudtl1g= -github.com/FloatTech/zbputils v1.6.2-0.20230410061920-5cc4e86b882b h1:SKiGdj1CpeBAmIFF5OvdgdDbSA+nUKj4zcZF/Jb4D2k= -github.com/FloatTech/zbputils v1.6.2-0.20230410061920-5cc4e86b882b/go.mod h1:GLuSpLdTOCpqkR1oxqjuDz/rOif/ZrH4zGhtMzBqlqo= +github.com/FloatTech/zbputils v1.6.2-0.20230410152717-6fc617e7c2fb h1:qaNGMdblE/Ix3xbBcnTOYCjKVNy2W8JXuUAqJHuMTAI= +github.com/FloatTech/zbputils v1.6.2-0.20230410152717-6fc617e7c2fb/go.mod h1:GLuSpLdTOCpqkR1oxqjuDz/rOif/ZrH4zGhtMzBqlqo= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= From 292fc311d67737b224c8bbea22d5ee31ef68cc20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=9C=E8=93=BF=E7=B4=AB?= <68104673+medicago087@users.noreply.github.com> Date: Tue, 11 Apr 2023 11:56:24 +0800 Subject: [PATCH 53/95] fix dish.go (#661) --- plugin/dish/dish.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugin/dish/dish.go b/plugin/dish/dish.go index 714715f17b..e70b0f4b6e 100644 --- a/plugin/dish/dish.go +++ b/plugin/dish/dish.go @@ -43,9 +43,9 @@ func init() { logrus.Warnln("[dish]获取菜谱数据库文件失败") } else if err = db.Open(time.Hour * 24); err != nil { logrus.Warnln("[dish]连接菜谱数据库失败") - } else if err = db.Create("dishes", &dish{}); err != nil { + } else if err = db.Create("dish", &dish{}); err != nil { logrus.Warnln("[dish]同步菜谱数据表失败") - } else if count, err := db.Count("dishes"); err != nil { + } else if count, err := db.Count("dish"); err != nil { logrus.Warnln("[dish]统计菜谱数据失败") } else { logrus.Infoln("[dish]加载", count, "条菜谱") @@ -77,7 +77,7 @@ func init() { } var d dish - if err := db.Find("dishes", &d, fmt.Sprintf("WHERE name like %%%s%%", dishName)); err != nil { + if err := db.Find("dish", &d, fmt.Sprintf("WHERE name like %%%s%%", dishName)); err != nil { return } @@ -98,7 +98,7 @@ func init() { name := ctx.NickName() var d dish - if err := db.Pick("dishes", &d); err != nil { + if err := db.Pick("dish", &d); err != nil { ctx.SendChain(message.Text("小店好像出错了,暂时端不出菜来惹")) logrus.Warnln("[dish]随机菜谱请求出错:" + err.Error()) return From 8050f12d515f17f17751071b03373147f8aed03b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Tue, 11 Apr 2023 13:59:33 +0800 Subject: [PATCH 54/95] db cache time to time.Hour --- plugin/book_review/book_review.go | 2 +- plugin/chouxianghua/chouxianghua.go | 2 +- plugin/cpstory/cpstory.go | 2 +- plugin/curse/curse.go | 2 +- plugin/diana/data/text.go | 2 +- plugin/dish/dish.go | 2 +- plugin/drift_bottle/main.go | 2 +- plugin/funny/laugh.go | 2 +- plugin/jandan/jandan.go | 2 +- plugin/jptingroom/jptingroom.go | 2 +- plugin/manager/manager.go | 2 +- plugin/nativesetu/data.go | 2 +- plugin/nativesetu/main.go | 2 +- plugin/nihongo/nihongo.go | 2 +- plugin/omikuji/sensou.go | 2 +- plugin/qqwife/command.go | 2 +- plugin/setutime/setu_geter.go | 2 +- plugin/steam/store.go | 2 +- plugin/tiangou/tiangou.go | 2 +- plugin/wenxinAI/wenxinAI.go | 4 ++-- 20 files changed, 21 insertions(+), 21 deletions(-) diff --git a/plugin/book_review/book_review.go b/plugin/book_review/book_review.go index ee2a50c61c..47ba6752e5 100644 --- a/plugin/book_review/book_review.go +++ b/plugin/book_review/book_review.go @@ -27,7 +27,7 @@ func init() { db.DBPath = engine.DataFolder() + "bookreview.db" // os.RemoveAll(dbpath) _, _ = engine.GetLazyData("bookreview.db", true) - err := db.Open(time.Hour * 24) + err := db.Open(time.Hour) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return false diff --git a/plugin/chouxianghua/chouxianghua.go b/plugin/chouxianghua/chouxianghua.go index cfc9d3d223..e4d7ae806a 100644 --- a/plugin/chouxianghua/chouxianghua.go +++ b/plugin/chouxianghua/chouxianghua.go @@ -26,7 +26,7 @@ func init() { db.DBPath = en.DataFolder() + "cxh.db" // os.RemoveAll(dbpath) _, _ = en.GetLazyData("cxh.db", true) - err := db.Open(time.Hour * 24) + err := db.Open(time.Hour) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return false diff --git a/plugin/cpstory/cpstory.go b/plugin/cpstory/cpstory.go index 5a74d1eb72..e44327de81 100644 --- a/plugin/cpstory/cpstory.go +++ b/plugin/cpstory/cpstory.go @@ -27,7 +27,7 @@ func init() { db.DBPath = engine.DataFolder() + "cp.db" // os.RemoveAll(dbpath) _, _ = engine.GetLazyData("cp.db", true) - err := db.Open(time.Hour * 24) + err := db.Open(time.Hour) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return false diff --git a/plugin/curse/curse.go b/plugin/curse/curse.go index c1fe14f368..7116f1e494 100644 --- a/plugin/curse/curse.go +++ b/plugin/curse/curse.go @@ -35,7 +35,7 @@ func init() { ctx.SendChain(message.Text("ERROR: ", err)) return false } - err = db.Open(time.Hour * 24) + err = db.Open(time.Hour) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return false diff --git a/plugin/diana/data/text.go b/plugin/diana/data/text.go index 303ddd9f7b..29b8f621c5 100644 --- a/plugin/diana/data/text.go +++ b/plugin/diana/data/text.go @@ -27,7 +27,7 @@ func LoadText(dbfile string) error { if err != nil { return err } - err = db.Open(time.Hour * 24) + err = db.Open(time.Hour) if err != nil { return err } diff --git a/plugin/dish/dish.go b/plugin/dish/dish.go index 714715f17b..8211ba2740 100644 --- a/plugin/dish/dish.go +++ b/plugin/dish/dish.go @@ -41,7 +41,7 @@ func init() { if _, err := en.GetLazyData("dishes.db", true); err != nil { logrus.Warnln("[dish]获取菜谱数据库文件失败") - } else if err = db.Open(time.Hour * 24); err != nil { + } else if err = db.Open(time.Hour); err != nil { logrus.Warnln("[dish]连接菜谱数据库失败") } else if err = db.Create("dishes", &dish{}); err != nil { logrus.Warnln("[dish]同步菜谱数据表失败") diff --git a/plugin/drift_bottle/main.go b/plugin/drift_bottle/main.go index 0d7f5b2f41..1417f251bd 100644 --- a/plugin/drift_bottle/main.go +++ b/plugin/drift_bottle/main.go @@ -40,7 +40,7 @@ func init() { PrivateDataFolder: "driftbottle", }) seaSide.DBPath = en.DataFolder() + "sea.db" - err := seaSide.Open(time.Hour * 24) + err := seaSide.Open(time.Hour) if err != nil { panic(err) } diff --git a/plugin/funny/laugh.go b/plugin/funny/laugh.go index b64be4094a..86d28077b9 100644 --- a/plugin/funny/laugh.go +++ b/plugin/funny/laugh.go @@ -38,7 +38,7 @@ func init() { ctx.SendChain(message.Text("ERROR: ", err)) return false } - err = db.Open(time.Hour * 24) + err = db.Open(time.Hour) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return false diff --git a/plugin/jandan/jandan.go b/plugin/jandan/jandan.go index 4e6a8ef51f..3c54cfbe44 100644 --- a/plugin/jandan/jandan.go +++ b/plugin/jandan/jandan.go @@ -33,7 +33,7 @@ func init() { getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool { db.DBPath = engine.DataFolder() + "pics.db" _, _ = engine.GetLazyData("pics.db", false) - err := db.Open(time.Hour * 24) + err := db.Open(time.Hour) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return false diff --git a/plugin/jptingroom/jptingroom.go b/plugin/jptingroom/jptingroom.go index 109e15c288..a901a2e32b 100644 --- a/plugin/jptingroom/jptingroom.go +++ b/plugin/jptingroom/jptingroom.go @@ -32,7 +32,7 @@ func init() { // 插件主体 ctx.SendChain(message.Text("ERROR: ", err)) return false } - err = db.Open(time.Hour * 24) + err = db.Open(time.Hour) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return false diff --git a/plugin/manager/manager.go b/plugin/manager/manager.go index a48b3e8492..17fe0502c7 100644 --- a/plugin/manager/manager.go +++ b/plugin/manager/manager.go @@ -73,7 +73,7 @@ func init() { // 插件主体 go func() { db.DBPath = engine.DataFolder() + "config.db" - err := db.Open(time.Hour * 24) + err := db.Open(time.Hour) if err != nil { panic(err) } diff --git a/plugin/nativesetu/data.go b/plugin/nativesetu/data.go index b1cbe72e6c..e9a37c66e4 100644 --- a/plugin/nativesetu/data.go +++ b/plugin/nativesetu/data.go @@ -47,7 +47,7 @@ func (n *nsetu) scanall(path string) error { root := os.DirFS(path) _ = n.db.Close() _ = os.Remove(n.db.DBPath) - err := n.db.Open(time.Hour * 24) + err := n.db.Open(time.Hour) if err != nil { return err } diff --git a/plugin/nativesetu/main.go b/plugin/nativesetu/main.go index cec363d847..6e7ef67971 100644 --- a/plugin/nativesetu/main.go +++ b/plugin/nativesetu/main.go @@ -43,7 +43,7 @@ func init() { logrus.Infoln("[nsetu] set setu dir to", setupath) } } - err := ns.db.Open(time.Hour * 24) + err := ns.db.Open(time.Hour) if err != nil { panic(err) } diff --git a/plugin/nihongo/nihongo.go b/plugin/nihongo/nihongo.go index f7b172bdef..842c85689a 100644 --- a/plugin/nihongo/nihongo.go +++ b/plugin/nihongo/nihongo.go @@ -30,7 +30,7 @@ func init() { ctx.SendChain(message.Text("ERROR: ", err)) return false } - err = db.Open(time.Hour * 24) + err = db.Open(time.Hour) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return false diff --git a/plugin/omikuji/sensou.go b/plugin/omikuji/sensou.go index 08b5539c77..0fd84a6a02 100644 --- a/plugin/omikuji/sensou.go +++ b/plugin/omikuji/sensou.go @@ -54,7 +54,7 @@ func init() { // 插件主体 ctx.SendChain(message.Text("ERROR: ", err)) return false } - err = db.Open(time.Hour * 24) + err = db.Open(time.Hour) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return false diff --git a/plugin/qqwife/command.go b/plugin/qqwife/command.go index c215be19bc..bfc1696ff5 100644 --- a/plugin/qqwife/command.go +++ b/plugin/qqwife/command.go @@ -82,7 +82,7 @@ var ( )) getdb = fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool { 民政局.db.DBPath = engine.DataFolder() + "结婚登记表.db" - err := 民政局.db.Open(time.Hour * 24) + err := 民政局.db.Open(time.Hour) if err == nil { // 创建群配置表 err = 民政局.db.Create("updateinfo", &updateinfo{}) diff --git a/plugin/setutime/setu_geter.go b/plugin/setutime/setu_geter.go index b03c3328f9..b78ab10359 100644 --- a/plugin/setutime/setu_geter.go +++ b/plugin/setutime/setu_geter.go @@ -66,7 +66,7 @@ func init() { // 插件主体 // 如果数据库不存在则下载 pool.db.DBPath = engine.DataFolder() + "SetuTime.db" _, _ = engine.GetLazyData("SetuTime.db", false) - err := pool.db.Open(time.Hour * 24) + err := pool.db.Open(time.Hour) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return false diff --git a/plugin/steam/store.go b/plugin/steam/store.go index e68aa71994..3e49422188 100644 --- a/plugin/steam/store.go +++ b/plugin/steam/store.go @@ -17,7 +17,7 @@ var ( // 开启并检查数据库链接 getDB = fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool { database.db.DBPath = engine.DataFolder() + "steam.db" - err := database.db.Open(time.Hour * 24) + err := database.db.Open(time.Hour) if err != nil { ctx.SendChain(message.Text("[steam] ERROR: ", err)) return false diff --git a/plugin/tiangou/tiangou.go b/plugin/tiangou/tiangou.go index 05a69b72b8..102975745d 100644 --- a/plugin/tiangou/tiangou.go +++ b/plugin/tiangou/tiangou.go @@ -37,7 +37,7 @@ func init() { ctx.SendChain(message.Text("ERROR: ", err)) return false } - err = db.Open(time.Hour * 24) + err = db.Open(time.Hour) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return false diff --git a/plugin/wenxinAI/wenxinAI.go b/plugin/wenxinAI/wenxinAI.go index a4d2e3168b..9f1c379091 100644 --- a/plugin/wenxinAI/wenxinAI.go +++ b/plugin/wenxinAI/wenxinAI.go @@ -100,7 +100,7 @@ func init() { // 插件主体 )) getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool { vilginfo.db.DBPath = engine.DataFolder() + "ernieVilg.db" - err := vilginfo.db.Open(time.Hour * 24) + err := vilginfo.db.Open(time.Hour) if err != nil { ctx.SendChain(message.Text(serviceErr, err)) return false @@ -302,7 +302,7 @@ func init() { // 插件主体 )) getmodeldb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool { modelinfo.db.DBPath = engine.DataFolder() + "ernieModel.db" - err := modelinfo.db.Open(time.Hour * 24) + err := modelinfo.db.Open(time.Hour) if err != nil { ctx.SendChain(message.Text(modelErr, err)) return false From 8edc3f6de62982ad5b7776361990110663919191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Tue, 11 Apr 2023 14:00:06 +0800 Subject: [PATCH 55/95] update deps --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index d77fc8bbf2..c9538d54b5 100644 --- a/go.mod +++ b/go.mod @@ -11,8 +11,8 @@ require ( github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9 github.com/FloatTech/sqlite v1.6.2 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b - github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849 - github.com/FloatTech/zbputils v1.6.2-0.20230410152717-6fc617e7c2fb + github.com/FloatTech/zbpctrl v1.5.3-0.20230411055601-7cdff751dd67 + github.com/FloatTech/zbputils v1.6.2-0.20230411055746-43ba9566c674 github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 diff --git a/go.sum b/go.sum index 63a3dd434a..458327d49f 100644 --- a/go.sum +++ b/go.sum @@ -16,10 +16,10 @@ github.com/FloatTech/sqlite v1.6.2 h1:FytbExjpvYalZxxITtmSenHiPGLPUvlz47LY/P0SCC github.com/FloatTech/sqlite v1.6.2/go.mod h1:zFbHzRfB+CJ+VidfjuVbrcin3DAz283F7hF1hIeHzpY= github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJGLDNIdRX3BI546D3O7k7vrVueZw= github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= -github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849 h1:ARKWV3tXJLENWY6vcwTStEDwJckYnxoHXgZMsuJ3gUw= -github.com/FloatTech/zbpctrl v1.5.3-0.20230408032827-50ef967f2849/go.mod h1:IagyEhY38VcbbQgVRzAM9f9mhaUn90rM5BTPfudtl1g= -github.com/FloatTech/zbputils v1.6.2-0.20230410152717-6fc617e7c2fb h1:qaNGMdblE/Ix3xbBcnTOYCjKVNy2W8JXuUAqJHuMTAI= -github.com/FloatTech/zbputils v1.6.2-0.20230410152717-6fc617e7c2fb/go.mod h1:GLuSpLdTOCpqkR1oxqjuDz/rOif/ZrH4zGhtMzBqlqo= +github.com/FloatTech/zbpctrl v1.5.3-0.20230411055601-7cdff751dd67 h1:KGfXWryE3VGFDC8Z6661d/7xm8oLNPpFB5ODb7DqYJc= +github.com/FloatTech/zbpctrl v1.5.3-0.20230411055601-7cdff751dd67/go.mod h1:gkGC1C1eEUd/Ld/ja68zas5j2ZktIZCdnj2FMaM+Au0= +github.com/FloatTech/zbputils v1.6.2-0.20230411055746-43ba9566c674 h1:AIUsaEd3axQqivto9xemoZzVxwHgJXRyIeDM4YwISo0= +github.com/FloatTech/zbputils v1.6.2-0.20230411055746-43ba9566c674/go.mod h1:m3IW5z7vLMNgNtVNUfcYtOF1du6PnjckifdRK2hVjA0= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= From c1e37b293c08843ffbfb69754b5f01f6d5a6df35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Tue, 11 Apr 2023 19:48:32 +0800 Subject: [PATCH 56/95] remove ca --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c9538d54b5..9606d9c85c 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/FloatTech/sqlite v1.6.2 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b github.com/FloatTech/zbpctrl v1.5.3-0.20230411055601-7cdff751dd67 - github.com/FloatTech/zbputils v1.6.2-0.20230411055746-43ba9566c674 + github.com/FloatTech/zbputils v1.6.2-0.20230411114057-4c71136244b2 github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 diff --git a/go.sum b/go.sum index 458327d49f..89974bb1ec 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJG github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= github.com/FloatTech/zbpctrl v1.5.3-0.20230411055601-7cdff751dd67 h1:KGfXWryE3VGFDC8Z6661d/7xm8oLNPpFB5ODb7DqYJc= github.com/FloatTech/zbpctrl v1.5.3-0.20230411055601-7cdff751dd67/go.mod h1:gkGC1C1eEUd/Ld/ja68zas5j2ZktIZCdnj2FMaM+Au0= -github.com/FloatTech/zbputils v1.6.2-0.20230411055746-43ba9566c674 h1:AIUsaEd3axQqivto9xemoZzVxwHgJXRyIeDM4YwISo0= -github.com/FloatTech/zbputils v1.6.2-0.20230411055746-43ba9566c674/go.mod h1:m3IW5z7vLMNgNtVNUfcYtOF1du6PnjckifdRK2hVjA0= +github.com/FloatTech/zbputils v1.6.2-0.20230411114057-4c71136244b2 h1:Dx64RjcbxhsOHinykOPAlYqvPd9tE375IQrWqlNmDXs= +github.com/FloatTech/zbputils v1.6.2-0.20230411114057-4c71136244b2/go.mod h1:m3IW5z7vLMNgNtVNUfcYtOF1du6PnjckifdRK2hVjA0= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= From 3e157540312f6c46b87f443d390ccb112c17141f Mon Sep 17 00:00:00 2001 From: weigui404 <74092436+weigui404@users.noreply.github.com> Date: Wed, 12 Apr 2023 00:34:33 +0800 Subject: [PATCH 57/95] Update shindan.go (#662) --- plugin/shindan/shindan.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/shindan/shindan.go b/plugin/shindan/shindan.go index 9ce3c0e547..57d8d8aee6 100644 --- a/plugin/shindan/shindan.go +++ b/plugin/shindan/shindan.go @@ -20,7 +20,7 @@ func init() { Help: "- 今天是什么少女[@xxx]\n" + "- 异世界转生[@xxx]\n" + "- 卖萌[@xxx]\n" + - "- 抽老婆[@xxx]\n" + + "- 今日老婆[@xxx]\n" + "- 黄油角色[@xxx]", }) engine.OnPrefix("异世界转生", number(587874)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic) From c5c63d0b646d80c9e709905442c308dbb2ef648a Mon Sep 17 00:00:00 2001 From: GenesisAN Date: Wed, 12 Apr 2023 14:02:49 +0800 Subject: [PATCH 58/95] =?UTF-8?q?wfapi=20=E9=94=81=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=8C=E8=AE=BE=E7=BD=AETLS=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E4=B8=BA1.2=20(#663)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: GenesisAN <501946815@qq.com> --- plugin/warframeapi/api.go | 13 +++++++++++-- plugin/warframeapi/world.go | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/plugin/warframeapi/api.go b/plugin/warframeapi/api.go index d4a3de2803..fd4d43df78 100644 --- a/plugin/warframeapi/api.go +++ b/plugin/warframeapi/api.go @@ -1,6 +1,7 @@ package warframeapi import ( + "crypto/tls" "encoding/json" "errors" "fmt" @@ -30,7 +31,11 @@ func newwfapi() (w wfapi, err error) { // 获取Warframe市场的售价表,并进行排序,cn_name为物品中文名称,onlyMaxRank表示只取最高等级的物品,返回物品售价表,物品信息,物品英文 func getitemsorder(cnName string, onlyMaxRank bool) (od orders, it *itemsInSet, n string, err error) { var wfapiio wfAPIItemsOrders - data, err := web.RequestDataWithHeaders(&http.Client{}, fmt.Sprintf("https://api.warframe.market/v1/items/%s/orders?include=item", cnName), "GET", func(request *http.Request) error { + data, err := web.RequestDataWithHeaders(&http.Client{Transport: &http.Transport{ + TLSClientConfig: &tls.Config{ + MinVersion: tls.VersionTLS12, + }, + }}, fmt.Sprintf("https://api.warframe.market/v1/items/%s/orders?include=item", cnName), "GET", func(request *http.Request) error { request.Header.Add("Accept", "application/json") request.Header.Add("Platform", "pc") return nil @@ -87,7 +92,11 @@ var ( func newwm() (*wmdata, error) { var itemapi wfAPIItem // WarFrame市场的数据实例 var wd wmdata - data, err := web.RequestDataWithHeaders(&http.Client{}, wfitemurl, "GET", func(request *http.Request) error { + data, err := web.RequestDataWithHeaders(&http.Client{Transport: &http.Transport{ + TLSClientConfig: &tls.Config{ + MinVersion: tls.VersionTLS12, + }, + }}, wfitemurl, "GET", func(request *http.Request) error { request.Header.Add("Accept", "application/json") request.Header.Add("Language", "zh-hans") return nil diff --git a/plugin/warframeapi/world.go b/plugin/warframeapi/world.go index 814abdd4b2..cef0d15d5b 100644 --- a/plugin/warframeapi/world.go +++ b/plugin/warframeapi/world.go @@ -81,6 +81,9 @@ func (w *world) refresh(api *wfapi) { w.w[2].NextTime = api.CambionCycle.Expiry.Local() w.w[2].IsDay = api.CambionCycle.Active == "fass" + for _, t := range w.w { + t.Unlock() + } } // 游戏时间更新 From f35a89e401180f3815eee9228ea358742ae16e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sat, 15 Apr 2023 13:13:37 +0800 Subject: [PATCH 59/95] update deps --- data | 2 +- go.mod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data b/data index 1e64e7cf82..074abee575 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit 1e64e7cf82a24b6d0a231f3cfd474dcbd4d52781 +Subproject commit 074abee575503b5c66c57a2b3aa28fe40c6b215e diff --git a/go.mod b/go.mod index 9606d9c85c..0539f236c8 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,6 @@ require ( github.com/fumiama/go-base16384 v1.6.4 github.com/fumiama/go-registry v0.2.6 github.com/fumiama/gotracemoe v0.0.3 - github.com/fumiama/imgsz v0.0.2 github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565 github.com/fumiama/unibase2n v0.0.0-20221020155353-02876e777430 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 @@ -52,6 +51,7 @@ require ( github.com/faiface/beep v1.1.0 // indirect github.com/fumiama/go-simple-protobuf v0.1.0 // indirect github.com/fumiama/gofastTEA v0.0.10 // indirect + github.com/fumiama/imgsz v0.0.2 // indirect github.com/gabriel-vasile/mimetype v1.0.4 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect From 3d8d0ad1071d0ed3277543d4ff159da47ef708bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=B2=E5=AE=9D=E5=9D=8F=E5=9D=8F=E5=9D=8F?= <2758988938@qq.com> Date: Sat, 15 Apr 2023 15:32:09 +0800 Subject: [PATCH 60/95] =?UTF-8?q?fix=20=E6=9D=83=E9=87=8D=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=20(#666)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/quan/quan.go | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/plugin/quan/quan.go b/plugin/quan/quan.go index 1584badf64..07271ddb15 100644 --- a/plugin/quan/quan.go +++ b/plugin/quan/quan.go @@ -2,7 +2,7 @@ package quan import ( - "fmt" + "encoding/json" "strconv" "strings" @@ -11,13 +11,18 @@ import ( "github.com/FloatTech/zbputils/control" zero "github.com/wdvxdr1123/ZeroBot" "github.com/wdvxdr1123/ZeroBot/message" - "github.com/wdvxdr1123/ZeroBot/utils/helper" ) const ( - quan = "http://tc.tfkapi.top/API/qqqz.php?qq=%v" // api + quan = "http://tfapi.top/API/qqqz.php?type=json&qq=" // api ) +type result struct { + Code int `json:"code"` + Msg string `json:"msg"` + Qz string `json:"qz"` +} + func init() { // 主函数 en := control.Register("quan", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, @@ -31,28 +36,25 @@ func init() { // 主函数 if str == "" { // user str = strconv.FormatInt(ctx.Event.UserID, 10) } - es, err := web.GetData(fmt.Sprintf(quan, str)) // 将网站返回结果赋值 + es, err := web.GetData(quan + str) // 将网站返回结果赋值 if err != nil { - ctx.SendChain(message.Text("出现错误捏:", err)) - return - } - if len(helper.BytesToString(es)) <= 24 { - ctx.SendChain(message.Text("网站维护中")) // 输出结果 + ctx.SendChain(message.Text("出现错误捏: ", err)) return } - f := helper.BytesToString(es)[24:] - _, err = strconv.Atoi(f) + var data result + err = json.Unmarshal(es, &data) if err != nil { - ctx.SendChain(message.Text("网站维护中")) // 输出结果 + ctx.SendChain(message.Text("解析json错误: ", err)) return } var msg strings.Builder - msg.WriteString("查询账号:") + msg.WriteString("查询账号: ") msg.WriteString(str) msg.WriteString("\n") - msg.WriteString("查询状态:成功\n") - msg.WriteString("您的权重为:") - msg.WriteString(f) + msg.WriteString("查询状态: ") + msg.WriteString(data.Msg) + msg.WriteString("\n您的权重为: ") + msg.WriteString(data.Qz) ctx.SendChain(message.Text(msg.String())) // 输出结果 }) } From 667c9fbcca8770303974b2c870b0abb2d700ab3b Mon Sep 17 00:00:00 2001 From: himawari <54976075+guohuiyuan@users.noreply.github.com> Date: Mon, 17 Apr 2023 11:23:37 +0800 Subject: [PATCH 61/95] =?UTF-8?q?=E2=9C=A8=20=E6=B7=BB=E5=8A=A0=E6=8D=AE?= =?UTF-8?q?=E6=84=8F=E6=9F=A5=E5=8F=A5=20(#660)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 +- main.go | 7 +- plugin/wantquotes/wantquotes.go | 203 ++++++++++++++++++++++++++++++++ 3 files changed, 218 insertions(+), 4 deletions(-) create mode 100644 plugin/wantquotes/wantquotes.go diff --git a/README.md b/README.md index c85f4c8e1a..cd4a0387c1 100644 --- a/README.md +++ b/README.md @@ -1386,7 +1386,17 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] 来份网易云热评 -
+
+
+ 据意查句 + + `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wantquotes"` + + - [x] 据意查句 大海 + + - [x] 登录据意查句 + +
星际战甲 diff --git a/main.go b/main.go index 2086330ea2..dd83f0892b 100644 --- a/main.go +++ b/main.go @@ -142,6 +142,7 @@ import ( _ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtbmusic" // vtb点歌 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wallet" // 钱包 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wangyiyun" // 网易云音乐热评 + _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wantquotes" // 据意查句 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/warframeapi" // warframeAPI插件 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenben" // 文本指令大全 _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenxinAI" // 百度文心AI画图 @@ -257,6 +258,9 @@ func init() { // sus = append(sus, 12345678) // sus = append(sus, 87654321) + // 启用 webui + // go webctrl.RunGui(*g) + if *runcfg != "" { f, err := os.Open(*runcfg) if err != nil { @@ -302,9 +306,6 @@ func init() { logrus.Infoln("[main] 配置文件已保存到", *save) os.Exit(0) } - - // 启用 webui - // go webctrl.RunGui(*g) } func main() { diff --git a/plugin/wantquotes/wantquotes.go b/plugin/wantquotes/wantquotes.go new file mode 100644 index 0000000000..25cb036128 --- /dev/null +++ b/plugin/wantquotes/wantquotes.go @@ -0,0 +1,203 @@ +// Package wantquotes 据意查句 +package wantquotes + +import ( + "encoding/json" + "fmt" + "net/url" + "strconv" + "strings" + "time" + + "github.com/FloatTech/floatbox/binary" + "github.com/FloatTech/floatbox/web" + ctrl "github.com/FloatTech/zbpctrl" + "github.com/FloatTech/zbputils/control" + "github.com/FloatTech/zbputils/ctxext" + "github.com/FloatTech/zbputils/img/text" + "github.com/sirupsen/logrus" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" +) + +const ( + wantquotesURL = "https://wantquotes.net" + getQrcode = "/api/get_qrcode/" + showqrcode = "https://mp.weixin.qq.com/cgi-bin/showqrcode" + loginCheck = "/api/login_check/" + semantic = "/api/semantic/" + semanticURL = wantquotesURL + semantic + "?query=%s&type=%s&unionid=%s&secret=%s" +) + +var ( + typeList = [...]string{"现", "现-名言", "现-佳句", "现-佳句-文学", "现-佳句-诗歌", "现-佳句-其他", "现-网络", "现-台词", "现-台词-影视剧", "现-台词-动漫", "现-台词-综艺", + "古", "谚", "谚-谚语", "谚-俗语", "谚-惯用语", "歇"} +) + +type getQrcodeRsp struct { + Ticket string `json:"ticket"` + SceneID string `json:"scene_id"` +} + +type loginCheckRsp struct { + Login int `json:"login"` + Secret string `json:"secret"` + Unionid string `json:"unionid"` +} + +type semanticRsp struct { + Quotes []Quotes `json:"quotes"` + TopSim float64 `json:"top_sim"` +} + +// Quotes 名句结构体 +type Quotes struct { + Quote string `json:"quote"` + SourceType string `json:"source_type"` + Author string `json:"author"` + Work string `json:"work"` + ID int `json:"id"` +} + +func init() { + engine := control.Register("wantquotes", &ctrl.Options[*zero.Ctx]{ + DisableOnDefault: false, + Extra: control.ExtraFromString("wantquotes"), + Brief: "据意查句", + Help: "- 据意查句 大海 (需登录据意查句)\n" + + "- 登录据意查句", + PrivateDataFolder: "wantquotes", + }) + + // 开启 + engine.OnRegex(`^据意查句\s?(.{1,25})$`, getPara).SetBlock(true).Handle(func(ctx *zero.Ctx) { + keyword := ctx.State["regex_matched"].([]string)[1] + quotesType := ctx.State["quotesType"].(string) + var key string + manager := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) + err := manager.GetExtra(&key) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + logrus.Debugln("[wantquotes] get api key:", key) + unionid, secret, _ := strings.Cut(key, "|") + apiURL := fmt.Sprintf(semanticURL, url.QueryEscape(keyword), url.QueryEscape(quotesType), url.QueryEscape(unionid), url.QueryEscape(secret)) + data, err := web.RequestDataWith(web.NewDefaultClient(), apiURL, "GET", wantquotesURL, web.RandUA(), nil) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + var rsp semanticRsp + err = json.Unmarshal(data, &rsp) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + m := make(message.Message, 0, len(rsp.Quotes)) + text := strings.Builder{} + for _, v := range rsp.Quotes { + text.WriteString(v.Quote) + text.WriteString("\n—— ") + text.WriteString(v.Author) + text.WriteString(" 《") + text.WriteString(v.Work) + text.WriteString("》") + m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text(text.String()))) + text.Reset() + } + if id := ctx.Send(m).ID(); id == 0 { + ctx.SendChain(message.Text("ERROR: 可能被风控或下载图片用时过长,请耐心等待")) + } + }) + engine.OnFullMatch(`登录据意查句`, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) { + getQrcodeData, err := web.RequestDataWith(web.NewDefaultClient(), wantquotesURL+getQrcode, "GET", wantquotesURL, web.RandUA(), nil) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + var qrRsp getQrcodeRsp + err = json.Unmarshal(getQrcodeData, &qrRsp) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + showQrcodeData, err := web.RequestDataWith(web.NewDefaultClient(), showqrcode+"?ticket="+qrRsp.Ticket, "GET", "", web.RandUA(), nil) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + ctx.SendChain(message.Text("WantQuotes\n微信扫码登录\n首次登录需关注公众号")) + ctx.SendChain(message.ImageBytes(showQrcodeData)) + + ticker := time.NewTicker(2 * time.Second) // 创建每秒触发一次的定时器 + defer ticker.Stop() + count := 0 + for range ticker.C { + count++ + if count == 60 { + ctx.SendChain(message.Text("据意查句登录超时,请重新登录")) + return + } + loginCheckData, err := web.RequestDataWith(web.NewDefaultClient(), wantquotesURL+loginCheck+"?scene_id="+qrRsp.SceneID, "GET", "", web.RandUA(), nil) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + var lcr loginCheckRsp + err = json.Unmarshal(loginCheckData, &lcr) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + if lcr.Login == 1 { + manager := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) + err := manager.SetExtra(lcr.Unionid + "|" + lcr.Secret) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + ctx.SendChain(message.Text("据意查句登录成功")) + return + } + } + }) +} + +func getPara(ctx *zero.Ctx) bool { + next := zero.NewFutureEvent("message", 999, false, ctx.CheckSession()) + recv, cancel := next.Repeat() + defer cancel() + tex := strings.Builder{} + tex.WriteString("请下列选择查询名句的类型\n") + for i, v := range typeList { + tex.WriteString(strconv.Itoa(i)) + tex.WriteString(". ") + tex.WriteString(v) + tex.WriteString("\n") + } + base64Str, err := text.RenderToBase64(tex.String(), text.FontFile, 400, 20) + if err != nil { + ctx.SendChain(message.Text("图片生成错误了, ", zero.BotConfig.NickName[0], "帮你选择查询名句类型")) + ctx.State["quotesType"] = typeList[0] + return true + } + ctx.SendChain(message.Image("base64://" + binary.BytesToString(base64Str))) + for { + select { + case <-time.After(time.Second * 10): + ctx.SendChain(message.Text("时间太久啦!", zero.BotConfig.NickName[0], "帮你选择查询名句类型")) + ctx.State["quotesType"] = typeList[0] + return true + case c := <-recv: + msg := c.Event.Message.ExtractPlainText() + num, _ := strconv.Atoi(msg) + if num < 0 || num >= len(typeList) { + ctx.SendChain(message.Text("序号非法!")) + continue + } + ctx.State["quotesType"] = typeList[num] + return true + } + } +} From 296fd60cd7c75a10d61922f232e4c0552b6b8cf6 Mon Sep 17 00:00:00 2001 From: GenesisAN Date: Mon, 17 Apr 2023 12:40:45 +0800 Subject: [PATCH 62/95] =?UTF-8?q?=E2=99=BF=EF=B8=8F=20gif=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E4=BD=BF=E7=94=A8base64=E5=8F=91=E9=80=81=20(#664)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 4 +- plugin/gif/gif.go | 200 +++++++++++++++++++++++++++------------------- 3 files changed, 123 insertions(+), 83 deletions(-) diff --git a/go.mod b/go.mod index 0539f236c8..16c2597870 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/FloatTech/AnimeAPI v1.6.1-0.20230409024643-f25135dee0da github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 - github.com/FloatTech/imgfactory v0.2.2-0.20230322091809-b0ddbe44b94b + github.com/FloatTech/imgfactory v0.2.2-0.20230413152719-e101cc3606ef github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9 github.com/FloatTech/sqlite v1.6.2 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b diff --git a/go.sum b/go.sum index 89974bb1ec..867f4bfde1 100644 --- a/go.sum +++ b/go.sum @@ -8,8 +8,8 @@ github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 h1:/eQoMa6Aj3co github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI= github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 h1:dPLeoiTVSBlgls+66EB/UJ2e38BaASmBN5nANaycSBU= github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08/go.mod h1:uzPzAeT35egARdRuu+1oyjU3CmTwCceoq3Vvje7LpcI= -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/imgfactory v0.2.2-0.20230413152719-e101cc3606ef h1:CJbK/2FRwPuZpeb6M4sWK2d7oXDnBEGhpkQuQrgc91A= +github.com/FloatTech/imgfactory v0.2.2-0.20230413152719-e101cc3606ef/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.6.2 h1:FytbExjpvYalZxxITtmSenHiPGLPUvlz47LY/P0SCCw= diff --git a/plugin/gif/gif.go b/plugin/gif/gif.go index 1174f2f5a3..8c98fd63de 100644 --- a/plugin/gif/gif.go +++ b/plugin/gif/gif.go @@ -19,7 +19,7 @@ func mo(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - name := cc.usrdir + "摸.gif" + //name := cc.usrdir + "摸.gif" c := dlrange("mo", 5, &wg, func(e error) { m.Lock() errwg = e @@ -44,7 +44,8 @@ func mo(cc *context, value ...string) (string, error) { imgs[3].InsertBottom(tou, 85, 75, 27, 37).Image(), imgs[4].InsertBottom(tou, 90, 70, 22, 42).Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(1, mo)) + g := imgfactory.MergeGif(1, mo) + return imgfactory.GIF2Base64(g) } // cuo 搓 @@ -53,7 +54,7 @@ func cuo(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - name := cc.usrdir + "搓.gif" + //name := cc.usrdir + "搓.gif" c := dlrange("cuo", 5, &wg, func(e error) { m.Lock() errwg = e @@ -82,7 +83,8 @@ func cuo(cc *context, value ...string) (string, error) { imgs[3].InsertBottomC(m3.Image(), 0, 0, 75, 130).Image(), imgs[4].InsertBottomC(m4.Image(), 0, 0, 75, 130).Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(5, cuo)) + g := imgfactory.MergeGif(5, cuo) + return imgfactory.GIF2Base64(g) } // qiao 敲 @@ -91,7 +93,7 @@ func qiao(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - name := cc.usrdir + "敲.gif" + //name := cc.usrdir + "敲.gif" c := dlrange("qiao", 2, &wg, func(e error) { m.Lock() errwg = e @@ -113,7 +115,8 @@ func qiao(cc *context, value ...string) (string, error) { imgs[0].InsertUp(tou, 40, 33, 57, 52).Image(), imgs[1].InsertUp(tou, 38, 36, 58, 50).Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(1, qiao)) + g := imgfactory.MergeGif(1, qiao) + return imgfactory.GIF2Base64(g) } // chi 吃 @@ -122,7 +125,7 @@ func chi(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - name := cc.usrdir + "吃.gif" + //name := cc.usrdir + "吃.gif" c := dlrange("chi", 3, &wg, func(e error) { m.Lock() errwg = e @@ -145,7 +148,8 @@ func chi(cc *context, value ...string) (string, error) { imgs[1].InsertBottom(tou, 0, 0, 1, 38).Image(), imgs[2].InsertBottom(tou, 0, 0, 1, 38).Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(1, chi)) + g := imgfactory.MergeGif(1, chi) + return imgfactory.GIF2Base64(g) } // ceng 蹭 @@ -154,7 +158,7 @@ func ceng(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - name := cc.usrdir + "蹭.gif" + //name := cc.usrdir + "蹭.gif" c := dlrange("ceng", 6, &wg, func(e error) { m.Lock() errwg = e @@ -184,7 +188,8 @@ func ceng(cc *context, value ...string) (string, error) { imgs[4].InsertUp(tou, 75, 77, 56, 110).InsertUp(imgfactory.Rotate(tou2, -66, 132, 80).Image(), 0, 0, 78, 40).Image(), imgs[5].InsertUp(tou, 75, 77, 62, 102).InsertUp(tou2, 71, 100, 110, 94).Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(8, ceng)) + g := imgfactory.MergeGif(8, ceng) + return imgfactory.GIF2Base64(g) } // ken 啃 @@ -193,7 +198,7 @@ func ken(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - name := cc.usrdir + "啃.gif" + //name := cc.usrdir + "啃.gif" c := dlrange("ken", 16, &wg, func(e error) { m.Lock() errwg = e @@ -229,7 +234,8 @@ func ken(cc *context, value ...string) (string, error) { imgs[14].Image(), imgs[15].Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, ken)) + g := imgfactory.MergeGif(7, ken) + return imgfactory.GIF2Base64(g) } // pai 拍 @@ -238,7 +244,7 @@ func pai(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - name := cc.usrdir + "拍.gif" + //name := cc.usrdir + "拍.gif" c := dlrange("pai", 2, &wg, func(e error) { m.Lock() errwg = e @@ -260,7 +266,8 @@ func pai(cc *context, value ...string) (string, error) { imgs[0].InsertUp(tou, 0, 0, 1, 47).Image(), imgs[1].InsertUp(tou, 0, 0, 1, 67).Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(1, pai)) + g := imgfactory.MergeGif(1, pai) + return imgfactory.GIF2Base64(g) } // xqe 冲 @@ -269,7 +276,7 @@ func xqe(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - name := cc.usrdir + "冲.gif" + //name := cc.usrdir + "冲.gif" c := dlrange("xqe", 2, &wg, func(e error) { m.Lock() errwg = e @@ -291,7 +298,8 @@ func xqe(cc *context, value ...string) (string, error) { imgs[0].InsertUp(tou, 30, 30, 15, 53).Image(), imgs[1].InsertUp(tou, 30, 30, 40, 53).Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(1, chong)) + g := imgfactory.MergeGif(1, chong) + return imgfactory.GIF2Base64(g) } // diu 丢 @@ -300,7 +308,7 @@ func diu(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - name := cc.usrdir + "丢.gif" + //name := cc.usrdir + "丢.gif" c := dlrange("diu", 8, &wg, func(e error) { m.Lock() errwg = e @@ -328,7 +336,8 @@ func diu(cc *context, value ...string) (string, error) { imgs[6].InsertUp(tou, 35, 35, 259, 31).Image(), imgs[7].InsertUp(tou, 175, 175, -50, 220).Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, diu)) + g := imgfactory.MergeGif(7, diu) + return imgfactory.GIF2Base64(g) } // kiss 亲 @@ -338,7 +347,7 @@ func kiss(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 13 - name := cc.usrdir + "Kiss.gif" + //name := cc.usrdir + "Kiss.gif" c := dlrange("kiss", piclen, &wg, func(e error) { m.Lock() err = e @@ -367,7 +376,8 @@ func kiss(cc *context, value ...string) (string, error) { kiss[i] = imgs[i].InsertUp(tou, 50, 50, userLocs[i][0], userLocs[i][1]). InsertUp(tou2, 40, 40, selfLocs[i][0], selfLocs[i][1]).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, kiss)) + g := imgfactory.MergeGif(7, kiss) + return imgfactory.GIF2Base64(g) } // garbage 垃圾 垃圾桶 @@ -377,7 +387,7 @@ func garbage(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 25 - name := cc.usrdir + "Garbage.gif" + //name := cc.usrdir + "Garbage.gif" c := dlrange("garbage", piclen, &wg, func(e error) { m.Lock() err = e @@ -400,7 +410,8 @@ func garbage(cc *context, value ...string) (string, error) { for i := 0; i < piclen; i++ { garbage[i] = imgs[i].InsertBottom(im.Image(), 0, 0, locs[i][0], locs[i][1]).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, garbage)) + g := imgfactory.MergeGif(7, garbage) + return imgfactory.GIF2Base64(g) } // thump 捶 @@ -410,7 +421,7 @@ func thump(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 4 - name := cc.usrdir + "Thump.gif" + //name := cc.usrdir + "Thump.gif" c := dlrange("thump", piclen, &wg, func(e error) { m.Lock() err = e @@ -433,7 +444,8 @@ func thump(cc *context, value ...string) (string, error) { for i := 0; i < piclen; i++ { thump[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, thump)) + g := imgfactory.MergeGif(7, thump) + return imgfactory.GIF2Base64(g) } // jiujiu 啾啾 @@ -443,7 +455,7 @@ func jiujiu(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 8 - name := cc.usrdir + "Jiujiu.gif" + //name := cc.usrdir + "Jiujiu.gif" c := dlrange("jiujiu", piclen, &wg, func(e error) { m.Lock() err = e @@ -465,7 +477,8 @@ func jiujiu(cc *context, value ...string) (string, error) { for i := 0; i < piclen; i++ { jiujiu[i] = imgs[i].InsertBottom(im.Image(), 0, 0, 0, 0).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, jiujiu)) + g := imgfactory.MergeGif(7, jiujiu) + return imgfactory.GIF2Base64(g) } // knock 2敲 @@ -475,7 +488,7 @@ func knock(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 8 - name := cc.usrdir + "Knock.gif" + //name := cc.usrdir + "Knock.gif" c := dlrange("knock", piclen, &wg, func(e error) { m.Lock() err = e @@ -498,7 +511,8 @@ func knock(cc *context, value ...string) (string, error) { for i := 0; i < piclen; i++ { knock[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, knock)) + g := imgfactory.MergeGif(7, knock) + return imgfactory.GIF2Base64(g) } // 听音乐 listenMusic @@ -508,7 +522,7 @@ func listenMusic(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 1 - name := cc.usrdir + "ListenMusic.gif" + //name := cc.usrdir + "ListenMusic.gif" c := dlrange("listen_music", piclen, &wg, func(e error) { m.Lock() err = e @@ -530,7 +544,8 @@ func listenMusic(cc *context, value ...string) (string, error) { for i := 0; i < 36; i++ { listenmusic[i] = imgs[0].InsertBottomC(imgfactory.Rotate(face, float64(-i*10), 215, 215).Image(), 0, 0, 207, 207).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, listenmusic)) + g := imgfactory.MergeGif(7, listenmusic) + return imgfactory.GIF2Base64(g) } // loveYou 永远爱你 @@ -540,7 +555,7 @@ func loveYou(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 2 - name := cc.usrdir + "LoveYou.gif" + //name := cc.usrdir + "LoveYou.gif" c := dlrange("love_you", piclen, &wg, func(e error) { m.Lock() err = e @@ -563,7 +578,8 @@ func loveYou(cc *context, value ...string) (string, error) { for i := 0; i < piclen; i++ { loveyou[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, loveyou)) + g := imgfactory.MergeGif(7, loveyou) + return imgfactory.GIF2Base64(g) } // pat 2拍 @@ -573,7 +589,7 @@ func pat(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 10 - name := cc.usrdir + "Pat.gif" + //name := cc.usrdir + "Pat.gif" c := dlrange("pat", piclen, &wg, func(e error) { m.Lock() err = e @@ -605,7 +621,8 @@ func pat(cc *context, value ...string) (string, error) { for i := 0; i < len(pat); i++ { pat[i] = p[seq[i]] } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, pat)) + g := imgfactory.MergeGif(7, pat) + return imgfactory.GIF2Base64(g) } // jackUp 顶 @@ -615,7 +632,7 @@ func jackUp(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 23 - name := cc.usrdir + "JackUp.gif" + //name := cc.usrdir + "JackUp.gif" c := dlrange("play", piclen, &wg, func(e error) { m.Lock() err = e @@ -648,7 +665,8 @@ func jackUp(cc *context, value ...string) (string, error) { play = append(play, p[0:8]...) play = append(play, p[12:18]...) play = append(play, p[18:23]...) - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, play)) + g := imgfactory.MergeGif(7, play) + return imgfactory.GIF2Base64(g) } // pound 捣 @@ -658,7 +676,7 @@ func pound(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 8 - name := cc.usrdir + "Pound.gif" + //name := cc.usrdir + "Pound.gif" c := dlrange("pound", piclen, &wg, func(e error) { m.Lock() err = e @@ -681,7 +699,8 @@ func pound(cc *context, value ...string) (string, error) { for i := 0; i < piclen; i++ { pound[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, pound)) + g := imgfactory.MergeGif(7, pound) + return imgfactory.GIF2Base64(g) } // punch 打拳 @@ -691,7 +710,7 @@ func punch(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 13 - name := cc.usrdir + "Punch.gif" + //name := cc.usrdir + "Punch.gif" c := dlrange("punch", piclen, &wg, func(e error) { m.Lock() err = e @@ -714,7 +733,8 @@ func punch(cc *context, value ...string) (string, error) { for i := 0; i < piclen; i++ { punch[i] = imgs[i].InsertBottom(im.Image(), 0, 0, locs[i][0], locs[i][1]-15).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, punch)) + g := imgfactory.MergeGif(7, punch) + return imgfactory.GIF2Base64(g) } // roll 滚 @@ -724,7 +744,7 @@ func roll(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 8 - name := cc.usrdir + "roll.gif" + //name := cc.usrdir + "roll.gif" c := dlrange("roll", piclen, &wg, func(e error) { m.Lock() err = e @@ -747,7 +767,8 @@ func roll(cc *context, value ...string) (string, error) { for i := 0; i < piclen; i++ { roll[i] = imgs[i].InsertBottomC(imgfactory.Rotate(im.Image(), float64(locs[i][2]), 0, 0).Image(), 0, 0, locs[i][0]+105, locs[i][1]+105).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, roll)) + g := imgfactory.MergeGif(7, roll) + return imgfactory.GIF2Base64(g) } // suck 吸 嗦 @@ -757,7 +778,7 @@ func suck(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 12 - name := cc.usrdir + "Suck.gif" + //name := cc.usrdir + "Suck.gif" c := dlrange("suck", piclen, &wg, func(e error) { m.Lock() err = e @@ -780,7 +801,8 @@ func suck(cc *context, value ...string) (string, error) { for i := 0; i < piclen; i++ { suck[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, suck)) + g := imgfactory.MergeGif(7, suck) + return imgfactory.GIF2Base64(g) } // hammer 锤 @@ -790,7 +812,7 @@ func hammer(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 7 - name := cc.usrdir + "Hammer.gif" + //name := cc.usrdir + "Hammer.gif" c := dlrange("hammer", piclen, &wg, func(e error) { m.Lock() err = e @@ -813,7 +835,8 @@ func hammer(cc *context, value ...string) (string, error) { for i := 0; i < piclen; i++ { hammer[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, hammer)) + g := imgfactory.MergeGif(7, hammer) + return imgfactory.GIF2Base64(g) } // tightly 紧贴 紧紧贴着 @@ -823,7 +846,7 @@ func tightly(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 20 - name := cc.usrdir + "Tightly.gif" + //name := cc.usrdir + "Tightly.gif" c := dlrange("tightly", piclen, &wg, func(e error) { m.Lock() err = e @@ -846,13 +869,14 @@ func tightly(cc *context, value ...string) (string, error) { for i := 0; i < piclen; i++ { tightly[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, tightly)) + g := imgfactory.MergeGif(7, tightly) + return imgfactory.GIF2Base64(g) } // turn 转 func turn(cc *context, value ...string) (string, error) { _ = value - name := cc.usrdir + "Turn.gif" + //name := cc.usrdir + "Turn.gif" face, err := cc.getLogo(0, 0) if err != nil { return "", err @@ -865,7 +889,8 @@ func turn(cc *context, value ...string) (string, error) { for i := 0; i < 36; i++ { turn[i] = imgfactory.Size(canvas.Image(), 0, 0).InsertUpC(imgfactory.Rotate(face, float64(10*i), 250, 250).Image(), 0, 0, 125, 125).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, turn)) + g := imgfactory.MergeGif(7, turn) + return imgfactory.GIF2Base64(g) } // taiguan 抬棺 @@ -874,7 +899,7 @@ func taiguan(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - name := cc.usrdir + "taiguan.gif" + //name := cc.usrdir + "taiguan.gif" c := dlrange("taiguan", 20, &wg, func(e error) { m.Lock() errwg = e @@ -914,7 +939,8 @@ func taiguan(cc *context, value ...string) (string, error) { imgs[18].InsertUp(tou, 85, 85, 170, 65).Image(), imgs[19].InsertUp(tou, 85, 85, 175, 65).Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, taiguan)) + g := imgfactory.MergeGif(7, taiguan) + return imgfactory.GIF2Base64(g) } // zou 揍 @@ -923,7 +949,7 @@ func zou(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - name := cc.usrdir + "zou.gif" + //name := cc.usrdir + "zou.gif" c := dlrange("zou", 3, &wg, func(e error) { m.Lock() errwg = e @@ -950,7 +976,8 @@ func zou(cc *context, value ...string) (string, error) { imgs[1].InsertUp(tou, 40, 40, 98, 138).InsertUp(tou2, 55, 55, 101, 45).Image(), imgs[2].InsertUp(tou, 40, 40, 89, 140).InsertUp(tou2, 55, 55, 99, 40).Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(8, zou)) + g := imgfactory.MergeGif(8, zou) + return imgfactory.GIF2Base64(g) } // ci 吞 @@ -959,7 +986,7 @@ func ci(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - name := cc.usrdir + "ci.gif" + //name := cc.usrdir + "ci.gif" c := dlrange("ci", 26, &wg, func(e error) { m.Lock() errwg = e @@ -1005,7 +1032,8 @@ func ci(cc *context, value ...string) (string, error) { imgs[24].Image(), imgs[25].Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, ci)) + g := imgfactory.MergeGif(7, ci) + return imgfactory.GIF2Base64(g) } // worship 膜拜 @@ -1014,7 +1042,7 @@ func worship(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var err error var m sync.Mutex - name := cc.usrdir + "worship.gif" + //name := cc.usrdir + "worship.gif" c := dlrange("worship", 9, &wg, func(e error) { m.Lock() err = e @@ -1043,7 +1071,8 @@ func worship(cc *context, value ...string) (string, error) { imgs[7].InsertBottom(face, 140, 140, 0, 0).Image(), imgs[8].InsertBottom(face, 140, 140, 0, 0).Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, worship)) + g := imgfactory.MergeGif(7, worship) + return imgfactory.GIF2Base64(g) } // 2ceng 2蹭 @@ -1052,7 +1081,7 @@ func ceng2(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - name := cc.usrdir + "ceng2.gif" + //name := cc.usrdir + "ceng2.gif" c := dlrange("ceng2", 4, &wg, func(e error) { m.Lock() errwg = e @@ -1076,7 +1105,8 @@ func ceng2(cc *context, value ...string) (string, error) { imgs[2].InsertBottom(tou, 175, 175, 78, 263).Image(), imgs[3].InsertBottom(tou, 175, 175, 78, 263).Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, ceng2)) + g := imgfactory.MergeGif(7, ceng2) + return imgfactory.GIF2Base64(g) } // dun 炖 @@ -1085,7 +1115,7 @@ func dun(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - name := cc.usrdir + "dun.gif" + //name := cc.usrdir + "dun.gif" c := dlrange("dun", 5, &wg, func(e error) { m.Lock() errwg = e @@ -1110,7 +1140,8 @@ func dun(cc *context, value ...string) (string, error) { imgs[3].InsertBottom(tou, 80, 80, 85, 45).Image(), imgs[4].InsertBottom(tou, 80, 80, 85, 45).Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, dun)) + g := imgfactory.MergeGif(7, dun) + return imgfactory.GIF2Base64(g) } // push 滚高清重置版 过渡 @@ -1120,7 +1151,7 @@ func push(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 16 - name := cc.usrdir + "push.gif" + //name := cc.usrdir + "push.gif" c := dlrange("push", piclen, &wg, func(e error) { m.Lock() err = e @@ -1142,7 +1173,8 @@ func push(cc *context, value ...string) (string, error) { for i := 0; i < piclen; i++ { push[i] = imgs[i].InsertUpC(imgfactory.Rotate(tou, float64(-22*i), 280, 280).Image(), 0, 0, 523, 291).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, push)) + g := imgfactory.MergeGif(7, push) + return imgfactory.GIF2Base64(g) } // peng 砰 @@ -1151,7 +1183,7 @@ func peng(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - name := cc.usrdir + "peng.gif" + //name := cc.usrdir + "peng.gif" c := dlrange("peng", 25, &wg, func(e error) { m.Lock() errwg = e @@ -1200,7 +1232,8 @@ func peng(cc *context, value ...string) (string, error) { imgs[23].InsertUp(m4.Image(), 0, 0, 89, 159).Image(), imgs[24].InsertUp(m4.Image(), 0, 0, 86, 160).Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(8, peng)) + g := imgfactory.MergeGif(8, peng) + return imgfactory.GIF2Base64(g) } // klee 可莉吃 @@ -1210,7 +1243,7 @@ func klee(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 31 - name := cc.usrdir + "klee.gif" + //name := cc.usrdir + "klee.gif" c := dlrange("klee", piclen, &wg, func(e error) { m.Lock() err = e @@ -1233,7 +1266,8 @@ func klee(cc *context, value ...string) (string, error) { for i := 0; i < piclen; i++ { klee[i] = imgs[i].InsertBottom(im.Image(), 0, 0, locs[i][0], locs[i][1]).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, klee)) + g := imgfactory.MergeGif(7, klee) + return imgfactory.GIF2Base64(g) } // hutaoken 胡桃啃 @@ -1242,7 +1276,7 @@ func hutaoken(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - name := cc.usrdir + "hutaoken.gif" + //name := cc.usrdir + "hutaoken.gif" c := dlrange("hutaoken", 2, &wg, func(e error) { m.Lock() errwg = e @@ -1264,7 +1298,8 @@ func hutaoken(cc *context, value ...string) (string, error) { imgs[0].InsertBottom(tou, 98, 101, 108, 234).Image(), imgs[1].InsertBottom(tou, 96, 100, 108, 237).Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(8, hutaoken)) + g := imgfactory.MergeGif(8, hutaoken) + return imgfactory.GIF2Base64(g) } // lick 2舔 @@ -1273,7 +1308,7 @@ func lick(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - name := cc.usrdir + "lick.gif" + //name := cc.usrdir + "lick.gif" c := dlrange("lick", 2, &wg, func(e error) { m.Lock() errwg = e @@ -1295,7 +1330,8 @@ func lick(cc *context, value ...string) (string, error) { imgs[0].InsertUp(tou, 44, 44, 10, 138).Image(), imgs[1].InsertUp(tou, 44, 44, 10, 138).Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(8, lick)) + g := imgfactory.MergeGif(8, lick) + return imgfactory.GIF2Base64(g) } // tiqiu 踢球 @@ -1305,7 +1341,7 @@ func tiqiu(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 15 - name := cc.usrdir + "tiqiu.gif" + //name := cc.usrdir + "tiqiu.gif" c := dlrange("tiqiu", piclen, &wg, func(e error) { m.Lock() err = e @@ -1328,7 +1364,8 @@ func tiqiu(cc *context, value ...string) (string, error) { for i := 0; i < piclen; i++ { tiqiu[i] = imgs[i].InsertUpC(imgfactory.Rotate(tou, float64(-24*i), 0, 0).Image(), 0, 0, locs[i][0]+38, locs[i][1]+38).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, tiqiu)) + g := imgfactory.MergeGif(7, tiqiu) + return imgfactory.GIF2Base64(g) } // cai 踩 @@ -1337,7 +1374,7 @@ func cai(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - name := cc.usrdir + "cai.gif" + //name := cc.usrdir + "cai.gif" c := dlrange("cai", 5, &wg, func(e error) { m.Lock() errwg = e @@ -1363,7 +1400,8 @@ func cai(cc *context, value ...string) (string, error) { imgs[3].InsertBottom(tou, 85, 76, 52, 203).Image(), imgs[4].InsertBottom(tou, 88, 82, 49, 198).Image(), } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, cai)) + g := imgfactory.MergeGif(7, cai) + return imgfactory.GIF2Base64(g) } // whir 2转 @@ -1373,7 +1411,7 @@ func whirl(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 15 - name := cc.usrdir + "whirl.gif" + //name := cc.usrdir + "whirl.gif" c := dlrange("whirl", piclen, &wg, func(e error) { m.Lock() err = e @@ -1395,7 +1433,8 @@ func whirl(cc *context, value ...string) (string, error) { for i := 0; i < piclen; i++ { whirl[i] = imgs[i].InsertUpC(imgfactory.Rotate(tou, float64(-24*i), 145, 145).Image(), 0, 0, 115, 89).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, whirl)) + g := imgfactory.MergeGif(7, whirl) + return imgfactory.GIF2Base64(g) } // always 一直 @@ -1403,7 +1442,7 @@ func alwaysDoGif(cc *context, value ...string) (string, error) { _ = value var err error var face []*imgfactory.Factory - name := cc.usrdir + "AlwaysDo.gif" + //name := cc.usrdir + "AlwaysDo.gif" face, err = imgfactory.LoadAllTrueFrames(cc.headimgsdir[0], 500, 500) if err != nil { // 载入失败尝试载入第一帧 @@ -1444,5 +1483,6 @@ func alwaysDoGif(cc *context, value ...string) (string, error) { canvas.DrawString("吗", 370, 560) turn[i] = imgfactory.Size(canvas.Image(), 0, 0).Image() } - return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(8, turn)) + g := imgfactory.MergeGif(8, turn) + return imgfactory.GIF2Base64(g) } From 33e5b0286fef74b60510006b606799c75d87e4c4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 17 Apr 2023 16:14:17 +0800 Subject: [PATCH 63/95] =?UTF-8?q?=F0=9F=8E=A8=20=E6=94=B9=E8=BF=9B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=B7=E5=BC=8F=20(#669)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- plugin/gif/gif.go | 80 +++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/plugin/gif/gif.go b/plugin/gif/gif.go index 8c98fd63de..bff083a1ae 100644 --- a/plugin/gif/gif.go +++ b/plugin/gif/gif.go @@ -19,7 +19,7 @@ func mo(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - //name := cc.usrdir + "摸.gif" + // name := cc.usrdir + "摸.gif" c := dlrange("mo", 5, &wg, func(e error) { m.Lock() errwg = e @@ -54,7 +54,7 @@ func cuo(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - //name := cc.usrdir + "搓.gif" + // name := cc.usrdir + "搓.gif" c := dlrange("cuo", 5, &wg, func(e error) { m.Lock() errwg = e @@ -93,7 +93,7 @@ func qiao(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - //name := cc.usrdir + "敲.gif" + // name := cc.usrdir + "敲.gif" c := dlrange("qiao", 2, &wg, func(e error) { m.Lock() errwg = e @@ -125,7 +125,7 @@ func chi(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - //name := cc.usrdir + "吃.gif" + // name := cc.usrdir + "吃.gif" c := dlrange("chi", 3, &wg, func(e error) { m.Lock() errwg = e @@ -158,7 +158,7 @@ func ceng(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - //name := cc.usrdir + "蹭.gif" + // name := cc.usrdir + "蹭.gif" c := dlrange("ceng", 6, &wg, func(e error) { m.Lock() errwg = e @@ -198,7 +198,7 @@ func ken(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - //name := cc.usrdir + "啃.gif" + // name := cc.usrdir + "啃.gif" c := dlrange("ken", 16, &wg, func(e error) { m.Lock() errwg = e @@ -244,7 +244,7 @@ func pai(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - //name := cc.usrdir + "拍.gif" + // name := cc.usrdir + "拍.gif" c := dlrange("pai", 2, &wg, func(e error) { m.Lock() errwg = e @@ -276,7 +276,7 @@ func xqe(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - //name := cc.usrdir + "冲.gif" + // name := cc.usrdir + "冲.gif" c := dlrange("xqe", 2, &wg, func(e error) { m.Lock() errwg = e @@ -308,7 +308,7 @@ func diu(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - //name := cc.usrdir + "丢.gif" + // name := cc.usrdir + "丢.gif" c := dlrange("diu", 8, &wg, func(e error) { m.Lock() errwg = e @@ -347,7 +347,7 @@ func kiss(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 13 - //name := cc.usrdir + "Kiss.gif" + // name := cc.usrdir + "Kiss.gif" c := dlrange("kiss", piclen, &wg, func(e error) { m.Lock() err = e @@ -387,7 +387,7 @@ func garbage(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 25 - //name := cc.usrdir + "Garbage.gif" + // name := cc.usrdir + "Garbage.gif" c := dlrange("garbage", piclen, &wg, func(e error) { m.Lock() err = e @@ -421,7 +421,7 @@ func thump(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 4 - //name := cc.usrdir + "Thump.gif" + // name := cc.usrdir + "Thump.gif" c := dlrange("thump", piclen, &wg, func(e error) { m.Lock() err = e @@ -455,7 +455,7 @@ func jiujiu(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 8 - //name := cc.usrdir + "Jiujiu.gif" + // name := cc.usrdir + "Jiujiu.gif" c := dlrange("jiujiu", piclen, &wg, func(e error) { m.Lock() err = e @@ -488,7 +488,7 @@ func knock(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 8 - //name := cc.usrdir + "Knock.gif" + // name := cc.usrdir + "Knock.gif" c := dlrange("knock", piclen, &wg, func(e error) { m.Lock() err = e @@ -522,7 +522,7 @@ func listenMusic(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 1 - //name := cc.usrdir + "ListenMusic.gif" + // name := cc.usrdir + "ListenMusic.gif" c := dlrange("listen_music", piclen, &wg, func(e error) { m.Lock() err = e @@ -555,7 +555,7 @@ func loveYou(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 2 - //name := cc.usrdir + "LoveYou.gif" + // name := cc.usrdir + "LoveYou.gif" c := dlrange("love_you", piclen, &wg, func(e error) { m.Lock() err = e @@ -589,7 +589,7 @@ func pat(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 10 - //name := cc.usrdir + "Pat.gif" + // name := cc.usrdir + "Pat.gif" c := dlrange("pat", piclen, &wg, func(e error) { m.Lock() err = e @@ -632,7 +632,7 @@ func jackUp(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 23 - //name := cc.usrdir + "JackUp.gif" + // name := cc.usrdir + "JackUp.gif" c := dlrange("play", piclen, &wg, func(e error) { m.Lock() err = e @@ -676,7 +676,7 @@ func pound(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 8 - //name := cc.usrdir + "Pound.gif" + // name := cc.usrdir + "Pound.gif" c := dlrange("pound", piclen, &wg, func(e error) { m.Lock() err = e @@ -710,7 +710,7 @@ func punch(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 13 - //name := cc.usrdir + "Punch.gif" + // name := cc.usrdir + "Punch.gif" c := dlrange("punch", piclen, &wg, func(e error) { m.Lock() err = e @@ -744,7 +744,7 @@ func roll(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 8 - //name := cc.usrdir + "roll.gif" + // name := cc.usrdir + "roll.gif" c := dlrange("roll", piclen, &wg, func(e error) { m.Lock() err = e @@ -778,7 +778,7 @@ func suck(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 12 - //name := cc.usrdir + "Suck.gif" + // name := cc.usrdir + "Suck.gif" c := dlrange("suck", piclen, &wg, func(e error) { m.Lock() err = e @@ -812,7 +812,7 @@ func hammer(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 7 - //name := cc.usrdir + "Hammer.gif" + // name := cc.usrdir + "Hammer.gif" c := dlrange("hammer", piclen, &wg, func(e error) { m.Lock() err = e @@ -846,7 +846,7 @@ func tightly(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 20 - //name := cc.usrdir + "Tightly.gif" + // name := cc.usrdir + "Tightly.gif" c := dlrange("tightly", piclen, &wg, func(e error) { m.Lock() err = e @@ -876,7 +876,7 @@ func tightly(cc *context, value ...string) (string, error) { // turn 转 func turn(cc *context, value ...string) (string, error) { _ = value - //name := cc.usrdir + "Turn.gif" + // name := cc.usrdir + "Turn.gif" face, err := cc.getLogo(0, 0) if err != nil { return "", err @@ -899,7 +899,7 @@ func taiguan(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - //name := cc.usrdir + "taiguan.gif" + // name := cc.usrdir + "taiguan.gif" c := dlrange("taiguan", 20, &wg, func(e error) { m.Lock() errwg = e @@ -949,7 +949,7 @@ func zou(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - //name := cc.usrdir + "zou.gif" + // name := cc.usrdir + "zou.gif" c := dlrange("zou", 3, &wg, func(e error) { m.Lock() errwg = e @@ -986,7 +986,7 @@ func ci(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - //name := cc.usrdir + "ci.gif" + // name := cc.usrdir + "ci.gif" c := dlrange("ci", 26, &wg, func(e error) { m.Lock() errwg = e @@ -1042,7 +1042,7 @@ func worship(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var err error var m sync.Mutex - //name := cc.usrdir + "worship.gif" + // name := cc.usrdir + "worship.gif" c := dlrange("worship", 9, &wg, func(e error) { m.Lock() err = e @@ -1081,7 +1081,7 @@ func ceng2(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - //name := cc.usrdir + "ceng2.gif" + // name := cc.usrdir + "ceng2.gif" c := dlrange("ceng2", 4, &wg, func(e error) { m.Lock() errwg = e @@ -1115,7 +1115,7 @@ func dun(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - //name := cc.usrdir + "dun.gif" + // name := cc.usrdir + "dun.gif" c := dlrange("dun", 5, &wg, func(e error) { m.Lock() errwg = e @@ -1151,7 +1151,7 @@ func push(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 16 - //name := cc.usrdir + "push.gif" + // name := cc.usrdir + "push.gif" c := dlrange("push", piclen, &wg, func(e error) { m.Lock() err = e @@ -1183,7 +1183,7 @@ func peng(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - //name := cc.usrdir + "peng.gif" + // name := cc.usrdir + "peng.gif" c := dlrange("peng", 25, &wg, func(e error) { m.Lock() errwg = e @@ -1243,7 +1243,7 @@ func klee(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 31 - //name := cc.usrdir + "klee.gif" + // name := cc.usrdir + "klee.gif" c := dlrange("klee", piclen, &wg, func(e error) { m.Lock() err = e @@ -1276,7 +1276,7 @@ func hutaoken(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - //name := cc.usrdir + "hutaoken.gif" + // name := cc.usrdir + "hutaoken.gif" c := dlrange("hutaoken", 2, &wg, func(e error) { m.Lock() errwg = e @@ -1308,7 +1308,7 @@ func lick(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - //name := cc.usrdir + "lick.gif" + // name := cc.usrdir + "lick.gif" c := dlrange("lick", 2, &wg, func(e error) { m.Lock() errwg = e @@ -1341,7 +1341,7 @@ func tiqiu(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 15 - //name := cc.usrdir + "tiqiu.gif" + // name := cc.usrdir + "tiqiu.gif" c := dlrange("tiqiu", piclen, &wg, func(e error) { m.Lock() err = e @@ -1374,7 +1374,7 @@ func cai(cc *context, value ...string) (string, error) { var wg sync.WaitGroup var errwg error var m sync.Mutex - //name := cc.usrdir + "cai.gif" + // name := cc.usrdir + "cai.gif" c := dlrange("cai", 5, &wg, func(e error) { m.Lock() errwg = e @@ -1411,7 +1411,7 @@ func whirl(cc *context, value ...string) (string, error) { var err error var m sync.Mutex piclen := 15 - //name := cc.usrdir + "whirl.gif" + // name := cc.usrdir + "whirl.gif" c := dlrange("whirl", piclen, &wg, func(e error) { m.Lock() err = e @@ -1442,7 +1442,7 @@ func alwaysDoGif(cc *context, value ...string) (string, error) { _ = value var err error var face []*imgfactory.Factory - //name := cc.usrdir + "AlwaysDo.gif" + // name := cc.usrdir + "AlwaysDo.gif" face, err = imgfactory.LoadAllTrueFrames(cc.headimgsdir[0], 500, 500) if err != nil { // 载入失败尝试载入第一帧 From 8eb058fb26d86b28740a6020e0e8008454ee9547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=B2=E5=AE=9D=E5=9D=8F=E5=9D=8F=E5=9D=8F?= <2758988938@qq.com> Date: Wed, 19 Apr 2023 00:47:44 +0800 Subject: [PATCH 64/95] =?UTF-8?q?add=20=E7=BB=B4=E5=9F=BA=E7=99=BE?= =?UTF-8?q?=E7=A7=91=20(#673)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add 维基百科 * make happy --- README.md | 4 ++-- plugin/baidu/search.go | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cd4a0387c1..0344abe2d5 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] 百度/百科/维基/wiki[xxx]
diff --git a/plugin/baidu/search.go b/plugin/baidu/search.go index 887bdeac1f..4942d24d08 100644 --- a/plugin/baidu/search.go +++ b/plugin/baidu/search.go @@ -13,7 +13,9 @@ import ( ) const ( - api = "https://api.a20safe.com/api.php?api=21&key=7d06a110e9e20a684e02934549db1d3d&text=%s" // api地址 + duURL = "https://api.a20safe.com/api.php?api=21&key=%s&text=%s" // api地址 + wikiURL = "https://api.a20safe.com/api.php?api=23&key=%s&text=%s" + key = "7d06a110e9e20a684e02934549db1d3d" ) type result struct { @@ -27,11 +29,18 @@ type result struct { func init() { // 主函数 en := control.Register("baidu", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, - Help: "百度百科\n" + - "- 百度/百科[关键字]", + Help: "百科\n" + + "- 百度/百科/维基/wiki[关键字]", }) - en.OnRegex(`^百[度科]\s*(.+)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) { - es, err := web.GetData(fmt.Sprintf(api, ctx.State["regex_matched"].([]string)[1])) // 将网站返回结果赋值 + en.OnRegex(`^(百度|维基|百科|wiki)\s*(.+)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) { + var es []byte + var err error + switch ctx.State["regex_matched"].([]string)[1] { + case "百度", "百科": + es, err = web.GetData(fmt.Sprintf(duURL, key, ctx.State["regex_matched"].([]string)[2])) // 将网站返回结果赋值 + case "wiki", "维基": + es, err = web.GetData(fmt.Sprintf(wikiURL, key, ctx.State["regex_matched"].([]string)[2])) // 将网站返回结果赋值 + } if err != nil { ctx.SendChain(message.Text("出现错误捏:", err)) return From 5463945b6c8ca44fa5102cb77c823a2a6ce2f969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Wed, 19 Apr 2023 11:36:52 +0800 Subject: [PATCH 65/95] =?UTF-8?q?=F0=9F=94=96=20v1.7.1-beta3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- kanban/banner/banner.go | 4 ++-- winres/winres.json | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 16c2597870..eea03d66f0 100644 --- a/go.mod +++ b/go.mod @@ -24,6 +24,7 @@ require ( github.com/fumiama/go-base16384 v1.6.4 github.com/fumiama/go-registry v0.2.6 github.com/fumiama/gotracemoe v0.0.3 + github.com/fumiama/imgsz v0.0.2 github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565 github.com/fumiama/unibase2n v0.0.0-20221020155353-02876e777430 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 @@ -51,7 +52,6 @@ require ( github.com/faiface/beep v1.1.0 // indirect github.com/fumiama/go-simple-protobuf v0.1.0 // indirect github.com/fumiama/gofastTEA v0.0.10 // indirect - github.com/fumiama/imgsz v0.0.2 // indirect github.com/gabriel-vasile/mimetype v1.0.4 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect diff --git a/kanban/banner/banner.go b/kanban/banner/banner.go index 4da7690735..e818a16bb3 100644 --- a/kanban/banner/banner.go +++ b/kanban/banner/banner.go @@ -3,13 +3,13 @@ package banner // Version ... -var Version = "v1.7.1-beta2" +var Version = "v1.7.1-beta3" // Copyright ... var Copyright = "© 2020 - 2023 FloatTech" // Banner ... var Banner = "* OneBot + ZeroBot + Golang\n" + - "* Version " + Version + " - 2023-04-09 11:01:54 +0800 CST\n" + + "* Version " + Version + " - 2023-04-19 11:36:16 +0800 CST\n" + "* Copyright " + Copyright + ". All Rights Reserved.\n" + "* Project: https://github.com/FloatTech/ZeroBot-Plugin" diff --git a/winres/winres.json b/winres/winres.json index 322c0446e9..b06730d65a 100644 --- a/winres/winres.json +++ b/winres/winres.json @@ -12,7 +12,7 @@ "0409": { "identity": { "name": "ZeroBot-Plugin", - "version": "1.7.1.1789" + "version": "1.7.1.1812" }, "description": "", "minimum-os": "vista", @@ -36,23 +36,23 @@ "#1": { "0000": { "fixed": { - "file_version": "1.7.1.1789", - "product_version": "v1.7.1-beta2", - "timestamp": "2023-04-09T11:02:07+08:00" + "file_version": "1.7.1.1812", + "product_version": "v1.7.1-beta3", + "timestamp": "2023-04-19T11:36:27+08:00" }, "info": { "0409": { "Comments": "OneBot plugins based on ZeroBot", "CompanyName": "FloatTech", "FileDescription": "https://github.com/FloatTech/ZeroBot-Plugin", - "FileVersion": "1.7.1.1789", + "FileVersion": "1.7.1.1812", "InternalName": "", "LegalCopyright": "© 2020 - 2023 FloatTech. All Rights Reserved.", "LegalTrademarks": "", "OriginalFilename": "ZBP.EXE", "PrivateBuild": "", "ProductName": "ZeroBot-Plugin", - "ProductVersion": "v1.7.1-beta2", + "ProductVersion": "v1.7.1-beta3", "SpecialBuild": "" } } From 1c0270fda017e6b89aa86f75d51764873e75ca09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Wed, 19 Apr 2023 23:07:43 +0800 Subject: [PATCH 66/95] =?UTF-8?q?thesarus=20add=20=F0=9F=A6=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/thesaurus/chat.go | 71 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/plugin/thesaurus/chat.go b/plugin/thesaurus/chat.go index 5f011f9c2d..33d6a625ef 100644 --- a/plugin/thesaurus/chat.go +++ b/plugin/thesaurus/chat.go @@ -5,10 +5,15 @@ import ( "bytes" "encoding/json" "math/rand" + "net/url" + "os" "strings" + "github.com/FloatTech/floatbox/binary" "github.com/FloatTech/floatbox/ctxext" + "github.com/FloatTech/floatbox/file" "github.com/FloatTech/floatbox/process" + "github.com/FloatTech/floatbox/web" ctrl "github.com/FloatTech/zbpctrl" "github.com/FloatTech/zbputils/control" "github.com/fumiama/jieba" @@ -22,10 +27,33 @@ func init() { engine := control.Register("thesaurus", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, Brief: "词典匹配回复", - Help: "- 切换[kimo|傲娇|可爱]词库\n- 设置词库触发概率0.x (0 0 { + ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text(m.Msg))) } } }) From 0315718ab7b1d77d5443590c2a6b86abdf3c0fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Thu, 20 Apr 2023 01:14:32 +0800 Subject: [PATCH 68/95] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/thesaurus/chat.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/plugin/thesaurus/chat.go b/plugin/thesaurus/chat.go index 9331f16362..be336b4257 100644 --- a/plugin/thesaurus/chat.go +++ b/plugin/thesaurus/chat.go @@ -8,7 +8,9 @@ import ( "net/http" "net/url" "os" + "strconv" "strings" + "time" "github.com/FloatTech/floatbox/binary" "github.com/FloatTech/floatbox/ctxext" @@ -192,6 +194,7 @@ func init() { return } type reply struct { + ID int Msg string } m := reply{} @@ -200,8 +203,25 @@ func init() { logrus.Warnln("[chat] 🦙 unmarshal err:", err) return } - if len(m.Msg) > 0 { - ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text(m.Msg))) + for i := 0; i < 60; i++ { + time.Sleep(time.Second * 4) + data, err := web.RequestDataWithHeaders(http.DefaultClient, alpacapiurl+"/get?id="+strconv.Itoa(m.ID), "GET", + func(r *http.Request) error { + r.Header.Set("Authorization", alpacatoken) + return nil + }, nil) + if err != nil { + continue + } + err = json.Unmarshal(data, &m) + if err != nil { + logrus.Warnln("[chat] 🦙 unmarshal err:", err) + return + } + if len(m.Msg) > 0 { + ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text(m.Msg))) + } + return } } }) From df1d71b9b28430eeb371363314fab8754f5b2bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Fri, 21 Apr 2023 14:49:34 +0800 Subject: [PATCH 69/95] =?UTF-8?q?remove=20=F0=9F=A6=99=20reply?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/thesaurus/chat.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/thesaurus/chat.go b/plugin/thesaurus/chat.go index be336b4257..e9baf45517 100644 --- a/plugin/thesaurus/chat.go +++ b/plugin/thesaurus/chat.go @@ -219,7 +219,7 @@ func init() { return } if len(m.Msg) > 0 { - ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text(m.Msg))) + ctx.Send(message.Text(m.Msg)) } return } From 30301f1abaa551ed9714d26b61dafa826ff1f099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sat, 22 Apr 2023 14:40:35 +0800 Subject: [PATCH 70/95] =?UTF-8?q?=F0=9F=A6=99=E8=AF=B7=E6=B1=82=E6=94=B9PO?= =?UTF-8?q?ST?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/thesaurus/chat.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/plugin/thesaurus/chat.go b/plugin/thesaurus/chat.go index e9baf45517..0bdfb92a36 100644 --- a/plugin/thesaurus/chat.go +++ b/plugin/thesaurus/chat.go @@ -6,7 +6,6 @@ import ( "encoding/json" "math/rand" "net/http" - "net/url" "os" "strconv" "strings" @@ -180,15 +179,20 @@ func init() { SetBlock(false). Handle(randreply(sm.K)) engine.OnMessage(canmatch(tALPACA), func(ctx *zero.Ctx) bool { - return !zero.HasPicture(ctx) && alpacapiurl != "" && alpacatoken != "" + return alpacapiurl != "" && alpacatoken != "" }).SetBlock(false).Handle(func(ctx *zero.Ctx) { msg := ctx.ExtractPlainText() if msg != "" { - data, err := web.RequestDataWithHeaders(http.DefaultClient, alpacapiurl+"/reply?msg="+url.QueryEscape(msg), "GET", + data, err := web.RequestDataWithHeaders(http.DefaultClient, alpacapiurl+"/reply", "POST", func(r *http.Request) error { r.Header.Set("Authorization", alpacatoken) return nil - }, nil) + }, bytes.NewReader(binary.NewWriterF(func(writer *binary.Writer) { + _ = json.NewEncoder(writer).Encode(&alpacamsg{ + Name: ctx.CardOrNickName(ctx.Event.UserID), + Message: msg, + }) + }))) if err != nil { logrus.Warnln("[chat] 🦙 err:", err) return @@ -235,6 +239,11 @@ type simai struct { K map[string][]string `yaml:"可爱"` } +type alpacamsg struct { + Name string + Message string +} + const ( tKIMO = iota tDERE From 436838d2f8da88fb7fb1125794c8adc0706555a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sat, 22 Apr 2023 14:53:32 +0800 Subject: [PATCH 71/95] fix --- plugin/thesaurus/chat.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/thesaurus/chat.go b/plugin/thesaurus/chat.go index 0bdfb92a36..1f75bcd46c 100644 --- a/plugin/thesaurus/chat.go +++ b/plugin/thesaurus/chat.go @@ -188,10 +188,10 @@ func init() { r.Header.Set("Authorization", alpacatoken) return nil }, bytes.NewReader(binary.NewWriterF(func(writer *binary.Writer) { - _ = json.NewEncoder(writer).Encode(&alpacamsg{ + _ = json.NewEncoder(writer).Encode(&[]alpacamsg{{ Name: ctx.CardOrNickName(ctx.Event.UserID), Message: msg, - }) + }}) }))) if err != nil { logrus.Warnln("[chat] 🦙 err:", err) From 821f8d494933b064a2f4cf0d3dcd245973716f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 30 Apr 2023 13:51:25 +0800 Subject: [PATCH 72/95] update wife --- data | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data b/data index 074abee575..d0342c3806 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit 074abee575503b5c66c57a2b3aa28fe40c6b215e +Subproject commit d0342c38067c5cc34880bcaf0bab6e88fb5d242e From 278d7e0cf9c425c455c34011655e6a252a09d0e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 30 Apr 2023 13:52:25 +0800 Subject: [PATCH 73/95] =?UTF-8?q?=F0=9F=94=96=20v1.7.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kanban/banner/banner.go | 4 ++-- winres/winres.json | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kanban/banner/banner.go b/kanban/banner/banner.go index e818a16bb3..b2d57a299a 100644 --- a/kanban/banner/banner.go +++ b/kanban/banner/banner.go @@ -3,13 +3,13 @@ package banner // Version ... -var Version = "v1.7.1-beta3" +var Version = "v1.7.1" // Copyright ... var Copyright = "© 2020 - 2023 FloatTech" // Banner ... var Banner = "* OneBot + ZeroBot + Golang\n" + - "* Version " + Version + " - 2023-04-19 11:36:16 +0800 CST\n" + + "* Version " + Version + " - 2023-04-30 13:51:47 +0800 CST\n" + "* Copyright " + Copyright + ". All Rights Reserved.\n" + "* Project: https://github.com/FloatTech/ZeroBot-Plugin" diff --git a/winres/winres.json b/winres/winres.json index b06730d65a..34cdfacac0 100644 --- a/winres/winres.json +++ b/winres/winres.json @@ -12,7 +12,7 @@ "0409": { "identity": { "name": "ZeroBot-Plugin", - "version": "1.7.1.1812" + "version": "1.7.1.1820" }, "description": "", "minimum-os": "vista", @@ -36,23 +36,23 @@ "#1": { "0000": { "fixed": { - "file_version": "1.7.1.1812", - "product_version": "v1.7.1-beta3", - "timestamp": "2023-04-19T11:36:27+08:00" + "file_version": "1.7.1.1820", + "product_version": "v1.7.1", + "timestamp": "2023-04-30T13:52:06+08:00" }, "info": { "0409": { "Comments": "OneBot plugins based on ZeroBot", "CompanyName": "FloatTech", "FileDescription": "https://github.com/FloatTech/ZeroBot-Plugin", - "FileVersion": "1.7.1.1812", + "FileVersion": "1.7.1.1820", "InternalName": "", "LegalCopyright": "© 2020 - 2023 FloatTech. All Rights Reserved.", "LegalTrademarks": "", "OriginalFilename": "ZBP.EXE", "PrivateBuild": "", "ProductName": "ZeroBot-Plugin", - "ProductVersion": "v1.7.1-beta3", + "ProductVersion": "v1.7.1", "SpecialBuild": "" } } From bdcb8332178bc6956e130312b6356b22885df387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Tue, 9 May 2023 13:35:50 +0800 Subject: [PATCH 74/95] =?UTF-8?q?=F0=9F=90=9B=20fix=20control=20cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index eea03d66f0..4f1990df28 100644 --- a/go.mod +++ b/go.mod @@ -11,8 +11,8 @@ require ( github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9 github.com/FloatTech/sqlite v1.6.2 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b - github.com/FloatTech/zbpctrl v1.5.3-0.20230411055601-7cdff751dd67 - github.com/FloatTech/zbputils v1.6.2-0.20230411114057-4c71136244b2 + github.com/FloatTech/zbpctrl v1.5.3-0.20230509052559-9de33e0b2511 + github.com/FloatTech/zbputils v1.6.2-0.20230509053221-57817eec971e github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 diff --git a/go.sum b/go.sum index 867f4bfde1..c585c7ffb8 100644 --- a/go.sum +++ b/go.sum @@ -16,10 +16,10 @@ github.com/FloatTech/sqlite v1.6.2 h1:FytbExjpvYalZxxITtmSenHiPGLPUvlz47LY/P0SCC github.com/FloatTech/sqlite v1.6.2/go.mod h1:zFbHzRfB+CJ+VidfjuVbrcin3DAz283F7hF1hIeHzpY= github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJGLDNIdRX3BI546D3O7k7vrVueZw= github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= -github.com/FloatTech/zbpctrl v1.5.3-0.20230411055601-7cdff751dd67 h1:KGfXWryE3VGFDC8Z6661d/7xm8oLNPpFB5ODb7DqYJc= -github.com/FloatTech/zbpctrl v1.5.3-0.20230411055601-7cdff751dd67/go.mod h1:gkGC1C1eEUd/Ld/ja68zas5j2ZktIZCdnj2FMaM+Au0= -github.com/FloatTech/zbputils v1.6.2-0.20230411114057-4c71136244b2 h1:Dx64RjcbxhsOHinykOPAlYqvPd9tE375IQrWqlNmDXs= -github.com/FloatTech/zbputils v1.6.2-0.20230411114057-4c71136244b2/go.mod h1:m3IW5z7vLMNgNtVNUfcYtOF1du6PnjckifdRK2hVjA0= +github.com/FloatTech/zbpctrl v1.5.3-0.20230509052559-9de33e0b2511 h1:b0YlNjWM/KJMAnXgNMExh6OY6Mal8E3eFtHfUFS2ndM= +github.com/FloatTech/zbpctrl v1.5.3-0.20230509052559-9de33e0b2511/go.mod h1:gkGC1C1eEUd/Ld/ja68zas5j2ZktIZCdnj2FMaM+Au0= +github.com/FloatTech/zbputils v1.6.2-0.20230509053221-57817eec971e h1:oVLv2LMmHmODrRZfoOL1GFTccvbudBvq1iluFO/dW+g= +github.com/FloatTech/zbputils v1.6.2-0.20230509053221-57817eec971e/go.mod h1:N52dNHS9MmfueGwNTAR/4MQd1nYTyrut6zxrBU5vbR8= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= From 6403614fa8016f5448ae6a3898986ff5dd7e7782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 14 May 2023 23:49:46 +0800 Subject: [PATCH 75/95] =?UTF-8?q?=F0=9F=90=9B=20fix=20control=20cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 4f1990df28..7c6beda7f7 100644 --- a/go.mod +++ b/go.mod @@ -11,8 +11,8 @@ require ( github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9 github.com/FloatTech/sqlite v1.6.2 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b - github.com/FloatTech/zbpctrl v1.5.3-0.20230509052559-9de33e0b2511 - github.com/FloatTech/zbputils v1.6.2-0.20230509053221-57817eec971e + github.com/FloatTech/zbpctrl v1.5.3-0.20230514154630-b74e6fcca380 + github.com/FloatTech/zbputils v1.6.2-0.20230514154857-9363fdb11fd6 github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 diff --git a/go.sum b/go.sum index c585c7ffb8..bce8ce673c 100644 --- a/go.sum +++ b/go.sum @@ -16,10 +16,10 @@ github.com/FloatTech/sqlite v1.6.2 h1:FytbExjpvYalZxxITtmSenHiPGLPUvlz47LY/P0SCC github.com/FloatTech/sqlite v1.6.2/go.mod h1:zFbHzRfB+CJ+VidfjuVbrcin3DAz283F7hF1hIeHzpY= github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJGLDNIdRX3BI546D3O7k7vrVueZw= github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= -github.com/FloatTech/zbpctrl v1.5.3-0.20230509052559-9de33e0b2511 h1:b0YlNjWM/KJMAnXgNMExh6OY6Mal8E3eFtHfUFS2ndM= -github.com/FloatTech/zbpctrl v1.5.3-0.20230509052559-9de33e0b2511/go.mod h1:gkGC1C1eEUd/Ld/ja68zas5j2ZktIZCdnj2FMaM+Au0= -github.com/FloatTech/zbputils v1.6.2-0.20230509053221-57817eec971e h1:oVLv2LMmHmODrRZfoOL1GFTccvbudBvq1iluFO/dW+g= -github.com/FloatTech/zbputils v1.6.2-0.20230509053221-57817eec971e/go.mod h1:N52dNHS9MmfueGwNTAR/4MQd1nYTyrut6zxrBU5vbR8= +github.com/FloatTech/zbpctrl v1.5.3-0.20230514154630-b74e6fcca380 h1:qmwoT8xVaND01aCdwy+5/j6z490nehQWZAVyTBN8ahU= +github.com/FloatTech/zbpctrl v1.5.3-0.20230514154630-b74e6fcca380/go.mod h1:gkGC1C1eEUd/Ld/ja68zas5j2ZktIZCdnj2FMaM+Au0= +github.com/FloatTech/zbputils v1.6.2-0.20230514154857-9363fdb11fd6 h1:uss0/IszBjik7LSM5Q4xQ9FaDXAC7vK7y1dAaOj4UAk= +github.com/FloatTech/zbputils v1.6.2-0.20230514154857-9363fdb11fd6/go.mod h1:JXRQf2GAzpd7gp853LP6PU3O4pkRoFFuKGykcBChPNk= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= From 283667cfe5420a4d56bd0a3e88b8fab69a06f3ca Mon Sep 17 00:00:00 2001 From: alexskim <2872999267@qq.com> Date: Tue, 13 Jun 2023 11:46:06 +0800 Subject: [PATCH 76/95] =?UTF-8?q?=E4=BF=AE=E5=A4=9A=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=8A=BD=E7=AD=BE=E4=B8=8D=E5=88=B7=E6=96=B0=E5=88=97=E8=A1=A8?= =?UTF-8?q?bug=20(#693)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/drawlots/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/drawlots/main.go b/plugin/drawlots/main.go index 9d77e675cc..9154629e04 100644 --- a/plugin/drawlots/main.go +++ b/plugin/drawlots/main.go @@ -53,7 +53,8 @@ var ( func init() { en.OnFullMatchGroup([]string{"抽签列表", "刷新抽签列表"}).SetBlock(true).Handle(func(ctx *zero.Ctx) { - lotsList, err := getList() // 刷新列表 + var err error + lotsList, err = getList() // 刷新列表 if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return From 0d8157e2f88c353b5cbc838baa37e92192182d88 Mon Sep 17 00:00:00 2001 From: Jiang-Red <79574799+Jiang-Red@users.noreply.github.com> Date: Thu, 13 Jul 2023 14:23:25 +0800 Subject: [PATCH 77/95] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=8D=E5=90=91ws?= =?UTF-8?q?=E9=A1=BA=E4=BE=BF=E7=A6=81=E7=94=A8=E6=96=B0=E7=89=88ci?= =?UTF-8?q?=E7=9A=84=E6=9F=90=E4=B8=AA=E5=8A=9F=E8=83=BD=20(#700)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .golangci.yml | 2 +- main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 8701bdc08a..383c903fdd 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -18,7 +18,7 @@ linters: fast: false enable: - bodyclose - - depguard + #- depguard - dogsled - errcheck - exportloopref diff --git a/main.go b/main.go index dd83f0892b..4f3730339d 100644 --- a/main.go +++ b/main.go @@ -277,7 +277,7 @@ func init() { config.Z.Driver[i] = w } for i, s := range config.S { - config.Z.Driver[i+len(config.W)] = s + config.Z.Driver[i+len(config.W)] = driver.NewWebSocketServer(16, s.Url, s.AccessToken) } logrus.Infoln("[main] 从", *runcfg, "读取配置文件") return From f4add826ff9ba1fb7426059933a590ce046f004b Mon Sep 17 00:00:00 2001 From: weigui404 <74092436+weigui404@users.noreply.github.com> Date: Sun, 16 Jul 2023 15:50:45 +0800 Subject: [PATCH 78/95] Update README.md (#701) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0344abe2d5..b60444472e 100644 --- a/README.md +++ b/README.md @@ -1295,7 +1295,7 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] steam[添加|删除]订阅xxxxx - - [x] steam查看订阅 + - [x] steam查询订阅 - [x] steam绑定 api key xxxxxxx From aaf659f6d4b2dd4753a73788bdf5c613b34827d5 Mon Sep 17 00:00:00 2001 From: Jiang-Red <79574799+Jiang-Red@users.noreply.github.com> Date: Mon, 17 Jul 2023 22:57:58 +0800 Subject: [PATCH 79/95] fix runcode (#702) * fix runcode * fix permission --- go.mod | 4 ++-- go.sum | 4 ++-- plugin/runcode/code_runner.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 7c6beda7f7..3a2c75add8 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/Baidu-AIP/golang-sdk v1.1.1 - github.com/FloatTech/AnimeAPI v1.6.1-0.20230409024643-f25135dee0da + github.com/FloatTech/AnimeAPI v1.6.1-0.20230716130052-ec46a05ce2d6 github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 github.com/FloatTech/imgfactory v0.2.2-0.20230413152719-e101cc3606ef @@ -24,7 +24,6 @@ require ( github.com/fumiama/go-base16384 v1.6.4 github.com/fumiama/go-registry v0.2.6 github.com/fumiama/gotracemoe v0.0.3 - github.com/fumiama/imgsz v0.0.2 github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565 github.com/fumiama/unibase2n v0.0.0-20221020155353-02876e777430 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 @@ -52,6 +51,7 @@ require ( github.com/faiface/beep v1.1.0 // indirect github.com/fumiama/go-simple-protobuf v0.1.0 // indirect github.com/fumiama/gofastTEA v0.0.10 // indirect + github.com/fumiama/imgsz v0.0.2 // indirect github.com/gabriel-vasile/mimetype v1.0.4 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect diff --git a/go.sum b/go.sum index bce8ce673c..e98c740bd2 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/Baidu-AIP/golang-sdk v1.1.1 h1:RQsAmgDSAkiq22I6n7XJ2t3afgzFeqjY46FGhv github.com/Baidu-AIP/golang-sdk v1.1.1/go.mod h1:bXnGw7xPeKt8aF7UCELKrV6UZ/46spItONK1RQBQj1Y= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= -github.com/FloatTech/AnimeAPI v1.6.1-0.20230409024643-f25135dee0da h1:QyH0zpWt3YspNNfZ+5f8+QStvtmxrzld/DoocKjF+rc= -github.com/FloatTech/AnimeAPI v1.6.1-0.20230409024643-f25135dee0da/go.mod h1:UnCPjtpIzpNBZ02yeGYp+oYVxgoi5aF2yAK2bkOVxtI= +github.com/FloatTech/AnimeAPI v1.6.1-0.20230716130052-ec46a05ce2d6 h1:dNexfRJ51d2s8mVNNlZ/9wRR12Uu75oikd51ayYxWOI= +github.com/FloatTech/AnimeAPI v1.6.1-0.20230716130052-ec46a05ce2d6/go.mod h1:fWJ5hx1ggDmLyLldO53Go97zc1JpWnDpsC5qeTOcaVw= github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 h1:/eQoMa6Aj3coF5F7yhzZe1+SzX6SItul7MW8//pl18o= github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI= github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 h1:dPLeoiTVSBlgls+66EB/UJ2e38BaASmBN5nANaycSBU= diff --git a/plugin/runcode/code_runner.go b/plugin/runcode/code_runner.go index 3f648c4f91..359e70c666 100644 --- a/plugin/runcode/code_runner.go +++ b/plugin/runcode/code_runner.go @@ -12,7 +12,7 @@ import ( "github.com/wdvxdr1123/ZeroBot/message" ) -var ro = runoob.NewRunOOB("b6365362a90ac2ac7098ba52c13e352b") +var ro = runoob.NewRunOOB("066417defb80d038228de76ec581a50a") func init() { control.Register("runcode", &ctrl.Options[*zero.Ctx]{ @@ -59,7 +59,7 @@ func init() { } else { // 运行成功 output = cutTooLong(strings.Trim(output, "\n")) - if israw { + if israw && zero.AdminPermission(ctx) { ctx.SendChain(message.Text(output)) } else { ctx.SendChain( From 5931e03c00cf7b18df6b9f64d881403654cbb2db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=AB=E6=80=9D=E6=BD=8B?= <55676105+shudorcl@users.noreply.github.com> Date: Tue, 18 Jul 2023 23:46:28 +0800 Subject: [PATCH 80/95] *update help command (#703) --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 4f3730339d..54b4c3ce55 100644 --- a/main.go +++ b/main.go @@ -313,7 +313,7 @@ func main() { rand.Seed(time.Now().UnixNano()) //nolint: staticcheck } // 帮助 - zero.OnFullMatchGroup([]string{"/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true). + zero.OnFullMatchGroup([]string{"help", "/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true). Handle(func(ctx *zero.Ctx) { ctx.SendChain(message.Text(banner.Banner, "\n管理发送\"/服务列表\"查看 bot 功能\n发送\"/用法name\"查看功能用法")) }) From eb43f84d348237327e116d0554e25d72932ca23b Mon Sep 17 00:00:00 2001 From: Jiang-Red <79574799+Jiang-Red@users.noreply.github.com> Date: Sun, 23 Jul 2023 00:41:00 +0800 Subject: [PATCH 81/95] fix title (#705) --- console/console_windows.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/console/console_windows.go b/console/console_windows.go index 66253dba01..e4b5ed1b34 100644 --- a/console/console_windows.go +++ b/console/console_windows.go @@ -79,7 +79,7 @@ func init() { logrus.Warnln("VT100设置失败, 将以无色模式输出") } - err = setConsoleTitle("ZeroBot-Blugin " + banner.Version + " " + banner.Copyright) + err = setConsoleTitle("ZeroBot-Plugin " + banner.Version + " " + banner.Copyright) if err != nil { panic(err) } From ebcd3cdef2d226ee22bab1b1f02eceedb498f8db Mon Sep 17 00:00:00 2001 From: Jiang-Red <79574799+Jiang-Red@users.noreply.github.com> Date: Thu, 27 Jul 2023 13:20:51 +0800 Subject: [PATCH 82/95] fix shindan (#706) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3a2c75add8..9a97821267 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/Baidu-AIP/golang-sdk v1.1.1 - github.com/FloatTech/AnimeAPI v1.6.1-0.20230716130052-ec46a05ce2d6 + github.com/FloatTech/AnimeAPI v1.6.1-0.20230724165034-a3cf504fab92 github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 github.com/FloatTech/imgfactory v0.2.2-0.20230413152719-e101cc3606ef diff --git a/go.sum b/go.sum index e98c740bd2..9673680be8 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/Baidu-AIP/golang-sdk v1.1.1 h1:RQsAmgDSAkiq22I6n7XJ2t3afgzFeqjY46FGhv github.com/Baidu-AIP/golang-sdk v1.1.1/go.mod h1:bXnGw7xPeKt8aF7UCELKrV6UZ/46spItONK1RQBQj1Y= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= -github.com/FloatTech/AnimeAPI v1.6.1-0.20230716130052-ec46a05ce2d6 h1:dNexfRJ51d2s8mVNNlZ/9wRR12Uu75oikd51ayYxWOI= -github.com/FloatTech/AnimeAPI v1.6.1-0.20230716130052-ec46a05ce2d6/go.mod h1:fWJ5hx1ggDmLyLldO53Go97zc1JpWnDpsC5qeTOcaVw= +github.com/FloatTech/AnimeAPI v1.6.1-0.20230724165034-a3cf504fab92 h1:B4IaLEhnXdr7oqszneri6ykdHggL2GvPUueBB5WxYVQ= +github.com/FloatTech/AnimeAPI v1.6.1-0.20230724165034-a3cf504fab92/go.mod h1:fWJ5hx1ggDmLyLldO53Go97zc1JpWnDpsC5qeTOcaVw= github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 h1:/eQoMa6Aj3coF5F7yhzZe1+SzX6SItul7MW8//pl18o= github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI= github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 h1:dPLeoiTVSBlgls+66EB/UJ2e38BaASmBN5nANaycSBU= From c8dcdbb0b2a97f0c102c584a9bcc9919ffa058c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Fri, 28 Jul 2023 13:56:48 +0800 Subject: [PATCH 83/95] =?UTF-8?q?world:=20=E4=B8=80=E5=A4=A7=E6=B3=A2?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8E=E5=8A=9F=E8=83=BD=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fix #441 - 优化wsserver解析 - 完善 ctx.this 相关函数 - 自动已读: Config 的 MarkMessage --- README.md | 37 ++++++++++---------------- data | 2 +- go.mod | 4 +-- go.sum | 8 +++--- main.go | 4 ++- plugin/antiabuse/anti.go | 2 +- plugin/baiduaudit/model.go | 2 +- plugin/event/event.go | 2 +- plugin/guessmusic/main.go | 2 +- plugin/manager/manager.go | 54 +++++++++++++------------------------- plugin/wtf/main.go | 2 +- 11 files changed, 47 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index b60444472e..22eb93929e 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ [![go](https://goreportcard.com/badge/github.com/FloatTech/ZeroBot-Plugin?style=flat-square&logo=go)](https://goreportcard.com/badge/github.com/FloatTech/ZeroBot-Plugin) [![onebot](https://img.shields.io/badge/onebot-v11-black?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHAAAABwCAMAAADxPgR5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAxQTFRF////29vbr6+vAAAAk1hCcwAAAAR0Uk5T////AEAqqfQAAAKcSURBVHja7NrbctswDATQXfD//zlpO7FlmwAWIOnOtNaTM5JwDMa8E+PNFz7g3waJ24fviyDPgfhz8fHP39cBcBL9KoJbQUxjA2iYqHL3FAnvzhL4GtVNUcoSZe6eSHizBcK5LL7dBr2AUZlev1ARRHCljzRALIEog6H3U6bCIyqIZdAT0eBuJYaGiJaHSjmkYIZd+qSGWAQnIaz2OArVnX6vrItQvbhZJtVGB5qX9wKqCMkb9W7aexfCO/rwQRBzsDIsYx4AOz0nhAtWu7bqkEQBO0Pr+Ftjt5fFCUEbm0Sbgdu8WSgJ5NgH2iu46R/o1UcBXJsFusWF/QUaz3RwJMEgngfaGGdSxJkE/Yg4lOBryBiMwvAhZrVMUUvwqU7F05b5WLaUIN4M4hRocQQRnEedgsn7TZB3UCpRrIJwQfqvGwsg18EnI2uSVNC8t+0QmMXogvbPg/xk+Mnw/6kW/rraUlvqgmFreAA09xW5t0AFlHrQZ3CsgvZm0FbHNKyBmheBKIF2cCA8A600aHPmFtRB1XvMsJAiza7LpPog0UJwccKdzw8rdf8MyN2ePYF896LC5hTzdZqxb6VNXInaupARLDNBWgI8spq4T0Qb5H4vWfPmHo8OyB1ito+AysNNz0oglj1U955sjUN9d41LnrX2D/u7eRwxyOaOpfyevCWbTgDEoilsOnu7zsKhjRCsnD/QzhdkYLBLXjiK4f3UWmcx2M7PO21CKVTH84638NTplt6JIQH0ZwCNuiWAfvuLhdrcOYPVO9eW3A67l7hZtgaY9GZo9AFc6cryjoeFBIWeU+npnk/nLE0OxCHL1eQsc1IciehjpJv5mqCsjeopaH6r15/MrxNnVhu7tmcslay2gO2Z1QfcfX0JMACG41/u0RrI9QAAAABJRU5ErkJggg==)](https://t.me/zerobotplugin) - [![zerobot](https://img.shields.io/badge/zerobot-v1.6.11-black?style=flat-square&logo=go)](https://github.com/wdvxdr1123/ZeroBot) + [![zerobot](https://img.shields.io/badge/zerobot-v1.7.2-black?style=flat-square&logo=go)](https://github.com/wdvxdr1123/ZeroBot) [![license](https://img.shields.io/github/license/FloatTech/ZeroBot-Plugin.svg?style=flat-square&logo=gnu)](https://raw.githubusercontent.com/FloatTech/ZeroBot-Plugin/master/LICENSE) [![tencent-qq](https://img.shields.io/badge/group-1048452984-red?style=flat-square&logo=tencent-qq)](https://jq.qq.com/?_wv=1027&k=QMb7x1mM) [![telegram](https://img.shields.io/badge/Telegram-click%20me-informational?style=flat-square&logo=telegram)](https://t.me/zerobotplugin) @@ -42,9 +42,10 @@ ## 命令行参数 > `[]`代表是可选参数 ```bash -zerobot [-h] [-n nickname] [-t token] [-u url] [-g url] [-p prefix] [-d|w] [-c|s config.json] [-l latency] [-r ringlen] [-x max process time] [qq1 qq2 qq3 ...] [&] +zerobot [-h] [-m] [-n nickname] [-t token] [-u url] [-g url] [-p prefix] [-d|w] [-c|s config.json] [-l latency] [-r ringlen] [-x max process time] [qq1 qq2 qq3 ...] [&] ``` - **-h**: 显示帮助 +- **-m**: 不自动标记消息为已读 - **-n nickname**: 设置默认昵称,默认为`椛椛` - **-t token**: 设置`AccessToken`,默认为空 - **-u url**: 设置`Url`,默认为`ws://127.0.0.1:6700` @@ -62,27 +63,17 @@ zerobot [-h] [-n nickname] [-t token] [-u url] [-g url] [-p prefix] [-d|w] [-c|s 默认配置文件格式如下。当选择从配置文件加载时,将忽略相应命令行参数。 ```json { - "zero": { - "nickname": [ - "椛椛", - "ATRI", - "atri", - "亚托莉", - "アトリ" - ], - "command_prefix": "/", - "super_users": [], - "ring_len": 4096, - "latency": 233000000, - "max_process_time": 240000000000 - }, - "ws": [ - { - "Url": "ws://127.0.0.1:6700", - "AccessToken": "" - } - ], - "wss": null + "zero": { + "nickname": ["椛椛", "ATRI", "atri", "亚托莉", "アトリ"], + "command_prefix": "/", + "super_users": [], + "ring_len": 4096, + "latency": 233000000, + "max_process_time": 240000000000, + "mark_message": true + }, + "ws": [{ "Url": "ws://127.0.0.1:6700", "AccessToken": "" }], + "wss": null } ``` diff --git a/data b/data index d0342c3806..9cab8a7bae 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit d0342c38067c5cc34880bcaf0bab6e88fb5d242e +Subproject commit 9cab8a7bae5d076e7440475750cd0b54f19fe558 diff --git a/go.mod b/go.mod index 9a97821267..4dc632f0a7 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/FloatTech/sqlite v1.6.2 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b github.com/FloatTech/zbpctrl v1.5.3-0.20230514154630-b74e6fcca380 - github.com/FloatTech/zbputils v1.6.2-0.20230514154857-9363fdb11fd6 + github.com/FloatTech/zbputils v1.6.2-0.20230728055141-bf0c1f30e617 github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 @@ -37,7 +37,7 @@ require ( github.com/sirupsen/logrus v1.9.0 github.com/tidwall/gjson v1.14.4 github.com/wcharczuk/go-chart/v2 v2.1.0 - github.com/wdvxdr1123/ZeroBot v1.6.11 + github.com/wdvxdr1123/ZeroBot v1.7.2 gitlab.com/gomidi/midi/v2 v2.0.25 golang.org/x/image v0.3.0 golang.org/x/sys v0.4.0 diff --git a/go.sum b/go.sum index 9673680be8..73e73577cb 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJG github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= github.com/FloatTech/zbpctrl v1.5.3-0.20230514154630-b74e6fcca380 h1:qmwoT8xVaND01aCdwy+5/j6z490nehQWZAVyTBN8ahU= github.com/FloatTech/zbpctrl v1.5.3-0.20230514154630-b74e6fcca380/go.mod h1:gkGC1C1eEUd/Ld/ja68zas5j2ZktIZCdnj2FMaM+Au0= -github.com/FloatTech/zbputils v1.6.2-0.20230514154857-9363fdb11fd6 h1:uss0/IszBjik7LSM5Q4xQ9FaDXAC7vK7y1dAaOj4UAk= -github.com/FloatTech/zbputils v1.6.2-0.20230514154857-9363fdb11fd6/go.mod h1:JXRQf2GAzpd7gp853LP6PU3O4pkRoFFuKGykcBChPNk= +github.com/FloatTech/zbputils v1.6.2-0.20230728055141-bf0c1f30e617 h1:9qDcXB3ILqncMUBVqCXe6dLjNUIYCIMo5kcQHfCAXEU= +github.com/FloatTech/zbputils v1.6.2-0.20230728055141-bf0c1f30e617/go.mod h1:x99mMbbJrybb0dSKHL20hHutmjWop8CFP0X6Ywn8V78= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= @@ -203,8 +203,8 @@ github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYm github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4= github.com/wcharczuk/go-chart/v2 v2.1.0 h1:tY2slqVQ6bN+yHSnDYwZebLQFkphK4WNrVwnt7CJZ2I= github.com/wcharczuk/go-chart/v2 v2.1.0/go.mod h1:yx7MvAVNcP/kN9lKXM/NTce4au4DFN99j6i1OwDclNA= -github.com/wdvxdr1123/ZeroBot v1.6.11 h1:44Wr6CsCtWlFensK5IhuVCWkosdRw0rA8SygVD8DgoI= -github.com/wdvxdr1123/ZeroBot v1.6.11/go.mod h1:y29UIOy0RD3P+0meDNIWRhcJF3jtWPN9xP9hgt/AJAU= +github.com/wdvxdr1123/ZeroBot v1.7.2 h1:aSibGY9X4xXbIF7IAffsf1OqNMIM9WIi1APtFYEVxL0= +github.com/wdvxdr1123/ZeroBot v1.7.2/go.mod h1:y29UIOy0RD3P+0meDNIWRhcJF3jtWPN9xP9hgt/AJAU= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= diff --git a/main.go b/main.go index 54b4c3ce55..15c4f10439 100644 --- a/main.go +++ b/main.go @@ -231,6 +231,7 @@ func init() { late := flag.Uint("l", 233, "Response latency (ms).") rsz := flag.Uint("r", 4096, "Receiving buffer ring size.") maxpt := flag.Uint("x", 4, "Max process time (min).") + markmsg := flag.Bool("m", false, "Don't mark message as read automatically") flag.Parse() @@ -277,7 +278,7 @@ func init() { config.Z.Driver[i] = w } for i, s := range config.S { - config.Z.Driver[i+len(config.W)] = driver.NewWebSocketServer(16, s.Url, s.AccessToken) + config.Z.Driver[i+len(config.W)] = s } logrus.Infoln("[main] 从", *runcfg, "读取配置文件") return @@ -290,6 +291,7 @@ func init() { RingLen: *rsz, Latency: time.Duration(*late) * time.Millisecond, MaxProcessTime: time.Duration(*maxpt) * time.Minute, + MarkMessage: !*markmsg, Driver: []zero.Driver{config.W[0]}, } diff --git a/plugin/antiabuse/anti.go b/plugin/antiabuse/anti.go index 9d3d8cc1b6..c9f19bd1a7 100644 --- a/plugin/antiabuse/anti.go +++ b/plugin/antiabuse/anti.go @@ -70,7 +70,7 @@ func init() { if err := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]).Manager.DoBlock(uid); err == nil { t := time.Now().Unix() cache.Set(uid, struct{}{}) - ctx.SetGroupBan(gid, uid, int64(bandur.Minutes())) + ctx.SetThisGroupBan(uid, int64(bandur.Minutes())) ctx.SendChain(message.Text("检测到违禁词, 已封禁/屏蔽", bandur)) db.Lock() defer db.Unlock() diff --git a/plugin/baiduaudit/model.go b/plugin/baiduaudit/model.go index 43fdc99aa8..34b97fc10a 100644 --- a/plugin/baiduaudit/model.go +++ b/plugin/baiduaudit/model.go @@ -68,7 +68,7 @@ func (bdres *baiduRes) audit(ctx *zero.Ctx, configpath string) { bantime = group.BANTime * 60 } // 执行禁言 - ctx.SetGroupBan(ctx.Event.GroupID, ctx.Event.UserID, bantime) + ctx.SetThisGroupBan(ctx.Event.UserID, bantime) } // 查看是否开启撤回提示 if group.DMRemind { diff --git a/plugin/event/event.go b/plugin/event/event.go index 66c538901e..bc1cb508ef 100644 --- a/plugin/event/event.go +++ b/plugin/event/event.go @@ -39,8 +39,8 @@ func init() { userid := ctx.Event.UserID username := ctx.CardOrNickName(userid) data := (storage)(c.GetData(-su)) + groupname := ctx.GetThisGroupInfo(true).Name groupid := ctx.Event.GroupID - groupname := ctx.GetGroupInfo(groupid, true).Name logrus.Info("[event]收到来自[", username, "](", userid, ")的群聊邀请,群:[", groupname, "](", groupid, ")") if data.isinviteon() || (!data.ismasteroff() && zero.SuperUserPermission(ctx)) { ctx.SetGroupAddRequest(ctx.Event.Flag, "invite", true, "") diff --git a/plugin/guessmusic/main.go b/plugin/guessmusic/main.go index e910bc7db6..fa1621bffa 100644 --- a/plugin/guessmusic/main.go +++ b/plugin/guessmusic/main.go @@ -527,7 +527,7 @@ func getlist(pathOfMusic string) (list []listinfo, err error) { // 遍历群文件 func getFileURLbyFileName(ctx *zero.Ctx, fileName string) (fileSearchName, fileURL string) { - filesOfGroup := ctx.GetThisGroupRootFiles(ctx.Event.GroupID) + filesOfGroup := ctx.GetThisGroupRootFiles() files := filesOfGroup.Get("files").Array() folders := filesOfGroup.Get("folders").Array() // 遍历当前目录的文件名 diff --git a/plugin/manager/manager.go b/plugin/manager/manager.go index 17fe0502c7..a159781fb2 100644 --- a/plugin/manager/manager.go +++ b/plugin/manager/manager.go @@ -95,13 +95,11 @@ func init() { // 插件主体 // 升为管理 engine.OnRegex(`^升为管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true). Handle(func(ctx *zero.Ctx) { - ctx.SetGroupAdmin( - ctx.Event.GroupID, + ctx.SetThisGroupAdmin( math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被升为管理的人的qq true, ) - nickname := ctx.GetGroupMemberInfo( // 被升为管理的人的昵称 - ctx.Event.GroupID, + nickname := ctx.GetThisGroupMemberInfo( // 被升为管理的人的昵称 math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被升为管理的人的qq false, ).Get("nickname").Str @@ -110,13 +108,11 @@ func init() { // 插件主体 // 取消管理 engine.OnRegex(`^取消管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true). Handle(func(ctx *zero.Ctx) { - ctx.SetGroupAdmin( - ctx.Event.GroupID, + ctx.SetThisGroupAdmin( math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被取消管理的人的qq false, ) - nickname := ctx.GetGroupMemberInfo( // 被取消管理的人的昵称 - ctx.Event.GroupID, + nickname := ctx.GetThisGroupMemberInfo( // 被取消管理的人的昵称 math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被取消管理的人的qq false, ).Get("nickname").Str @@ -125,13 +121,11 @@ func init() { // 插件主体 // 踢出群聊 engine.OnRegex(`^踢出群聊.*?(\d+)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true). Handle(func(ctx *zero.Ctx) { - ctx.SetGroupKick( - ctx.Event.GroupID, + ctx.SetThisGroupKick( math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被踢出群聊的人的qq false, ) - nickname := ctx.GetGroupMemberInfo( // 被踢出群聊的人的昵称 - ctx.Event.GroupID, + nickname := ctx.GetThisGroupMemberInfo( // 被踢出群聊的人的昵称 math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被踢出群聊的人的qq false, ).Get("nickname").Str @@ -148,19 +142,13 @@ func init() { // 插件主体 // 开启全体禁言 engine.OnRegex(`^开启全员禁言$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true). Handle(func(ctx *zero.Ctx) { - ctx.SetGroupWholeBan( - ctx.Event.GroupID, - true, - ) + ctx.SetThisGroupWholeBan(true) ctx.SendChain(message.Text("全员自闭开始~")) }) // 解除全员禁言 engine.OnRegex(`^解除全员禁言$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true). Handle(func(ctx *zero.Ctx) { - ctx.SetGroupWholeBan( - ctx.Event.GroupID, - false, - ) + ctx.SetThisGroupWholeBan(false) ctx.SendChain(message.Text("全员自闭结束~")) }) // 禁言 @@ -180,8 +168,7 @@ func init() { // 插件主体 if duration >= 43200 { duration = 43199 // qq禁言最大时长为一个月 } - ctx.SetGroupBan( - ctx.Event.GroupID, + ctx.SetThisGroupBan( math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 要禁言的人的qq duration*60, // 要禁言的时间(分钟) ) @@ -190,8 +177,7 @@ func init() { // 插件主体 // 解除禁言 engine.OnRegex(`^解除禁言.*?(\d+)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true). Handle(func(ctx *zero.Ctx) { - ctx.SetGroupBan( - ctx.Event.GroupID, + ctx.SetThisGroupBan( math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 要解除禁言的人的qq 0, ) @@ -214,8 +200,7 @@ func init() { // 插件主体 if duration >= 43200 { duration = 43199 // qq禁言最大时长为一个月 } - ctx.SetGroupBan( - ctx.Event.GroupID, + ctx.SetThisGroupBan( ctx.Event.UserID, duration*60, // 要自闭的时间(分钟) ) @@ -228,8 +213,7 @@ func init() { // 插件主体 ctx.SendChain(message.Text("名字太长啦!")) return } - ctx.SetGroupCard( - ctx.Event.GroupID, + ctx.SetThisGroupCard( math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被修改群名片的人 ctx.State["regex_matched"].([]string)[2], // 修改成的群名片 ) @@ -246,8 +230,7 @@ func init() { // 插件主体 ctx.SendChain(message.Text("头衔太长啦!")) return } - ctx.SetGroupSpecialTitle( - ctx.Event.GroupID, + ctx.SetThisGroupSpecialTitle( math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被修改群头衔的人 sptitle, // 修改成的群头衔 ) @@ -264,8 +247,7 @@ func init() { // 插件主体 ctx.SendChain(message.Text("头衔太长啦!")) return } - ctx.SetGroupSpecialTitle( - ctx.Event.GroupID, + ctx.SetThisGroupSpecialTitle( ctx.Event.UserID, // 被修改群头衔的人 sptitle, // 修改成的群头衔 ) @@ -445,7 +427,7 @@ func init() { // 插件主体 case <-time.After(time.Minute): cancel() ctx.SendChain(message.Text("拜拜啦~")) - ctx.SetGroupKick(ctx.Event.GroupID, uid, false) + ctx.SetThisGroupKick(uid, false) case <-recv: cancel() ctx.SendChain(message.Text("答对啦~")) @@ -594,7 +576,7 @@ func init() { // 插件主体 if ok { ctx.SetGroupAddRequest(ctx.Event.Flag, "add", true, "") process.SleepAbout1sTo2s() - ctx.SetGroupCard(ctx.Event.GroupID, ctx.Event.UserID, ghun) + ctx.SetThisGroupCard(ctx.Event.UserID, ghun) } else { ctx.SetGroupAddRequest(ctx.Event.Flag, "add", false, reason) } @@ -618,7 +600,7 @@ func init() { // 插件主体 } }) engine.OnCommand("精华列表", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { - list := ctx.GetGroupEssenceMessageList(ctx.Event.GroupID).Array() + list := ctx.GetThisGroupEssenceMessageList().Array() msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("本群精华列表:"))} n := len(list) if n > 30 { @@ -675,7 +657,7 @@ func welcometocq(ctx *zero.Ctx, welcome string) string { at := "[CQ:at,qq=" + uid + "]" // at用户 avatar := "[CQ:image,file=" + "http://q4.qlogo.cn/g?b=qq&nk=" + uid + "&s=640]" // 用户头像 gid := strconv.FormatInt(ctx.Event.GroupID, 10) // 群id - groupname := ctx.GetGroupInfo(ctx.Event.GroupID, true).Name // 群名 + groupname := ctx.GetThisGroupInfo(true).Name // 群名 cqstring := strings.ReplaceAll(welcome, "{at}", at) cqstring = strings.ReplaceAll(cqstring, "{nickname}", nickname) cqstring = strings.ReplaceAll(cqstring, "{avatar}", avatar) diff --git a/plugin/wtf/main.go b/plugin/wtf/main.go index b641888bfb..a3290d327d 100644 --- a/plugin/wtf/main.go +++ b/plugin/wtf/main.go @@ -44,7 +44,7 @@ func init() { var secondname string if len(ctx.Event.Message) > 1 && ctx.Event.Message[1].Type == "at" { qq, _ := strconv.ParseInt(ctx.Event.Message[1].Data["qq"], 10, 64) - secondname = ctx.GetGroupMemberInfo(ctx.Event.GroupID, qq, false).Get("nickname").Str + secondname = ctx.GetThisGroupMemberInfo(qq, false).Get("nickname").Str } name = ctx.Event.Sender.NickName var text string From 7f264964c2db65f6c9363bd06f05d83233e0209a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Fri, 28 Jul 2023 13:59:33 +0800 Subject: [PATCH 84/95] =?UTF-8?q?=F0=9F=94=96=20v1.7.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kanban/banner/banner.go | 4 ++-- winres/winres.json | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kanban/banner/banner.go b/kanban/banner/banner.go index b2d57a299a..ba64dacdec 100644 --- a/kanban/banner/banner.go +++ b/kanban/banner/banner.go @@ -3,13 +3,13 @@ package banner // Version ... -var Version = "v1.7.1" +var Version = "v1.7.2" // Copyright ... var Copyright = "© 2020 - 2023 FloatTech" // Banner ... var Banner = "* OneBot + ZeroBot + Golang\n" + - "* Version " + Version + " - 2023-04-30 13:51:47 +0800 CST\n" + + "* Version " + Version + " - 2023-07-28 13:58:50 +0800 CST\n" + "* Copyright " + Copyright + ". All Rights Reserved.\n" + "* Project: https://github.com/FloatTech/ZeroBot-Plugin" diff --git a/winres/winres.json b/winres/winres.json index 34cdfacac0..aab129f673 100644 --- a/winres/winres.json +++ b/winres/winres.json @@ -12,7 +12,7 @@ "0409": { "identity": { "name": "ZeroBot-Plugin", - "version": "1.7.1.1820" + "version": "1.7.2.1831" }, "description": "", "minimum-os": "vista", @@ -36,23 +36,23 @@ "#1": { "0000": { "fixed": { - "file_version": "1.7.1.1820", - "product_version": "v1.7.1", - "timestamp": "2023-04-30T13:52:06+08:00" + "file_version": "1.7.2.1831", + "product_version": "v1.7.2", + "timestamp": "2023-07-28T13:59:16+08:00" }, "info": { "0409": { "Comments": "OneBot plugins based on ZeroBot", "CompanyName": "FloatTech", "FileDescription": "https://github.com/FloatTech/ZeroBot-Plugin", - "FileVersion": "1.7.1.1820", + "FileVersion": "1.7.2.1831", "InternalName": "", "LegalCopyright": "© 2020 - 2023 FloatTech. All Rights Reserved.", "LegalTrademarks": "", "OriginalFilename": "ZBP.EXE", "PrivateBuild": "", "ProductName": "ZeroBot-Plugin", - "ProductVersion": "v1.7.1", + "ProductVersion": "v1.7.2", "SpecialBuild": "" } } From 0357405cdfc1c9c0a0722d363ea9531c6a96e368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Fri, 28 Jul 2023 16:29:56 +0800 Subject: [PATCH 85/95] =?UTF-8?q?=F0=9F=90=9B=20=E5=BF=83=E8=B7=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 4dc632f0a7..ac51a1c74a 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/FloatTech/sqlite v1.6.2 github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b github.com/FloatTech/zbpctrl v1.5.3-0.20230514154630-b74e6fcca380 - github.com/FloatTech/zbputils v1.6.2-0.20230728055141-bf0c1f30e617 + github.com/FloatTech/zbputils v1.6.2-0.20230728081122-94d4d957f3bf github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 @@ -37,7 +37,7 @@ require ( github.com/sirupsen/logrus v1.9.0 github.com/tidwall/gjson v1.14.4 github.com/wcharczuk/go-chart/v2 v2.1.0 - github.com/wdvxdr1123/ZeroBot v1.7.2 + github.com/wdvxdr1123/ZeroBot v1.7.4 gitlab.com/gomidi/midi/v2 v2.0.25 golang.org/x/image v0.3.0 golang.org/x/sys v0.4.0 diff --git a/go.sum b/go.sum index 73e73577cb..4fc6a4ad9c 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJG github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= github.com/FloatTech/zbpctrl v1.5.3-0.20230514154630-b74e6fcca380 h1:qmwoT8xVaND01aCdwy+5/j6z490nehQWZAVyTBN8ahU= github.com/FloatTech/zbpctrl v1.5.3-0.20230514154630-b74e6fcca380/go.mod h1:gkGC1C1eEUd/Ld/ja68zas5j2ZktIZCdnj2FMaM+Au0= -github.com/FloatTech/zbputils v1.6.2-0.20230728055141-bf0c1f30e617 h1:9qDcXB3ILqncMUBVqCXe6dLjNUIYCIMo5kcQHfCAXEU= -github.com/FloatTech/zbputils v1.6.2-0.20230728055141-bf0c1f30e617/go.mod h1:x99mMbbJrybb0dSKHL20hHutmjWop8CFP0X6Ywn8V78= +github.com/FloatTech/zbputils v1.6.2-0.20230728081122-94d4d957f3bf h1:PwH9aMnmN+m204cVIqUrI3e7nsdQi/IGW012Fjzb1bs= +github.com/FloatTech/zbputils v1.6.2-0.20230728081122-94d4d957f3bf/go.mod h1:JRnGR7EGeEQgxOs+c0rZAhrS9Es2BTcGHdIDHXIPRzQ= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= @@ -203,8 +203,8 @@ github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYm github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4= github.com/wcharczuk/go-chart/v2 v2.1.0 h1:tY2slqVQ6bN+yHSnDYwZebLQFkphK4WNrVwnt7CJZ2I= github.com/wcharczuk/go-chart/v2 v2.1.0/go.mod h1:yx7MvAVNcP/kN9lKXM/NTce4au4DFN99j6i1OwDclNA= -github.com/wdvxdr1123/ZeroBot v1.7.2 h1:aSibGY9X4xXbIF7IAffsf1OqNMIM9WIi1APtFYEVxL0= -github.com/wdvxdr1123/ZeroBot v1.7.2/go.mod h1:y29UIOy0RD3P+0meDNIWRhcJF3jtWPN9xP9hgt/AJAU= +github.com/wdvxdr1123/ZeroBot v1.7.4 h1:+148rELpf/FCDW2EuvKqpb9bNKcwKRtoh16s2sIb5SE= +github.com/wdvxdr1123/ZeroBot v1.7.4/go.mod h1:y29UIOy0RD3P+0meDNIWRhcJF3jtWPN9xP9hgt/AJAU= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= From 38b11bb8c9948c57860f986b49368d3a0f5b749f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Fri, 28 Jul 2023 16:32:00 +0800 Subject: [PATCH 86/95] =?UTF-8?q?=F0=9F=93=9D=20edit=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 22eb93929e..1c788dccb3 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ [![go](https://goreportcard.com/badge/github.com/FloatTech/ZeroBot-Plugin?style=flat-square&logo=go)](https://goreportcard.com/badge/github.com/FloatTech/ZeroBot-Plugin) [![onebot](https://img.shields.io/badge/onebot-v11-black?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHAAAABwCAMAAADxPgR5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAxQTFRF////29vbr6+vAAAAk1hCcwAAAAR0Uk5T////AEAqqfQAAAKcSURBVHja7NrbctswDATQXfD//zlpO7FlmwAWIOnOtNaTM5JwDMa8E+PNFz7g3waJ24fviyDPgfhz8fHP39cBcBL9KoJbQUxjA2iYqHL3FAnvzhL4GtVNUcoSZe6eSHizBcK5LL7dBr2AUZlev1ARRHCljzRALIEog6H3U6bCIyqIZdAT0eBuJYaGiJaHSjmkYIZd+qSGWAQnIaz2OArVnX6vrItQvbhZJtVGB5qX9wKqCMkb9W7aexfCO/rwQRBzsDIsYx4AOz0nhAtWu7bqkEQBO0Pr+Ftjt5fFCUEbm0Sbgdu8WSgJ5NgH2iu46R/o1UcBXJsFusWF/QUaz3RwJMEgngfaGGdSxJkE/Yg4lOBryBiMwvAhZrVMUUvwqU7F05b5WLaUIN4M4hRocQQRnEedgsn7TZB3UCpRrIJwQfqvGwsg18EnI2uSVNC8t+0QmMXogvbPg/xk+Mnw/6kW/rraUlvqgmFreAA09xW5t0AFlHrQZ3CsgvZm0FbHNKyBmheBKIF2cCA8A600aHPmFtRB1XvMsJAiza7LpPog0UJwccKdzw8rdf8MyN2ePYF896LC5hTzdZqxb6VNXInaupARLDNBWgI8spq4T0Qb5H4vWfPmHo8OyB1ito+AysNNz0oglj1U955sjUN9d41LnrX2D/u7eRwxyOaOpfyevCWbTgDEoilsOnu7zsKhjRCsnD/QzhdkYLBLXjiK4f3UWmcx2M7PO21CKVTH84638NTplt6JIQH0ZwCNuiWAfvuLhdrcOYPVO9eW3A67l7hZtgaY9GZo9AFc6cryjoeFBIWeU+npnk/nLE0OxCHL1eQsc1IciehjpJv5mqCsjeopaH6r15/MrxNnVhu7tmcslay2gO2Z1QfcfX0JMACG41/u0RrI9QAAAABJRU5ErkJggg==)](https://t.me/zerobotplugin) - [![zerobot](https://img.shields.io/badge/zerobot-v1.7.2-black?style=flat-square&logo=go)](https://github.com/wdvxdr1123/ZeroBot) + [![zerobot](https://img.shields.io/badge/zerobot-v1.7.4-black?style=flat-square&logo=go)](https://github.com/wdvxdr1123/ZeroBot) [![license](https://img.shields.io/github/license/FloatTech/ZeroBot-Plugin.svg?style=flat-square&logo=gnu)](https://raw.githubusercontent.com/FloatTech/ZeroBot-Plugin/master/LICENSE) [![tencent-qq](https://img.shields.io/badge/group-1048452984-red?style=flat-square&logo=tencent-qq)](https://jq.qq.com/?_wv=1027&k=QMb7x1mM) [![telegram](https://img.shields.io/badge/Telegram-click%20me-informational?style=flat-square&logo=telegram)](https://t.me/zerobotplugin) From 986e50705df1fbb722d3ef1c6b8361b1dc8b611c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=B2=E5=AE=9D=E5=9D=8F=E5=9D=8F=E5=9D=8F?= <2758988938@qq.com> Date: Wed, 23 Aug 2023 12:25:22 +0800 Subject: [PATCH 87/95] fix bilibili (#710) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix bilibili * 1 * fix * 123 * 做了一下修改的提交 * 1 * make master happy * 最后一次 --- plugin/bilibili/bilibilipush.go | 157 ++++++++++++++++++++++++++------ 1 file changed, 131 insertions(+), 26 deletions(-) diff --git a/plugin/bilibili/bilibilipush.go b/plugin/bilibili/bilibilipush.go index 09bb21514e..2ed6d62308 100644 --- a/plugin/bilibili/bilibilipush.go +++ b/plugin/bilibili/bilibilipush.go @@ -3,38 +3,56 @@ package bilibili import ( "bytes" + "crypto/md5" + "encoding/hex" "encoding/json" "fmt" "net/http" + "net/url" + "path/filepath" + "sort" "strconv" + "strings" "time" - "github.com/pkg/errors" - "github.com/tidwall/gjson" - zero "github.com/wdvxdr1123/ZeroBot" - "github.com/wdvxdr1123/ZeroBot/message" - bz "github.com/FloatTech/AnimeAPI/bilibili" "github.com/FloatTech/floatbox/binary" "github.com/FloatTech/floatbox/web" ctrl "github.com/FloatTech/zbpctrl" "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/img/text" + "github.com/RomiChan/syncx" + "github.com/pkg/errors" + "github.com/tidwall/gjson" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" + "github.com/wdvxdr1123/ZeroBot/utils/helper" ) const ( ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36" - referer = "https://www.bilibili.com/" - infoURL = "https://api.bilibili.com/x/space/acc/info?mid=%v" + referer = "https://space.bilibili.com/%v" + infoURL = "https://api.bilibili.com/x/space/wbi/acc/info?mid=%v&token=&platform=web&web_location=1550101" + navURL = "https://api.bilibili.com/x/web-interface/nav" ) // bdb bilibili推送数据库 var bdb *bilibilipushdb var ( - lastTime = map[int64]int64{} - liveStatus = map[int64]int{} - upMap = map[int64]string{} + lastTime = map[int64]int64{} + liveStatus = map[int64]int{} + upMap = map[int64]string{} + mixinKeyEncTab = [...]int{ + 46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49, + 33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40, + 61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, 62, 11, + 36, 20, 34, 44, 52, + } + cache syncx.Map[string, string] + lastUpdateTime time.Time + + replacements = [...]string{"!", "'", "(", ")", "*"} ) func init() { @@ -60,7 +78,7 @@ func init() { en.OnRegex(`^添加[B|b]站订阅\s?(.{1,25})$`, zero.UserOrGrpAdmin, getPara).SetBlock(true).Handle(func(ctx *zero.Ctx) { buid, _ := strconv.ParseInt(ctx.State["uid"].(string), 10, 64) name, err := getName(buid) - if err != nil { + if err != nil || name == "" { ctx.SendChain(message.Text("ERROR: ", err)) return } @@ -175,27 +193,17 @@ func init() { func getName(buid int64) (name string, err error) { var ok bool if name, ok = upMap[buid]; !ok { - var data []byte - data, err = web.RequestDataWithHeaders(web.NewDefaultClient(), fmt.Sprintf(infoURL, buid), "GET", func(r *http.Request) error { - r.Header.Set("refer", referer) - r.Header.Set("user-agent", ua) - cookie := "" - if cfg != nil { - cookie, err = cfg.Load() - if err != nil { - return err - } - } - r.Header.Set("cookie", cookie) + data, err := web.RequestDataWithHeaders(web.NewDefaultClient(), signURL(fmt.Sprintf(infoURL, buid)), "GET", func(r *http.Request) error { + r.Header.Set("User-Agent", ua) return nil }, nil) if err != nil { - return + return "", err } status := int(gjson.Get(binary.BytesToString(data), "code").Int()) if status != 0 { err = errors.New(gjson.Get(binary.BytesToString(data), "message").String()) - return + return "", err } name = gjson.Get(binary.BytesToString(data), "data.name").String() bdb.insertBilibiliUp(buid, name) @@ -204,6 +212,103 @@ func getName(buid int64) (name string, err error) { return } +func getMixinKey(orig string) string { + var str strings.Builder + t := 0 + for _, v := range mixinKeyEncTab { + if v < len(orig) { + str.WriteByte(orig[v]) + t++ + } + if t > 31 { + break + } + } + return str.String() +} + +func wbiSign(params map[string]string, imgKey string, subKey string) map[string]string { + mixinKey := getMixinKey(imgKey + subKey) + currTime := strconv.FormatInt(time.Now().Unix(), 10) + params["wts"] = currTime + // Sort keys + keys := make([]string, 0, len(params)) + for k, v := range params { + keys = append(keys, k) + for _, old := range replacements { + v = strings.ReplaceAll(v, old, "") + } + params[k] = v + } + sort.Strings(keys) + h := md5.New() + for k, v := range keys { + h.Write([]byte(v)) + h.Write([]byte{'='}) + h.Write([]byte(params[v])) + if k < len(keys)-1 { + h.Write([]byte{'&'}) + } + } + h.Write([]byte(mixinKey)) + params["w_rid"] = hex.EncodeToString(h.Sum(make([]byte, 0, md5.Size))) + return params +} + +func getWbiKeysCached() (string, string) { + if time.Since(lastUpdateTime).Minutes() > 10 { + imgKey, subKey := getWbiKeys() + cache.Store("imgKey", imgKey) + cache.Store("subKey", subKey) + lastUpdateTime = time.Now() + return imgKey, subKey + } + imgKeyI, _ := cache.Load("imgKey") + subKeyI, _ := cache.Load("subKey") + return imgKeyI, subKeyI +} + +func getWbiKeys() (string, string) { + data, _ := web.RequestDataWithHeaders(web.NewDefaultClient(), navURL, "GET", func(r *http.Request) error { + if cfg != nil { + cookie, err := cfg.Load() + if err == nil { + r.Header.Set("cookie", cookie) + return nil + } + return err + } + return errors.New("未配置-cookie") + }, nil) + json := helper.BytesToString(data) + imgURL := gjson.Get(json, "data.wbi_img.img_url").String() + subURL := gjson.Get(json, "data.wbi_img.sub_url").String() + imgKey := imgURL[strings.LastIndex(imgURL, "/")+1:] + imgKey = strings.TrimSuffix(imgKey, filepath.Ext(imgKey)) + subKey := subURL[strings.LastIndex(subURL, "/")+1:] + subKey = strings.TrimSuffix(subKey, filepath.Ext(subKey)) + return imgKey, subKey +} + +func signURL(urlStr string) string { + urlObj, _ := url.Parse(urlStr) + imgKey, subKey := getWbiKeysCached() + query := urlObj.Query() + params := map[string]string{} + for k, v := range query { + if len(v) > 0 { + params[k] = v[0] + } + } + newParams := wbiSign(params, imgKey, subKey) + for k, v := range newParams { + query.Set(k, v) + } + urlObj.RawQuery = query.Encode() + newURL := urlObj.String() + return newURL +} + // subscribe 订阅 func subscribe(buid, groupid int64) (err error) { bpMap := map[string]any{ @@ -276,7 +381,7 @@ func sendDynamic(ctx *zero.Ctx) error { return err } if len(cardList) == 0 { - return errors.Errorf("%v的历史动态数为0", buid) + return nil } t, ok := lastTime[buid] // 第一次先记录时间,啥也不做 From 26e4b3c513a832c06aabdba30a55097ea5966b2d Mon Sep 17 00:00:00 2001 From: Jiang-Red <79574799+Jiang-Red@users.noreply.github.com> Date: Fri, 25 Aug 2023 21:56:27 +0800 Subject: [PATCH 88/95] chore: bump to go1.21 (#717) --- .github/workflows/nightly.yml | 2 +- .github/workflows/pull.yml | 2 +- .github/workflows/push.yml | 2 +- .github/workflows/release.yml | 2 +- .golangci.yml | 2 +- .goreleaser.yml | 2 +- go.mod | 22 +++++++-------- go.sum | 51 ++++++++++++++++++----------------- 8 files changed, 43 insertions(+), 42 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 43dc5383b6..1137d09ab3 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -28,7 +28,7 @@ jobs: - name: Setup Go environment uses: actions/setup-go@master with: - go-version: '1.20' + go-version: '1.21' - name: Cache downloaded module uses: actions/cache@master with: diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index c3debcbb08..b4c21900cb 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -8,7 +8,7 @@ jobs: - name: Set up Go uses: actions/setup-go@master with: - go-version: '1.20' + go-version: '1.21' - name: Check out code into the Go module directory uses: actions/checkout@master diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index e30c986d05..e4de1bcbbc 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -8,7 +8,7 @@ jobs: - name: Set up Go uses: actions/setup-go@master with: - go-version: '1.20' + go-version: '1.21' - name: Check out code into the Go module directory uses: actions/checkout@master diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d56b29854f..8636a8e3f9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Go uses: actions/setup-go@master with: - go-version: '1.20' + go-version: '1.21' - name: Run GoReleaser uses: goreleaser/goreleaser-action@master diff --git a/.golangci.yml b/.golangci.yml index 383c903fdd..f21ef512de 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -59,7 +59,7 @@ run: tests: false skip-dirs: - order - go: '1.20' + go: '1.21' # output configuration options output: diff --git a/.goreleaser.yml b/.goreleaser.yml index 4206cc9658..a2bbb1eb0e 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -66,7 +66,7 @@ archives: format: zip nfpms: - - license: GPL 3.0 + - license: AGPL 3.0 homepage: https://github.com/FloatTech/ZeroBot-Plugin file_name_template: "zbp_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" formats: diff --git a/go.mod b/go.mod index ac51a1c74a..38575d2a0c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/FloatTech/ZeroBot-Plugin -go 1.20 +go 1.21 require ( github.com/Baidu-AIP/golang-sdk v1.1.1 @@ -32,7 +32,7 @@ require ( github.com/lithammer/fuzzysearch v1.1.5 github.com/mroth/weightedrand v1.0.0 github.com/pkg/errors v0.9.1 - github.com/quic-go/quic-go v0.32.0 + github.com/quic-go/quic-go v0.38.1 github.com/shirou/gopsutil/v3 v3.23.1 github.com/sirupsen/logrus v1.9.0 github.com/tidwall/gjson v1.14.4 @@ -40,8 +40,8 @@ require ( github.com/wdvxdr1123/ZeroBot v1.7.4 gitlab.com/gomidi/midi/v2 v2.0.25 golang.org/x/image v0.3.0 - golang.org/x/sys v0.4.0 - golang.org/x/text v0.6.0 + golang.org/x/sys v0.8.0 + golang.org/x/text v0.9.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -54,7 +54,7 @@ require ( github.com/fumiama/imgsz v0.0.2 // indirect github.com/gabriel-vasile/mimetype v1.0.4 // indirect github.com/go-ole/go-ole v1.2.6 // indirect - github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect + github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect @@ -67,14 +67,12 @@ require ( github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/mattn/go-isatty v0.0.16 // indirect github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect - github.com/onsi/ginkgo/v2 v2.2.0 // indirect + github.com/onsi/ginkgo/v2 v2.9.5 // indirect github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect github.com/pkumza/numcn v1.0.0 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/quic-go/qpack v0.4.0 // indirect - github.com/quic-go/qtls-go1-18 v0.2.0 // indirect - github.com/quic-go/qtls-go1-19 v0.2.0 // indirect - github.com/quic-go/qtls-go1-20 v0.1.0 // indirect + github.com/quic-go/qtls-go1-20 v0.3.3 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect @@ -85,9 +83,9 @@ require ( golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect golang.org/x/exp/shiny v0.0.0-20221126150942-6ab00d035af9 // indirect golang.org/x/mobile v0.0.0-20201217150744-e6ae53a27f4f // indirect - golang.org/x/mod v0.6.0 // indirect - golang.org/x/net v0.4.0 // indirect - golang.org/x/tools v0.2.0 // indirect + golang.org/x/mod v0.10.0 // indirect + golang.org/x/net v0.10.0 // indirect + golang.org/x/tools v0.9.1 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect modernc.org/libc v1.21.5 // indirect modernc.org/mathutil v1.5.0 // indirect diff --git a/go.sum b/go.sum index 4fc6a4ad9c..dea627fc85 100644 --- a/go.sum +++ b/go.sum @@ -83,13 +83,16 @@ github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebK github.com/go-audio/audio v1.0.0/go.mod h1:6uAu0+H2lHkwdGsAY+j2wHPNPpPoeg5AaEFh9FlA+Zs= github.com/go-audio/riff v1.0.0/go.mod h1:l3cQwc85y79NQFCRB7TiPoNiaijp6q8Z0Uv38rVG498= github.com/go-audio/wav v1.0.0/go.mod h1:3yoReyQOsiARkvPl3ERCi8JFjihzG6WhjYpZCf5zAWE= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= @@ -99,7 +102,8 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -151,9 +155,10 @@ github.com/mroth/weightedrand v1.0.0 h1:V8JeHChvl2MP1sAoXq4brElOcza+jxLkRuwvtQu8 github.com/mroth/weightedrand v1.0.0/go.mod h1:3p2SIcC8al1YMzGhAIoXD+r9olo/g/cdJgAD905gyNE= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= -github.com/onsi/ginkgo/v2 v2.2.0 h1:3ZNA3L1c5FYDFTTxbFeVGGD8jYvjYauHD30YgLxVsNI= -github.com/onsi/ginkgo/v2 v2.2.0/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk= -github.com/onsi/gomega v1.20.1 h1:PA/3qinGoukvymdIDV8pii6tiZgC8kbmJO6Z5+b002Q= +github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q= +github.com/onsi/ginkgo/v2 v2.9.5/go.mod h1:tvAoo1QUJwNEU2ITftXTpR7R1RbCzoZUOs3RonqW57k= +github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= +github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= @@ -168,14 +173,10 @@ github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= -github.com/quic-go/qtls-go1-18 v0.2.0 h1:5ViXqBZ90wpUcZS0ge79rf029yx0dYB0McyPJwqqj7U= -github.com/quic-go/qtls-go1-18 v0.2.0/go.mod h1:moGulGHK7o6O8lSPSZNoOwcLvJKJ85vVNc7oJFD65bc= -github.com/quic-go/qtls-go1-19 v0.2.0 h1:Cvn2WdhyViFUHoOqK52i51k4nDX8EwIh5VJiVM4nttk= -github.com/quic-go/qtls-go1-19 v0.2.0/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= -github.com/quic-go/qtls-go1-20 v0.1.0 h1:d1PK3ErFy9t7zxKsG3NXBJXZjp/kMLoIb3y/kV54oAI= -github.com/quic-go/qtls-go1-20 v0.1.0/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= -github.com/quic-go/quic-go v0.32.0 h1:lY02md31s1JgPiiyfqJijpu/UX/Iun304FI3yUqX7tA= -github.com/quic-go/quic-go v0.32.0/go.mod h1:/fCsKANhQIeD5l76c2JFU+07gVE3KaA0FP+0zMWwfwo= +github.com/quic-go/qtls-go1-20 v0.3.3 h1:17/glZSLI9P9fDAeyCHBFSWSqJcwx1byhLwP5eUIDCM= +github.com/quic-go/qtls-go1-20 v0.3.3/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= +github.com/quic-go/quic-go v0.38.1 h1:M36YWA5dEhEeT+slOu/SwMEucbYd0YFidxG3KlGPZaE= +github.com/quic-go/quic-go v0.38.1/go.mod h1:ijnZM7JsFIkp4cRyjxJNIzdSfCLmUMg9wdyhGmg+SN4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/shirou/gopsutil/v3 v3.23.1 h1:a9KKO+kGLKEvcPIs4W62v0nu3sciVDOOOPUD0Hz7z/4= @@ -185,7 +186,7 @@ github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -241,8 +242,8 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I= -golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= +golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= +golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -254,8 +255,8 @@ golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU= -golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= +golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -277,32 +278,34 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE= -golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= +golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= +golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 16e5b84e5cef8b17adaea0f965e09046013ccc45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 27 Aug 2023 16:28:11 +0800 Subject: [PATCH 89/95] =?UTF-8?q?=F0=9F=90=9B=20fix:=20=E4=BC=98=E5=85=88?= =?UTF-8?q?=E7=BA=A7=E4=B9=B1=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/nightly.yml | 2 +- .github/workflows/pull.yml | 2 +- .github/workflows/push.yml | 2 +- .github/workflows/release.yml | 2 +- .golangci.yml | 2 +- data | 2 +- go.mod | 2 +- go.sum | 5 ----- kanban/version<1.21.go | 5 +++++ 9 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 kanban/version<1.21.go diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 1137d09ab3..43dc5383b6 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -28,7 +28,7 @@ jobs: - name: Setup Go environment uses: actions/setup-go@master with: - go-version: '1.21' + go-version: '1.20' - name: Cache downloaded module uses: actions/cache@master with: diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index b4c21900cb..c3debcbb08 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -8,7 +8,7 @@ jobs: - name: Set up Go uses: actions/setup-go@master with: - go-version: '1.21' + go-version: '1.20' - name: Check out code into the Go module directory uses: actions/checkout@master diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index e4de1bcbbc..e30c986d05 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -8,7 +8,7 @@ jobs: - name: Set up Go uses: actions/setup-go@master with: - go-version: '1.21' + go-version: '1.20' - name: Check out code into the Go module directory uses: actions/checkout@master diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8636a8e3f9..d56b29854f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Go uses: actions/setup-go@master with: - go-version: '1.21' + go-version: '1.20' - name: Run GoReleaser uses: goreleaser/goreleaser-action@master diff --git a/.golangci.yml b/.golangci.yml index f21ef512de..383c903fdd 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -59,7 +59,7 @@ run: tests: false skip-dirs: - order - go: '1.21' + go: '1.20' # output configuration options output: diff --git a/data b/data index 9cab8a7bae..d5ec04118f 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit 9cab8a7bae5d076e7440475750cd0b54f19fe558 +Subproject commit d5ec04118feb3a9071b9290a4b6db327c206fca8 diff --git a/go.mod b/go.mod index 38575d2a0c..5fba74cba3 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/FloatTech/ZeroBot-Plugin -go 1.21 +go 1.20 require ( github.com/Baidu-AIP/golang-sdk v1.1.1 diff --git a/go.sum b/go.sum index dea627fc85..f285f4cb25 100644 --- a/go.sum +++ b/go.sum @@ -84,11 +84,9 @@ github.com/go-audio/audio v1.0.0/go.mod h1:6uAu0+H2lHkwdGsAY+j2wHPNPpPoeg5AaEFh9 github.com/go-audio/riff v1.0.0/go.mod h1:l3cQwc85y79NQFCRB7TiPoNiaijp6q8Z0Uv38rVG498= github.com/go-audio/wav v1.0.0/go.mod h1:3yoReyQOsiARkvPl3ERCi8JFjihzG6WhjYpZCf5zAWE= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= -github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= -github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= @@ -103,7 +101,6 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4er github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -158,7 +155,6 @@ github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q= github.com/onsi/ginkgo/v2 v2.9.5/go.mod h1:tvAoo1QUJwNEU2ITftXTpR7R1RbCzoZUOs3RonqW57k= github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= -github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= @@ -302,7 +298,6 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/kanban/version<1.21.go b/kanban/version<1.21.go new file mode 100644 index 0000000000..577d06be25 --- /dev/null +++ b/kanban/version<1.21.go @@ -0,0 +1,5 @@ +//go:build go1.21 + +package kanban + +const Error int = "请使用小于1.21版本的Go" From 245b50ba94efc71fe9f57627ed3af91c61405a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 27 Aug 2023 22:54:27 +0800 Subject: [PATCH 90/95] update genshin tts --- go.mod | 4 ++-- go.sum | 8 ++++---- plugin/ai_reply/ai_tts.go | 8 ++++---- plugin/ai_reply/main.go | 42 ++++++++++++++++++++------------------- plugin/moegoe/main.go | 9 ++++----- 5 files changed, 36 insertions(+), 35 deletions(-) diff --git a/go.mod b/go.mod index 5fba74cba3..b48785b1ba 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/Baidu-AIP/golang-sdk v1.1.1 - github.com/FloatTech/AnimeAPI v1.6.1-0.20230724165034-a3cf504fab92 + github.com/FloatTech/AnimeAPI v1.6.1-0.20230827144904-758793598579 github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 github.com/FloatTech/imgfactory v0.2.2-0.20230413152719-e101cc3606ef @@ -21,7 +21,7 @@ require ( github.com/disintegration/imaging v1.6.2 github.com/fumiama/ahsai v0.1.0 github.com/fumiama/cron v1.3.0 - github.com/fumiama/go-base16384 v1.6.4 + github.com/fumiama/go-base16384 v1.7.0 github.com/fumiama/go-registry v0.2.6 github.com/fumiama/gotracemoe v0.0.3 github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565 diff --git a/go.sum b/go.sum index f285f4cb25..a6ee8c9db9 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/Baidu-AIP/golang-sdk v1.1.1 h1:RQsAmgDSAkiq22I6n7XJ2t3afgzFeqjY46FGhv github.com/Baidu-AIP/golang-sdk v1.1.1/go.mod h1:bXnGw7xPeKt8aF7UCELKrV6UZ/46spItONK1RQBQj1Y= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= -github.com/FloatTech/AnimeAPI v1.6.1-0.20230724165034-a3cf504fab92 h1:B4IaLEhnXdr7oqszneri6ykdHggL2GvPUueBB5WxYVQ= -github.com/FloatTech/AnimeAPI v1.6.1-0.20230724165034-a3cf504fab92/go.mod h1:fWJ5hx1ggDmLyLldO53Go97zc1JpWnDpsC5qeTOcaVw= +github.com/FloatTech/AnimeAPI v1.6.1-0.20230827144904-758793598579 h1:IMbVe2zNXAgoNaSnNzXq9F3PSgf6tbqbDUjzBwmCOkA= +github.com/FloatTech/AnimeAPI v1.6.1-0.20230827144904-758793598579/go.mod h1:6vYu7bW5gPQsBnXB+I6yk+eJQaaAwusoQ/I/wQMwOAI= github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 h1:/eQoMa6Aj3coF5F7yhzZe1+SzX6SItul7MW8//pl18o= github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI= github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 h1:dPLeoiTVSBlgls+66EB/UJ2e38BaASmBN5nANaycSBU= @@ -58,8 +58,8 @@ github.com/fumiama/bigfft v0.0.0-20211011143303-6e0bfa3c836b h1:Zt3pFQditAdWTHCO github.com/fumiama/bigfft v0.0.0-20211011143303-6e0bfa3c836b/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/fumiama/cron v1.3.0 h1:ZWlwuexF+HQHl3cYytEE5HNwD99q+3vNZF1GrEiXCFo= github.com/fumiama/cron v1.3.0/go.mod h1:bz5Izvgi/xEUI8tlBN8BI2jr9Moo8N4or0KV8xXuPDY= -github.com/fumiama/go-base16384 v1.6.4 h1:rYDRwD/th2cG4U7QLokpzmST1cCxZGXtHmolOUePt5o= -github.com/fumiama/go-base16384 v1.6.4/go.mod h1:OEn+947GV5gsbTAnyuUW/SrfxJYUdYupSIQXOuGOcXM= +github.com/fumiama/go-base16384 v1.7.0 h1:6fep7XPQWxRlh4Hu+KsdH+6+YdUp+w6CwRXtMWSsXCA= +github.com/fumiama/go-base16384 v1.7.0/go.mod h1:OEn+947GV5gsbTAnyuUW/SrfxJYUdYupSIQXOuGOcXM= github.com/fumiama/go-registry v0.2.6 h1:+vEeBUwa1+GC87ujW3Km42fi8O/H7QcpVJWu1iuGNh0= github.com/fumiama/go-registry v0.2.6/go.mod h1:HjYagPZXzR2xCCxaSQerqX7JRzC0yiv2kslDdBiTq/g= github.com/fumiama/go-simple-protobuf v0.1.0 h1:rLzJgNqB6LHNDVMl81yyNt6ZKziWtVfu+ioF0edlEVw= diff --git a/plugin/ai_reply/ai_tts.go b/plugin/ai_reply/ai_tts.go index ae1abd0535..38a75374e2 100644 --- a/plugin/ai_reply/ai_tts.go +++ b/plugin/ai_reply/ai_tts.go @@ -23,10 +23,10 @@ import ( // 数据结构: [4 bits] [4 bits] [8 bits] // [ttscn模式] [百度模式] [tts模式] -// [tts模式]: 0~63 genshin 64 baidu 65 ttscn +// [tts模式]: 0~255 genshin 256 baidu 257 ttscn const ( - lastgsttsindex = 63 + iota + lastgsttsindex = 255 + iota baiduttsindex ttscnttsindex ) @@ -119,8 +119,8 @@ var ttsins = func() map[string]tts.TTS { }() var ttsModes = func() []string { - s := append(genshin.SoundList[:], make([]string, 64-len(genshin.SoundList))...) // 0-63 - s = append(s, extrattsname...) // 64 65 ... + s := append(genshin.SoundList[:], make([]string, lastgsttsindex-len(genshin.SoundList))...) // 0-255 + s = append(s, extrattsname...) // 256 257 ... return s }() diff --git a/plugin/ai_reply/main.go b/plugin/ai_reply/main.go index 40d30d130f..f546214004 100644 --- a/plugin/ai_reply/main.go +++ b/plugin/ai_reply/main.go @@ -123,27 +123,29 @@ func init() { // 插件主体 ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err)) return } - if banner, ok := genshin.TestRecord[param]; ok { - logrus.Debugln("[tts] banner:", banner, "get sound mode...") - // 设置验证 - speaker, err := ttsmd.getSoundMode(ctx) - if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return - } - logrus.Debugln("[tts] got sound mode, speaking...") - rec, err := speaker.Speak(ctx.Event.UserID, func() string { return banner }) - if err != nil { - ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("无法发送测试语音,请重试。")) - return - } - logrus.Debugln("[tts] sending...") - if id := ctx.SendChain(message.Record(rec).Add("cache", 0)); id.ID() == 0 { - ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("无法发送测试语音,请重试。")) - return - } - time.Sleep(time.Second * 2) + banner := genshin.TestRecord[param] + if banner == "" { + banner = genshin.TestRecord["默认"] + } + logrus.Debugln("[tts] banner:", banner, "get sound mode...") + // 设置验证 + speaker, err := ttsmd.getSoundMode(ctx) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + logrus.Debugln("[tts] got sound mode, speaking...") + rec, err := speaker.Speak(ctx.Event.UserID, func() string { return banner }) + if err != nil { + ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("无法发送测试语音,请重试。")) + return + } + logrus.Debugln("[tts] sending...") + if id := ctx.SendChain(message.Record(rec).Add("cache", 0)); id.ID() == 0 { + ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("无法发送测试语音,请重试。")) + return } + time.Sleep(time.Second * 2) ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置成功")) }) diff --git a/plugin/moegoe/main.go b/plugin/moegoe/main.go index 6a4f3e8b35..3fd7d9102d 100644 --- a/plugin/moegoe/main.go +++ b/plugin/moegoe/main.go @@ -22,7 +22,6 @@ const ( var speakers = map[string]uint{ "宁宁": 0, "爱瑠": 1, "芳乃": 2, "茉子": 3, "丛雨": 4, "小春": 5, "七海": 6, "Sua": 0, "Mimiru": 1, "Arin": 2, "Yeonhwa": 3, "Yuhwa": 4, "Seonbae": 5, - "派蒙": 0, "凯亚": 1, "安柏": 2, "丽莎": 3, "琴": 4, "香菱": 5, "枫原万叶": 6, "迪卢克": 7, "温迪": 8, "可莉": 9, "早柚": 10, "托马": 11, "芭芭拉": 12, "优菈": 13, "云堇": 14, "钟离": 15, "魈": 16, "凝光": 17, "雷电将军": 18, "北斗": 19, "甘雨": 20, "七七": 21, "刻晴": 22, "神里绫华": 23, "戴因斯雷布": 24, "雷泽": 25, "神里绫人": 26, "罗莎莉亚": 27, "阿贝多": 28, "八重神子": 29, "宵宫": 30, "荒泷一斗": 31, "九条裟罗": 32, "夜兰": 33, "珊瑚宫心海": 34, "五郎": 35, "散兵": 36, "女士": 37, "达达利亚": 38, "莫娜": 39, "班尼特": 40, "申鹤": 41, "行秋": 42, "烟绯": 43, "久岐忍": 44, "辛焱": 45, "砂糖": 46, "胡桃": 47, "重云": 48, "菲谢尔": 49, "诺艾尔": 50, "迪奥娜": 51, "鹿野院平藏": 52, } var 原 = newapikeystore("./data/tts/o.txt") @@ -33,7 +32,7 @@ func init() { Brief: "日韩中 VITS 模型拟声", Help: "- 让[宁宁|爱瑠|芳乃|茉子|丛雨|小春|七海]说(日语)\n" + "- 让[Sua|Mimiru|Arin|Yeonhwa|Yuhwa|Seonbae]说(韩语)\n" + - "- 让[派蒙|凯亚|安柏|丽莎|琴|香菱|枫原万叶|迪卢克|温迪|可莉|早柚|托马|芭芭拉|优菈|云堇|钟离|魈|凝光|雷电将军|北斗|甘雨|七七|刻晴|神里绫华|雷泽|神里绫人|罗莎莉亚|阿贝多|八重神子|宵宫|荒泷一斗|九条裟罗|夜兰|珊瑚宫心海|五郎|达达利亚|莫娜|班尼特|申鹤|行秋|烟绯|久岐忍|辛焱|砂糖|胡桃|重云|菲谢尔|诺艾尔|迪奥娜|鹿野院平藏]说(中文)", + "- 让[空|荧|派蒙|纳西妲|阿贝多|温迪|枫原万叶|钟离|荒泷一斗|八重神子|艾尔海森|提纳里|迪希雅|卡维|宵宫|莱依拉|赛诺|诺艾尔|托马|凝光|莫娜|北斗|神里绫华|雷电将军|芭芭拉|鹿野院平藏|五郎|迪奥娜|凯亚|安柏|班尼特|琴|柯莱|夜兰|妮露|辛焱|珐露珊|魈|香菱|达达利亚|砂糖|早柚|云堇|刻晴|丽莎|迪卢克|烟绯|重云|珊瑚宫心海|胡桃|可莉|流浪者|久岐忍|神里绫人|甘雨|戴因斯雷布|优菈|菲谢尔|行秋|白术|九条裟罗|雷泽|申鹤|迪娜泽黛|凯瑟琳|多莉|坎蒂丝|萍姥姥|罗莎莉亚|留云借风真君|绮良良|瑶瑶|七七|奥兹|米卡|夏洛蒂|埃洛伊|博士|女士|大慈树王|三月七|娜塔莎|希露瓦|虎克|克拉拉|丹恒|希儿|布洛妮娅|瓦尔特|杰帕德|佩拉|姬子|艾丝妲|白露|星|穹|桑博|伦纳德|停云|罗刹|卡芙卡|彦卿|史瓦罗|螺丝咕姆|阿兰|银狼|素裳|丹枢|黑塔|景元|帕姆|可可利亚|半夏|符玄|公输师傅|奥列格|青雀|大毫|青镞|费斯曼|绿芙蓉|镜流|信使|丽塔|失落迷迭|缭乱星棘|伊甸|伏特加女孩|狂热蓝调|莉莉娅|萝莎莉娅|八重樱|八重霞|卡莲|第六夜想曲|卡萝尔|姬子|极地战刃|布洛妮娅|次生银翼|理之律者|真理之律者|迷城骇兔|希儿|魇夜星渊|黑希儿|帕朵菲莉丝|天元骑英|幽兰黛尔|德丽莎|月下初拥|朔夜观星|暮光骑士|明日香|李素裳|格蕾修|梅比乌斯|渡鸦|人之律者|爱莉希雅|爱衣|天穹游侠|琪亚娜|空之律者|终焉之律者|薪炎之律者|云墨丹心|符华|识之律者|维尔薇|始源之律者|芽衣|雷之律者|苏莎娜|阿波尼亚|陆景和|莫弈|夏彦|左然|标贝]说(中文)", }).ApplySingle(ctxext.DefaultSingle) en.OnRegex("^让(宁宁|爱瑠|芳乃|茉子|丛雨|小春|七海)说([A-Za-z\\s\\d\u3005\u3040-\u30ff\u4e00-\u9fff\uff11-\uff19\uff21-\uff3a\uff41-\uff5a\uff66-\uff9d\\pP]+)$").Limit(ctxext.LimitByGroup).SetBlock(true). Handle(func(ctx *zero.Ctx) { @@ -47,13 +46,13 @@ func init() { id := speakers[ctx.State["regex_matched"].([]string)[1]] ctx.SendChain(message.Record(fmt.Sprintf(krapi, url.QueryEscape(text), id))) }) - en.OnRegex("^让(派蒙|凯亚|安柏|丽莎|琴|香菱|枫原万叶|迪卢克|温迪|可莉|早柚|托马|芭芭拉|优菈|云堇|钟离|魈|凝光|雷电将军|北斗|甘雨|七七|刻晴|神里绫华|雷泽|神里绫人|罗莎莉亚|阿贝多|八重神子|宵宫|荒泷一斗|九条裟罗|夜兰|珊瑚宫心海|五郎|达达利亚|莫娜|班尼特|申鹤|行秋|烟绯|久岐忍|辛焱|砂糖|胡桃|重云|菲谢尔|诺艾尔|迪奥娜|鹿野院平藏)说([\\s\u4e00-\u9fa5\\pP]+)$").Limit(ctxext.LimitByGroup).SetBlock(true). + en.OnRegex("^让(空|荧|派蒙|纳西妲|阿贝多|温迪|枫原万叶|钟离|荒泷一斗|八重神子|艾尔海森|提纳里|迪希雅|卡维|宵宫|莱依拉|赛诺|诺艾尔|托马|凝光|莫娜|北斗|神里绫华|雷电将军|芭芭拉|鹿野院平藏|五郎|迪奥娜|凯亚|安柏|班尼特|琴|柯莱|夜兰|妮露|辛焱|珐露珊|魈|香菱|达达利亚|砂糖|早柚|云堇|刻晴|丽莎|迪卢克|烟绯|重云|珊瑚宫心海|胡桃|可莉|流浪者|久岐忍|神里绫人|甘雨|戴因斯雷布|优菈|菲谢尔|行秋|白术|九条裟罗|雷泽|申鹤|迪娜泽黛|凯瑟琳|多莉|坎蒂丝|萍姥姥|罗莎莉亚|留云借风真君|绮良良|瑶瑶|七七|奥兹|米卡|夏洛蒂|埃洛伊|博士|女士|大慈树王|三月七|娜塔莎|希露瓦|虎克|克拉拉|丹恒|希儿|布洛妮娅|瓦尔特|杰帕德|佩拉|姬子|艾丝妲|白露|星|穹|桑博|伦纳德|停云|罗刹|卡芙卡|彦卿|史瓦罗|螺丝咕姆|阿兰|银狼|素裳|丹枢|黑塔|景元|帕姆|可可利亚|半夏|符玄|公输师傅|奥列格|青雀|大毫|青镞|费斯曼|绿芙蓉|镜流|信使|丽塔|失落迷迭|缭乱星棘|伊甸|伏特加女孩|狂热蓝调|莉莉娅|萝莎莉娅|八重樱|八重霞|卡莲|第六夜想曲|卡萝尔|姬子|极地战刃|布洛妮娅|次生银翼|理之律者|真理之律者|迷城骇兔|希儿|魇夜星渊|黑希儿|帕朵菲莉丝|天元骑英|幽兰黛尔|德丽莎|月下初拥|朔夜观星|暮光骑士|明日香|李素裳|格蕾修|梅比乌斯|渡鸦|人之律者|爱莉希雅|爱衣|天穹游侠|琪亚娜|空之律者|终焉之律者|薪炎之律者|云墨丹心|符华|识之律者|维尔薇|始源之律者|芽衣|雷之律者|苏莎娜|阿波尼亚|陆景和|莫弈|夏彦|左然|标贝)说([\\s\u4e00-\u9fa5\\pP]+)$").Limit(ctxext.LimitByGroup).SetBlock(true). Handle(func(ctx *zero.Ctx) { if 原.k == "" { return } text := ctx.State["regex_matched"].([]string)[2] - id := speakers[ctx.State["regex_matched"].([]string)[1]] - ctx.SendChain(message.Record(fmt.Sprintf(genshin.CNAPI, id, url.QueryEscape(text), url.QueryEscape(原.k)))) + name := ctx.State["regex_matched"].([]string)[1] + ctx.SendChain(message.Record(fmt.Sprintf(genshin.CNAPI, name, url.QueryEscape(text), url.QueryEscape(原.k)))) }) } From e75814e3b386d265323d6da554dd46a792a23743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 27 Aug 2023 23:06:41 +0800 Subject: [PATCH 91/95] fix windows --- kanban/{version<1.21.go => version_less_than_1.21.go} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename kanban/{version<1.21.go => version_less_than_1.21.go} (100%) diff --git a/kanban/version<1.21.go b/kanban/version_less_than_1.21.go similarity index 100% rename from kanban/version<1.21.go rename to kanban/version_less_than_1.21.go From f043fbf0c022fc54d2b48ecff5a5088ea90e379c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 27 Aug 2023 23:30:26 +0800 Subject: [PATCH 92/95] fix: tts speaker --- plugin/ai_reply/ai_tts.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugin/ai_reply/ai_tts.go b/plugin/ai_reply/ai_tts.go index 38a75374e2..eaa7579e72 100644 --- a/plugin/ai_reply/ai_tts.go +++ b/plugin/ai_reply/ai_tts.go @@ -23,10 +23,10 @@ import ( // 数据结构: [4 bits] [4 bits] [8 bits] // [ttscn模式] [百度模式] [tts模式] -// [tts模式]: 0~255 genshin 256 baidu 257 ttscn +// [tts模式]: 0~200 genshin 201 baidu 202 ttscn const ( - lastgsttsindex = 255 + iota + lastgsttsindex = 200 + iota baiduttsindex ttscnttsindex ) @@ -111,7 +111,7 @@ func (r replymode) getReplyMode(ctx *zero.Ctx) aireply.AIReply { } var ttsins = func() map[string]tts.TTS { - m := make(map[string]tts.TTS, 128) + m := make(map[string]tts.TTS, 512) for _, mode := range append(genshin.SoundList[:], extrattsname...) { m[mode] = nil } @@ -119,8 +119,8 @@ var ttsins = func() map[string]tts.TTS { }() var ttsModes = func() []string { - s := append(genshin.SoundList[:], make([]string, lastgsttsindex-len(genshin.SoundList))...) // 0-255 - s = append(s, extrattsname...) // 256 257 ... + s := append(genshin.SoundList[:], make([]string, lastgsttsindex-len(genshin.SoundList))...) // 0-200 + s = append(s, extrattsname...) // 201 202 ... return s }() From 9dade7f3e81c88eaee24d037a283677f248170b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 28 Aug 2023 00:05:09 +0800 Subject: [PATCH 93/95] fix: customize tts download --- go.mod | 2 +- go.sum | 4 ++-- plugin/ai_reply/main.go | 23 +++++++++++++++++++++++ plugin/moegoe/main.go | 16 +++++++++++++++- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index b48785b1ba..ce25d68b1b 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( github.com/Baidu-AIP/golang-sdk v1.1.1 github.com/FloatTech/AnimeAPI v1.6.1-0.20230827144904-758793598579 - github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 + github.com/FloatTech/floatbox v0.0.0-20230827160415-f0865337a824 github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 github.com/FloatTech/imgfactory v0.2.2-0.20230413152719-e101cc3606ef github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9 diff --git a/go.sum b/go.sum index a6ee8c9db9..250e40b334 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/FloatTech/AnimeAPI v1.6.1-0.20230827144904-758793598579 h1:IMbVe2zNXAgoNaSnNzXq9F3PSgf6tbqbDUjzBwmCOkA= github.com/FloatTech/AnimeAPI v1.6.1-0.20230827144904-758793598579/go.mod h1:6vYu7bW5gPQsBnXB+I6yk+eJQaaAwusoQ/I/wQMwOAI= -github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 h1:/eQoMa6Aj3coF5F7yhzZe1+SzX6SItul7MW8//pl18o= -github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI= +github.com/FloatTech/floatbox v0.0.0-20230827160415-f0865337a824 h1:w72fzQg1Y9+VLSRl7iKzaZ6fG3myyMJfpOSajcjaMDM= +github.com/FloatTech/floatbox v0.0.0-20230827160415-f0865337a824/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI= github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 h1:dPLeoiTVSBlgls+66EB/UJ2e38BaASmBN5nANaycSBU= github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08/go.mod h1:uzPzAeT35egARdRuu+1oyjU3CmTwCceoq3Vvje7LpcI= github.com/FloatTech/imgfactory v0.2.2-0.20230413152719-e101cc3606ef h1:CJbK/2FRwPuZpeb6M4sWK2d7oXDnBEGhpkQuQrgc91A= diff --git a/plugin/ai_reply/main.go b/plugin/ai_reply/main.go index f546214004..0778efbcae 100644 --- a/plugin/ai_reply/main.go +++ b/plugin/ai_reply/main.go @@ -2,11 +2,17 @@ package aireply import ( + "crypto/md5" + "encoding/hex" + "os" "regexp" "strconv" + "strings" "time" "github.com/FloatTech/AnimeAPI/tts/genshin" + "github.com/FloatTech/floatbox/binary" + "github.com/FloatTech/floatbox/file" ctrl "github.com/FloatTech/zbpctrl" "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" @@ -75,6 +81,12 @@ func init() { // 插件主体 }) endpre := regexp.MustCompile(`\pP$`) + ttscachedir := ent.DataFolder() + "cache/" + _ = os.RemoveAll(ttscachedir) + err := os.MkdirAll(ttscachedir, 0755) + if err != nil { + panic(err) + } ent.OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser). Handle(func(ctx *zero.Ctx) { msg := ctx.ExtractPlainText() @@ -98,6 +110,17 @@ func init() { // 插件主体 ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(reply)) return } + if strings.HasPrefix(rec, "http") { + b := md5.Sum(binary.StringToBytes(rec)) + fn := hex.EncodeToString(b[:]) + fp := ttscachedir + fn + if file.IsNotExist(fp) { + if file.DownloadTo(rec, fp) != nil { + return + } + } + rec = "file:///" + file.BOTPATH + "/" + fp + } // 发送语音 if id := ctx.SendChain(message.Record(rec)); id.ID() == 0 { ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(reply)) diff --git a/plugin/moegoe/main.go b/plugin/moegoe/main.go index 3fd7d9102d..fe0c544ff9 100644 --- a/plugin/moegoe/main.go +++ b/plugin/moegoe/main.go @@ -2,6 +2,8 @@ package moegoe import ( + "crypto/md5" + "encoding/hex" "fmt" "net/url" @@ -9,6 +11,8 @@ import ( "github.com/wdvxdr1123/ZeroBot/message" "github.com/FloatTech/AnimeAPI/tts/genshin" + "github.com/FloatTech/floatbox/binary" + "github.com/FloatTech/floatbox/file" ctrl "github.com/FloatTech/zbpctrl" "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" @@ -53,6 +57,16 @@ func init() { } text := ctx.State["regex_matched"].([]string)[2] name := ctx.State["regex_matched"].([]string)[1] - ctx.SendChain(message.Record(fmt.Sprintf(genshin.CNAPI, name, url.QueryEscape(text), url.QueryEscape(原.k)))) + rec := fmt.Sprintf(genshin.CNAPI, name, url.QueryEscape(text), url.QueryEscape(原.k)) + b := md5.Sum(binary.StringToBytes(rec)) + fn := hex.EncodeToString(b[:]) + fp := "data/tts/" + fn + if file.IsNotExist(fp) { + if file.DownloadTo(rec, fp) != nil { + return + } + } + rec = "file:///" + file.BOTPATH + "/" + fp + ctx.SendChain(message.Record(rec)) }) } From 30f60bc7e9be34ae3a475c200ed682a1458308e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 28 Aug 2023 00:21:41 +0800 Subject: [PATCH 94/95] fix: gsvits --- go.mod | 2 +- go.sum | 4 ++-- plugin/ai_reply/main.go | 16 ---------------- plugin/moegoe/main.go | 2 +- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/go.mod b/go.mod index ce25d68b1b..3bfb86f922 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/Baidu-AIP/golang-sdk v1.1.1 - github.com/FloatTech/AnimeAPI v1.6.1-0.20230827144904-758793598579 + github.com/FloatTech/AnimeAPI v1.6.1-0.20230827161910-7e6a3d93a0ba github.com/FloatTech/floatbox v0.0.0-20230827160415-f0865337a824 github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 github.com/FloatTech/imgfactory v0.2.2-0.20230413152719-e101cc3606ef diff --git a/go.sum b/go.sum index 250e40b334..0d2831ea7e 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/Baidu-AIP/golang-sdk v1.1.1 h1:RQsAmgDSAkiq22I6n7XJ2t3afgzFeqjY46FGhv github.com/Baidu-AIP/golang-sdk v1.1.1/go.mod h1:bXnGw7xPeKt8aF7UCELKrV6UZ/46spItONK1RQBQj1Y= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= -github.com/FloatTech/AnimeAPI v1.6.1-0.20230827144904-758793598579 h1:IMbVe2zNXAgoNaSnNzXq9F3PSgf6tbqbDUjzBwmCOkA= -github.com/FloatTech/AnimeAPI v1.6.1-0.20230827144904-758793598579/go.mod h1:6vYu7bW5gPQsBnXB+I6yk+eJQaaAwusoQ/I/wQMwOAI= +github.com/FloatTech/AnimeAPI v1.6.1-0.20230827161910-7e6a3d93a0ba h1:0tqYkIc6RK8P3/cGEMSoBBwhiEHKPJC+1F7xlVkikgY= +github.com/FloatTech/AnimeAPI v1.6.1-0.20230827161910-7e6a3d93a0ba/go.mod h1:6vYu7bW5gPQsBnXB+I6yk+eJQaaAwusoQ/I/wQMwOAI= github.com/FloatTech/floatbox v0.0.0-20230827160415-f0865337a824 h1:w72fzQg1Y9+VLSRl7iKzaZ6fG3myyMJfpOSajcjaMDM= github.com/FloatTech/floatbox v0.0.0-20230827160415-f0865337a824/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI= github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 h1:dPLeoiTVSBlgls+66EB/UJ2e38BaASmBN5nANaycSBU= diff --git a/plugin/ai_reply/main.go b/plugin/ai_reply/main.go index 0778efbcae..447ee33469 100644 --- a/plugin/ai_reply/main.go +++ b/plugin/ai_reply/main.go @@ -2,17 +2,12 @@ package aireply import ( - "crypto/md5" - "encoding/hex" "os" "regexp" "strconv" - "strings" "time" "github.com/FloatTech/AnimeAPI/tts/genshin" - "github.com/FloatTech/floatbox/binary" - "github.com/FloatTech/floatbox/file" ctrl "github.com/FloatTech/zbpctrl" "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" @@ -110,17 +105,6 @@ func init() { // 插件主体 ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(reply)) return } - if strings.HasPrefix(rec, "http") { - b := md5.Sum(binary.StringToBytes(rec)) - fn := hex.EncodeToString(b[:]) - fp := ttscachedir + fn - if file.IsNotExist(fp) { - if file.DownloadTo(rec, fp) != nil { - return - } - } - rec = "file:///" + file.BOTPATH + "/" + fp - } // 发送语音 if id := ctx.SendChain(message.Record(rec)); id.ID() == 0 { ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(reply)) diff --git a/plugin/moegoe/main.go b/plugin/moegoe/main.go index fe0c544ff9..68c0f123ed 100644 --- a/plugin/moegoe/main.go +++ b/plugin/moegoe/main.go @@ -57,7 +57,7 @@ func init() { } text := ctx.State["regex_matched"].([]string)[2] name := ctx.State["regex_matched"].([]string)[1] - rec := fmt.Sprintf(genshin.CNAPI, name, url.QueryEscape(text), url.QueryEscape(原.k)) + rec := fmt.Sprintf(genshin.CNAPI, url.QueryEscape(name), url.QueryEscape(text), url.QueryEscape(原.k)) b := md5.Sum(binary.StringToBytes(rec)) fn := hex.EncodeToString(b[:]) fp := "data/tts/" + fn From 9676b26de0dedcc122d7ff6b044e376cff01387b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 28 Aug 2023 16:14:49 +0800 Subject: [PATCH 95/95] =?UTF-8?q?=F0=9F=94=96=20v1.7.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kanban/banner/banner.go | 4 ++-- winres/winres.json | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kanban/banner/banner.go b/kanban/banner/banner.go index ba64dacdec..626de2a768 100644 --- a/kanban/banner/banner.go +++ b/kanban/banner/banner.go @@ -3,13 +3,13 @@ package banner // Version ... -var Version = "v1.7.2" +var Version = "v1.7.3" // Copyright ... var Copyright = "© 2020 - 2023 FloatTech" // Banner ... var Banner = "* OneBot + ZeroBot + Golang\n" + - "* Version " + Version + " - 2023-07-28 13:58:50 +0800 CST\n" + + "* Version " + Version + " - 2023-08-28 16:14:08 +0800 CST\n" + "* Copyright " + Copyright + ". All Rights Reserved.\n" + "* Project: https://github.com/FloatTech/ZeroBot-Plugin" diff --git a/winres/winres.json b/winres/winres.json index aab129f673..0208c2e335 100644 --- a/winres/winres.json +++ b/winres/winres.json @@ -12,7 +12,7 @@ "0409": { "identity": { "name": "ZeroBot-Plugin", - "version": "1.7.2.1831" + "version": "1.7.3.1842" }, "description": "", "minimum-os": "vista", @@ -36,23 +36,23 @@ "#1": { "0000": { "fixed": { - "file_version": "1.7.2.1831", - "product_version": "v1.7.2", - "timestamp": "2023-07-28T13:59:16+08:00" + "file_version": "1.7.3.1842", + "product_version": "v1.7.3", + "timestamp": "2023-08-28T16:14:29+08:00" }, "info": { "0409": { "Comments": "OneBot plugins based on ZeroBot", "CompanyName": "FloatTech", "FileDescription": "https://github.com/FloatTech/ZeroBot-Plugin", - "FileVersion": "1.7.2.1831", + "FileVersion": "1.7.3.1842", "InternalName": "", "LegalCopyright": "© 2020 - 2023 FloatTech. All Rights Reserved.", "LegalTrademarks": "", "OriginalFilename": "ZBP.EXE", "PrivateBuild": "", "ProductName": "ZeroBot-Plugin", - "ProductVersion": "v1.7.2", + "ProductVersion": "v1.7.3", "SpecialBuild": "" } }