mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-28 04:41:20 +08:00
fix: acgimage block
This commit is contained in:
parent
b945338a8d
commit
121403231a
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module github.com/FloatTech/ZeroBot-Plugin
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/FloatTech/AnimeAPI v1.3.0-beta8.0.20220215053620-c7b20c8033a0
|
||||
github.com/FloatTech/AnimeAPI v1.3.0-beta8.0.20220215081026-d6f95aaf77df
|
||||
github.com/FloatTech/sqlite v0.1.0
|
||||
github.com/FloatTech/zbputils v1.3.0-beta8.0.20220215053220-192931cec3a8
|
||||
github.com/antchfx/htmlquery v1.2.4
|
||||
|
||||
4
go.sum
4
go.sum
@ -1,5 +1,5 @@
|
||||
github.com/FloatTech/AnimeAPI v1.3.0-beta8.0.20220215053620-c7b20c8033a0 h1:0w5Dx2TZCAPotWjGXlkrFI5INhMLcttgDfoUfH3S24M=
|
||||
github.com/FloatTech/AnimeAPI v1.3.0-beta8.0.20220215053620-c7b20c8033a0/go.mod h1:Kl18EWeAbw1xxqq/2KgS1pT3PmJv+9vWBeD3TNdIDvE=
|
||||
github.com/FloatTech/AnimeAPI v1.3.0-beta8.0.20220215081026-d6f95aaf77df h1:HLbcSbk4ReH+f6C+jGur32CP3NqWqGDCUAvcITOFSXU=
|
||||
github.com/FloatTech/AnimeAPI v1.3.0-beta8.0.20220215081026-d6f95aaf77df/go.mod h1:Kl18EWeAbw1xxqq/2KgS1pT3PmJv+9vWBeD3TNdIDvE=
|
||||
github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ=
|
||||
github.com/FloatTech/sqlite v0.1.0 h1:Geh6Z+DWZXmyXVOhM0U2oXT7b1Ob6sQtuyjInk+MCUk=
|
||||
github.com/FloatTech/sqlite v0.1.0/go.mod h1:XS0oeSqtH6lFzpPRiDE9fV6+zMcuUF5/6o+tQVO1QZE=
|
||||
|
||||
@ -5,15 +5,16 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/classify"
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/pool"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/classify"
|
||||
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/pool"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -52,8 +53,16 @@ func init() { // 插件主体
|
||||
// 有保护的随机图片
|
||||
engine.OnFullMatch("随机图片", zero.OnlyGroup).Limit(ctxext.LimitByUser).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
class, dhash, comment, _ := classify.Classify(randapi, true)
|
||||
replyClass(ctx, class, dhash, comment, false)
|
||||
class, dhash, _, err := classify.Classify(randapi, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
err = reply(ctx, class, dhash, classify.Comments[class])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
})
|
||||
// 直接随机图片,无r18保护,后果自负。如果出r18图可尽快通过发送"太涩了"撤回
|
||||
engine.OnFullMatch("直接随机", ctxext.UserOrGrpAdmin).SetBlock(true).
|
||||
@ -85,11 +94,13 @@ func init() { // 插件主体
|
||||
engine.OnKeywordGroup([]string{"评价图片"}, zero.OnlyGroup, ctxext.MustProvidePicture).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||
for _, url := range ctx.State["image_url"].([]string) {
|
||||
class, dhash, comment, _ := classify.Classify(url, true)
|
||||
replyClass(ctx, class, dhash, comment, true)
|
||||
break
|
||||
url := ctx.State["image_url"].([]string)[0]
|
||||
class, _, _, err := classify.Classify(url, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(classify.Comments[class]))
|
||||
})
|
||||
engine.OnRegex(`^给你点提示哦:(.*)$`, zero.OnlyPrivate).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
@ -114,15 +125,10 @@ func setLastMsg(id int64, msg message.MessageID) {
|
||||
msgof[id] = msg
|
||||
}
|
||||
|
||||
func replyClass(ctx *zero.Ctx, class int, dhash string, comment string, isupload bool) {
|
||||
if isupload {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(comment))
|
||||
return
|
||||
}
|
||||
|
||||
func reply(ctx *zero.Ctx, class int, dhash string, comment string) error {
|
||||
b14, err := url.QueryUnescape(dhash)
|
||||
if err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
var u string
|
||||
@ -150,4 +156,5 @@ func replyClass(ctx *zero.Ctx, class int, dhash string, comment string, isupload
|
||||
if err == nil && !hassent {
|
||||
send(message.Message{message.Image(m.String())})
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user