From 85dc4738211da1f5f675c0c720c9dd7267b18830 Mon Sep 17 00:00:00 2001 From: fumiama Date: Wed, 16 Jun 2021 23:40:04 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E7=BE=A4=E7=AE=A1=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=BF=BB=E7=89=8C=EF=BC=8C=E4=BF=AE=E5=A4=8D=E8=AE=A1=E6=97=B6?= =?UTF-8?q?=E5=99=A8=E7=A9=BA=E6=8C=87=E9=92=88=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + go.mod | 2 +- go.sum | 6 ++++-- manager/manager.go | 11 +++++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 652961fe..f70c078d 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ - [x] 在[月份]月[每周or周几]的[小时]点[分钟]分时(用[url])提醒大家[消息] - [x] 取消在[月份]月[日期]日的[小时]点[分钟]分的提醒 - [x] 取消在[月份]月[每周or周几]的[小时]点[分钟]分的提醒 + - [x] 翻牌 - [ ] 同意入群请求 - [ ] 同意好友请求 - [ ] 撤回[@xxx] [xxx] diff --git a/go.mod b/go.mod index a575552e..6e42b857 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.15 require ( github.com/antchfx/htmlquery v1.2.3 - github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210609104507-70d574d5761d + github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210609110318-3c8ef99e3c6c github.com/mattn/go-sqlite3 v1.14.7 github.com/sirupsen/logrus v1.8.1 github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 diff --git a/go.sum b/go.sum index e53396ba..71f02a93 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,5 @@ github.com/Yiwen-Chan/ZeroBot-Plugin v0.0.0-20210606065432-ce326ce97753/go.mod h1:54LOXRTKW0iR0BcKwRSUK46KfLPz7hiLcGMD5GGtL0k= +github.com/Yiwen-Chan/ZeroBot-Plugin v0.0.0-20210606082630-29be1bd5eca6/go.mod h1:UfFAgNpRzp1N9HFmYoUlBJ4nvJOMJC9fMBBHQoaHmf8= github.com/antchfx/htmlquery v1.2.3 h1:sP3NFDneHx2stfNXCKbhHFo8XgNjCACnU/4AO5gWz6M= github.com/antchfx/htmlquery v1.2.3/go.mod h1:B0ABL+F5irhhMWg54ymEZinzMSi0Kt3I2if0BLYa3V0= github.com/antchfx/xpath v1.1.6/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNYhvtNk= @@ -9,8 +10,9 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210606064339-d55b94d71eee/go.mod h1:RN0gCtafWRu2d7lMg9/5UfZDhtsPgdeUovsyuSwl+oQ= -github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210609104507-70d574d5761d h1:p67VMUDiZUhwKjUD6Xsur6FJc96hsikoXI0cm90IGSQ= -github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210609104507-70d574d5761d/go.mod h1:vG2ODqgJYFQobphBnhhmNv3TO+j/ZNYvN6FjUP/zkmA= +github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210606075146-09f50acdb4de/go.mod h1:vG2ODqgJYFQobphBnhhmNv3TO+j/ZNYvN6FjUP/zkmA= +github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210609110318-3c8ef99e3c6c h1:M98iR1Em9EzfaduyhaO/I9Az3CVC0YS3pVbUihoPlM8= +github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210609110318-3c8ef99e3c6c/go.mod h1:/Tv1kgOdp76gvr1VoVmMG2Xu4c76vXngy6P8NFE4pA0= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= diff --git a/manager/manager.go b/manager/manager.go index d71df744..fb7b8171 100644 --- a/manager/manager.go +++ b/manager/manager.go @@ -1,6 +1,8 @@ package manager import ( + "fmt" + "math/rand" "strconv" "strings" @@ -262,6 +264,15 @@ func init() { // 插件主体 } return }) + // 随机点名 + zero.OnFullMatchGroup([]string{"翻牌"}, zero.AdminPermission).SetBlock(true).SetPriority(24). + Handle(func(ctx *zero.Ctx) { + list := ctx.GetGroupMemberList(ctx.Event.GroupID) + path := fmt.Sprint(rand.Intn(int(list.Get("#").Int()))) + ".user_id" + random_user_id := list.Get(path).Int() + ctx.SendChain(message.At(random_user_id), message.Text("就是你啦!")) + return + }) // 入群欢迎 zero.OnNotice().SetBlock(false).SetPriority(40). Handle(func(ctx *zero.Ctx) { From 0d3dbbc8ebb8498c6f80b0fc9022006063fc36cf Mon Sep 17 00:00:00 2001 From: fumiama Date: Thu, 17 Jun 2021 00:01:26 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E7=BF=BB=E7=89=8C=E4=B8=8D@?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manager/manager.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/manager/manager.go b/manager/manager.go index fb7b8171..5bbaa4bc 100644 --- a/manager/manager.go +++ b/manager/manager.go @@ -265,13 +265,14 @@ func init() { // 插件主体 return }) // 随机点名 - zero.OnFullMatchGroup([]string{"翻牌"}, zero.AdminPermission).SetBlock(true).SetPriority(24). + zero.OnFullMatchGroup([]string{"翻牌"}).SetBlock(true).SetPriority(40). Handle(func(ctx *zero.Ctx) { - list := ctx.GetGroupMemberList(ctx.Event.GroupID) - path := fmt.Sprint(rand.Intn(int(list.Get("#").Int()))) + ".user_id" - random_user_id := list.Get(path).Int() - ctx.SendChain(message.At(random_user_id), message.Text("就是你啦!")) - return + if ctx.Event.GroupID > 0 { + list := ctx.GetGroupMemberList(ctx.Event.GroupID) + path := fmt.Sprint(rand.Intn(int(list.Get("#").Int()))) + ".card" + random_card := list.Get(path).String() + ctx.Send(random_card + ",就是你啦!") + } }) // 入群欢迎 zero.OnNotice().SetBlock(false).SetPriority(40). From 4bd2d8f8c5ec4c18fcfaf16e06da490191358a96 Mon Sep 17 00:00:00 2001 From: fumiama Date: Thu, 17 Jun 2021 00:09:11 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=97=A0=E7=BE=A4?= =?UTF-8?q?=E5=90=8D=E7=89=87=E6=97=B6=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manager/manager.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/manager/manager.go b/manager/manager.go index 5bbaa4bc..60ce0579 100644 --- a/manager/manager.go +++ b/manager/manager.go @@ -269,8 +269,11 @@ func init() { // 插件主体 Handle(func(ctx *zero.Ctx) { if ctx.Event.GroupID > 0 { list := ctx.GetGroupMemberList(ctx.Event.GroupID) - path := fmt.Sprint(rand.Intn(int(list.Get("#").Int()))) + ".card" - random_card := list.Get(path).String() + rand_index := fmt.Sprint(rand.Intn(int(list.Get("#").Int()))) + random_card := list.Get(rand_index + ".card").String() + if random_card == "" { + random_card = list.Get(rand_index + ".nickname").String() + } ctx.Send(random_card + ",就是你啦!") } }) From 3d3da9a4955d7e58ce7580daef0ef3f3482ca7cf Mon Sep 17 00:00:00 2001 From: fumiama Date: Thu, 17 Jun 2021 00:21:25 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E9=81=BF=E5=85=8D=E4=BC=AA=E9=9A=8F?= =?UTF-8?q?=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manager/manager.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/manager/manager.go b/manager/manager.go index 60ce0579..4aefdcd5 100644 --- a/manager/manager.go +++ b/manager/manager.go @@ -5,6 +5,7 @@ import ( "math/rand" "strconv" "strings" + "time" timer "github.com/fumiama/ZeroBot-Plugin-Timer" zero "github.com/wdvxdr1123/ZeroBot" @@ -269,6 +270,7 @@ func init() { // 插件主体 Handle(func(ctx *zero.Ctx) { if ctx.Event.GroupID > 0 { list := ctx.GetGroupMemberList(ctx.Event.GroupID) + rand.Seed(time.Now().UnixNano()) rand_index := fmt.Sprint(rand.Intn(int(list.Get("#").Int()))) random_card := list.Get(rand_index + ".card").String() if random_card == "" { From d9221585e1f92123ad73252c0f3dd86822fafb9b Mon Sep 17 00:00:00 2001 From: fumiama Date: Thu, 17 Jun 2021 16:24:00 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E5=B8=A6=E5=88=86=E7=B1=BB=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E7=9A=84=E9=9A=8F=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- randimg/setu_geter.go | 65 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/randimg/setu_geter.go b/randimg/setu_geter.go index 2bf3a960..e36a0889 100644 --- a/randimg/setu_geter.go +++ b/randimg/setu_geter.go @@ -1,14 +1,25 @@ package randimg import ( + "fmt" + "io/ioutil" + "net/http" + "net/url" + "os" + "strconv" "strings" "github.com/Yiwen-Chan/ZeroBot-Plugin/api/msgext" zero "github.com/wdvxdr1123/ZeroBot" ) -var RANDOM_API_URL = "https://api.pixivweb.com/anime18r.php?return=img" -var BLOCK_REQUEST = false +var ( + RANDOM_API_URL = "https://api.pixivweb.com/anime18r.php?return=img" + CLASSIFY_RANDOM_API_URL string = "http://saki.fumiama.top:62002/dice?url=" + RANDOM_API_URL + BLOCK_REQUEST = false + CACHE_IMG_FILE = "/tmp/setugt" + CACHE_URI = "file:///" + CACHE_IMG_FILE +) func init() { // 插件主体 zero.OnRegex(`^设置随机图片网址(.*)$`, zero.SuperUserPermission).SetBlock(true).SetPriority(20). @@ -22,14 +33,50 @@ func init() { // 插件主体 return }) // 随机图片 - zero.OnFullMatchGroup([]string{"随机图片"}).SetBlock(true).SetPriority(24). + zero.OnFullMatch("随机图片").SetBlock(true).SetPriority(24). Handle(func(ctx *zero.Ctx) { - if BLOCK_REQUEST { - ctx.Send("请稍后再试哦") - } else { - BLOCK_REQUEST = true - ctx.Send(msgext.ImageNoCache(RANDOM_API_URL)) - BLOCK_REQUEST = false + if ctx.Event.GroupID > 0 { + if BLOCK_REQUEST { + ctx.Send("请稍后再试哦") + } else { + BLOCK_REQUEST = true + if CLASSIFY_RANDOM_API_URL != "" { + resp, err := http.Get(CLASSIFY_RANDOM_API_URL) + if err != nil { + ctx.Send(fmt.Sprintf("ERROR: %v", err)) + } else { + class, err1 := strconv.Atoi(resp.Header.Get("Class")) + if err1 != nil { + ctx.Send(fmt.Sprintf("ERROR: %v", err1)) + } else { + defer resp.Body.Close() + // 写入文件 + data, _ := ioutil.ReadAll(resp.Body) + f, _ := os.OpenFile(CACHE_IMG_FILE, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644) + defer f.Close() + f.Write(data) + if class > 4 { + ctx.Send("太涩啦,不发了!") + dhash := resp.Header.Get("DHash") + if dhash != "" { + b14, err3 := url.QueryUnescape(dhash) + if err3 == nil { + ctx.Send("给你点提示哦:" + b14) + } + } + } else { + ctx.Send(msgext.ImageNoCache(CACHE_URI)) + if class > 2 { + ctx.Send("我好啦!") + } + } + } + } + } else { + ctx.Send(msgext.ImageNoCache(RANDOM_API_URL)) + } + BLOCK_REQUEST = false + } } return }) From 5d490be15b0193b563627e272f4143c50f2bc7e3 Mon Sep 17 00:00:00 2001 From: fumiama Date: Thu, 17 Jun 2021 19:57:45 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=92=A4=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- randimg/setu_geter.go | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/randimg/setu_geter.go b/randimg/setu_geter.go index e36a0889..45e783b2 100644 --- a/randimg/setu_geter.go +++ b/randimg/setu_geter.go @@ -8,17 +8,22 @@ import ( "os" "strconv" "strings" + "time" "github.com/Yiwen-Chan/ZeroBot-Plugin/api/msgext" zero "github.com/wdvxdr1123/ZeroBot" ) var ( - RANDOM_API_URL = "https://api.pixivweb.com/anime18r.php?return=img" - CLASSIFY_RANDOM_API_URL string = "http://saki.fumiama.top:62002/dice?url=" + RANDOM_API_URL - BLOCK_REQUEST = false - CACHE_IMG_FILE = "/tmp/setugt" - CACHE_URI = "file:///" + CACHE_IMG_FILE + RANDOM_API_URL = "https://api.pixivweb.com/anime18r.php?return=img" + CLASSIFY_RANDOM_API_URL = "http://saki.fumiama.top:62002/dice?url=" + RANDOM_API_URL + VOTE_API_URL = "http://saki.fumiama.top/vote?uuid=零号&img=%s&class=%d" + BLOCK_REQUEST = false + CACHE_IMG_FILE = "/tmp/setugt" + CACHE_URI = "file:///" + CACHE_IMG_FILE + last_message_id int64 + last_dhash string + last_visit = 0 ) func init() { // 插件主体 @@ -36,9 +41,10 @@ func init() { // 插件主体 zero.OnFullMatch("随机图片").SetBlock(true).SetPriority(24). Handle(func(ctx *zero.Ctx) { if ctx.Event.GroupID > 0 { - if BLOCK_REQUEST { + if BLOCK_REQUEST && time.Now().Unix()-last_message_id < 30 { ctx.Send("请稍后再试哦") } else { + last_message_id = time.Now().Unix() BLOCK_REQUEST = true if CLASSIFY_RANDOM_API_URL != "" { resp, err := http.Get(CLASSIFY_RANDOM_API_URL) @@ -46,6 +52,7 @@ func init() { // 插件主体 ctx.Send(fmt.Sprintf("ERROR: %v", err)) } else { class, err1 := strconv.Atoi(resp.Header.Get("Class")) + dhash := resp.Header.Get("DHash") if err1 != nil { ctx.Send(fmt.Sprintf("ERROR: %v", err1)) } else { @@ -57,7 +64,6 @@ func init() { // 插件主体 f.Write(data) if class > 4 { ctx.Send("太涩啦,不发了!") - dhash := resp.Header.Get("DHash") if dhash != "" { b14, err3 := url.QueryUnescape(dhash) if err3 == nil { @@ -65,7 +71,8 @@ func init() { // 插件主体 } } } else { - ctx.Send(msgext.ImageNoCache(CACHE_URI)) + last_message_id = ctx.Send(msgext.ImageNoCache(CACHE_URI)) + last_dhash = dhash if class > 2 { ctx.Send("我好啦!") } @@ -80,4 +87,24 @@ func init() { // 插件主体 } return }) + zero.OnFullMatch("不许好").SetBlock(true).SetPriority(24). + Handle(func(ctx *zero.Ctx) { + if last_message_id != 0 { + ctx.DeleteMessage(last_message_id) + last_message_id = 0 + vote(5) + } + }) + zero.OnFullMatch("太涩了").SetBlock(true).SetPriority(24). + Handle(func(ctx *zero.Ctx) { + if last_message_id != 0 { + ctx.DeleteMessage(last_message_id) + last_message_id = 0 + vote(6) + } + }) +} + +func vote(class int) { + http.Get(fmt.Sprintf(VOTE_API_URL, last_dhash, class)) } From cda7bec982069422584971eca9b10ef248c8f938 Mon Sep 17 00:00:00 2001 From: fumiama Date: Thu, 17 Jun 2021 20:05:38 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- randimg/setu_geter.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/randimg/setu_geter.go b/randimg/setu_geter.go index 45e783b2..1d65840c 100644 --- a/randimg/setu_geter.go +++ b/randimg/setu_geter.go @@ -24,6 +24,7 @@ var ( last_message_id int64 last_dhash string last_visit = 0 + last_group_id int64 ) func init() { // 插件主体 @@ -73,6 +74,7 @@ func init() { // 插件主体 } else { last_message_id = ctx.Send(msgext.ImageNoCache(CACHE_URI)) last_dhash = dhash + last_group_id = ctx.Event.GroupID if class > 2 { ctx.Send("我好啦!") } @@ -89,7 +91,7 @@ func init() { // 插件主体 }) zero.OnFullMatch("不许好").SetBlock(true).SetPriority(24). Handle(func(ctx *zero.Ctx) { - if last_message_id != 0 { + if last_message_id != 0 && last_group_id == ctx.Event.GroupID { ctx.DeleteMessage(last_message_id) last_message_id = 0 vote(5) @@ -97,7 +99,7 @@ func init() { // 插件主体 }) zero.OnFullMatch("太涩了").SetBlock(true).SetPriority(24). Handle(func(ctx *zero.Ctx) { - if last_message_id != 0 { + if last_message_id != 0 && last_group_id == ctx.Event.GroupID { ctx.DeleteMessage(last_message_id) last_message_id = 0 vote(6) From 445d2e96ce9175112f8d0eb180270d1ae190cbbc Mon Sep 17 00:00:00 2001 From: fumiama Date: Thu, 17 Jun 2021 21:15:38 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E9=80=82=E9=85=8D=E5=A4=9A=E7=BE=A4?= =?UTF-8?q?=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- randimg/setu_geter.go | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/randimg/setu_geter.go b/randimg/setu_geter.go index 1d65840c..5af8aa13 100644 --- a/randimg/setu_geter.go +++ b/randimg/setu_geter.go @@ -8,7 +8,6 @@ import ( "os" "strconv" "strings" - "time" "github.com/Yiwen-Chan/ZeroBot-Plugin/api/msgext" zero "github.com/wdvxdr1123/ZeroBot" @@ -21,10 +20,8 @@ var ( BLOCK_REQUEST = false CACHE_IMG_FILE = "/tmp/setugt" CACHE_URI = "file:///" + CACHE_IMG_FILE - last_message_id int64 - last_dhash string - last_visit = 0 - last_group_id int64 + msgofgrp = make(map[int64]int64) + dhashofmsg = make(map[int64]string) ) func init() { // 插件主体 @@ -42,10 +39,9 @@ func init() { // 插件主体 zero.OnFullMatch("随机图片").SetBlock(true).SetPriority(24). Handle(func(ctx *zero.Ctx) { if ctx.Event.GroupID > 0 { - if BLOCK_REQUEST && time.Now().Unix()-last_message_id < 30 { + if BLOCK_REQUEST { ctx.Send("请稍后再试哦") } else { - last_message_id = time.Now().Unix() BLOCK_REQUEST = true if CLASSIFY_RANDOM_API_URL != "" { resp, err := http.Get(CLASSIFY_RANDOM_API_URL) @@ -72,9 +68,10 @@ func init() { // 插件主体 } } } else { - last_message_id = ctx.Send(msgext.ImageNoCache(CACHE_URI)) - last_dhash = dhash - last_group_id = ctx.Event.GroupID + last_message_id := ctx.Send(msgext.ImageNoCache(CACHE_URI)) + last_group_id := ctx.Event.GroupID + msgofgrp[last_group_id] = last_message_id + dhashofmsg[last_message_id] = dhash if class > 2 { ctx.Send("我好啦!") } @@ -91,22 +88,23 @@ func init() { // 插件主体 }) zero.OnFullMatch("不许好").SetBlock(true).SetPriority(24). Handle(func(ctx *zero.Ctx) { - if last_message_id != 0 && last_group_id == ctx.Event.GroupID { - ctx.DeleteMessage(last_message_id) - last_message_id = 0 - vote(5) - } + vote(ctx, 5) }) zero.OnFullMatch("太涩了").SetBlock(true).SetPriority(24). Handle(func(ctx *zero.Ctx) { - if last_message_id != 0 && last_group_id == ctx.Event.GroupID { - ctx.DeleteMessage(last_message_id) - last_message_id = 0 - vote(6) - } + vote(ctx, 6) }) } -func vote(class int) { - http.Get(fmt.Sprintf(VOTE_API_URL, last_dhash, class)) +func vote(ctx *zero.Ctx, class int) { + msg, ok := msgofgrp[ctx.Event.GroupID] + if ok { + ctx.DeleteMessage(msg) + delete(msgofgrp, ctx.Event.GroupID) + dhash, ok2 := dhashofmsg[msg] + if ok2 { + http.Get(fmt.Sprintf(VOTE_API_URL, dhash, class)) + delete(dhashofmsg, msg) + } + } } From e323e32f646249544603eda0494d881d416ac920 Mon Sep 17 00:00:00 2001 From: fumiama Date: Thu, 17 Jun 2021 22:22:11 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E5=88=86=E7=A6=BB=E9=9A=8F=E6=9C=BA?= =?UTF-8?q?=E4=B8=8E=E8=AF=84=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- randimg/setu_geter.go | 44 ++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/randimg/setu_geter.go b/randimg/setu_geter.go index 5af8aa13..4674efe6 100644 --- a/randimg/setu_geter.go +++ b/randimg/setu_geter.go @@ -17,6 +17,7 @@ var ( RANDOM_API_URL = "https://api.pixivweb.com/anime18r.php?return=img" CLASSIFY_RANDOM_API_URL = "http://saki.fumiama.top:62002/dice?url=" + RANDOM_API_URL VOTE_API_URL = "http://saki.fumiama.top/vote?uuid=零号&img=%s&class=%d" + BLOCK_REQUEST_CLASS = false BLOCK_REQUEST = false CACHE_IMG_FILE = "/tmp/setugt" CACHE_URI = "file:///" + CACHE_IMG_FILE @@ -35,15 +36,15 @@ func init() { // 插件主体 } return }) - // 随机图片 - zero.OnFullMatch("随机图片").SetBlock(true).SetPriority(24). - Handle(func(ctx *zero.Ctx) { - if ctx.Event.GroupID > 0 { - if BLOCK_REQUEST { - ctx.Send("请稍后再试哦") - } else { - BLOCK_REQUEST = true - if CLASSIFY_RANDOM_API_URL != "" { + // 有保护的随机图片 + if CLASSIFY_RANDOM_API_URL != "" { + zero.OnFullMatch("评价图片").SetBlock(true).SetPriority(24). + Handle(func(ctx *zero.Ctx) { + if ctx.Event.GroupID > 0 { + if BLOCK_REQUEST_CLASS { + ctx.Send("请稍后再试哦") + } else { + BLOCK_REQUEST_CLASS = true resp, err := http.Get(CLASSIFY_RANDOM_API_URL) if err != nil { ctx.Send(fmt.Sprintf("ERROR: %v", err)) @@ -78,14 +79,13 @@ func init() { // 插件主体 } } } - } else { - ctx.Send(msgext.ImageNoCache(RANDOM_API_URL)) + BLOCK_REQUEST_CLASS = false } - BLOCK_REQUEST = false } - } - return - }) + return + }) + } + zero.OnFullMatch("不许好").SetBlock(true).SetPriority(24). Handle(func(ctx *zero.Ctx) { vote(ctx, 5) @@ -94,6 +94,20 @@ func init() { // 插件主体 Handle(func(ctx *zero.Ctx) { vote(ctx, 6) }) + // 直接随机图片 + zero.OnFullMatch("随机图片").SetBlock(true).SetPriority(24). + Handle(func(ctx *zero.Ctx) { + if ctx.Event.GroupID > 0 { + if BLOCK_REQUEST { + ctx.Send("请稍后再试哦") + } else { + BLOCK_REQUEST = true + ctx.Send(msgext.ImageNoCache(RANDOM_API_URL)) + BLOCK_REQUEST = false + } + } + return + }) } func vote(ctx *zero.Ctx, class int) { From 2a2ccc67fe5f67a4a03e0c3934e184df36de9c3c Mon Sep 17 00:00:00 2001 From: fumiama Date: Thu, 17 Jun 2021 22:26:00 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E8=AF=84=E4=BB=B7=E5=9B=BE=E7=89=87=E7=BD=91=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- randimg/setu_geter.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/randimg/setu_geter.go b/randimg/setu_geter.go index 4674efe6..3d35f9e6 100644 --- a/randimg/setu_geter.go +++ b/randimg/setu_geter.go @@ -36,6 +36,16 @@ func init() { // 插件主体 } return }) + zero.OnRegex(`^设置评价图片网址(.*)$`, zero.SuperUserPermission).SetBlock(true).SetPriority(20). + Handle(func(ctx *zero.Ctx) { + url := ctx.State["regex_matched"].([]string)[1] + if !strings.HasPrefix(url, "http") { + ctx.Send("URL非法!") + } else { + CLASSIFY_RANDOM_API_URL = url + RANDOM_API_URL + } + return + }) // 有保护的随机图片 if CLASSIFY_RANDOM_API_URL != "" { zero.OnFullMatch("评价图片").SetBlock(true).SetPriority(24). From c1a9236d1d4315fb1ba15bf95fd7cbaf14a0a201 Mon Sep 17 00:00:00 2001 From: fumiama Date: Thu, 17 Jun 2021 22:39:40 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E8=AF=84=E4=BB=B7=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- randimg/setu_geter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/randimg/setu_geter.go b/randimg/setu_geter.go index 3d35f9e6..d31dd0b5 100644 --- a/randimg/setu_geter.go +++ b/randimg/setu_geter.go @@ -15,7 +15,7 @@ import ( var ( RANDOM_API_URL = "https://api.pixivweb.com/anime18r.php?return=img" - CLASSIFY_RANDOM_API_URL = "http://saki.fumiama.top:62002/dice?url=" + RANDOM_API_URL + CLASSIFY_RANDOM_API_URL = "http://127.0.0.1:62002/dice?url=" + RANDOM_API_URL VOTE_API_URL = "http://saki.fumiama.top/vote?uuid=零号&img=%s&class=%d" BLOCK_REQUEST_CLASS = false BLOCK_REQUEST = false From d3b1bcb3d5d215591136957953575e76da4ec88d Mon Sep 17 00:00:00 2001 From: fumiama Date: Thu, 17 Jun 2021 22:42:54 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E6=B7=BB=E5=8A=A0arm=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build_arm.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 build_arm.sh diff --git a/build_arm.sh b/build_arm.sh new file mode 100755 index 00000000..7d0bff70 --- /dev/null +++ b/build_arm.sh @@ -0,0 +1,5 @@ +go version +go env -w GOPROXY=https://goproxy.cn,direct +go env -w GO111MODULE=auto +go mod tidy +GOOS=linux GOARCH=arm GOARM=6 CGO_ENABLED=0 CC=${CCBIN} CXX=${CXXBIN} go build -ldflags "-s -w" -o zerobot \ No newline at end of file From 164f441b299f48efb86ceed97e1f6c08d9bfd22c Mon Sep 17 00:00:00 2001 From: fumiama Date: Thu, 17 Jun 2021 23:27:27 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E6=99=AE=E9=80=9A=E9=9A=8F=E6=9C=BA?= =?UTF-8?q?=E5=9B=BE=E4=B9=9F=E5=8F=AF=E6=92=A4=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- randimg/setu_geter.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/randimg/setu_geter.go b/randimg/setu_geter.go index d31dd0b5..df40f02e 100644 --- a/randimg/setu_geter.go +++ b/randimg/setu_geter.go @@ -112,7 +112,9 @@ func init() { // 插件主体 ctx.Send("请稍后再试哦") } else { BLOCK_REQUEST = true - ctx.Send(msgext.ImageNoCache(RANDOM_API_URL)) + last_message_id := ctx.Send(msgext.ImageNoCache(RANDOM_API_URL)) + last_group_id := ctx.Event.GroupID + msgofgrp[last_group_id] = last_message_id BLOCK_REQUEST = false } } From d2eea329856d8ff586265ae4b5b82fcf58d8b985 Mon Sep 17 00:00:00 2001 From: fumiama Date: Thu, 17 Jun 2021 23:28:30 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f70c078d..047ce6bf 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ - 简易随机图片(调用url) `import _ "github.com/Yiwen-Chan/ZeroBot-Plugin/randimg"` - [x] 随机图片 - [x] 设置随机图片网址[url] + - [x] 太涩了(撤回最近发的图) - 点歌 `import _ "github.com/Yiwen-Chan/ZeroBot-Plugin/music"` - [x] 点歌[xxx] - [x] 网易点歌[xxx]