私聊获取图片

This commit is contained in:
fumiama 2021-08-07 14:20:13 +08:00
parent a094d1c2ba
commit 1d2960a51c

View File

@ -31,19 +31,19 @@ var (
func init() { // 插件主体
// 初始化 classify
classify.Init(datapath)
zero.OnRegex(`^设置随机图片网址(.*)$`, zero.SuperUserPermission).SetBlock(true).SetPriority(20).
zero.OnRegex(`^设置随机图片网址(.*)$`, zero.OnlyPrivate, 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 {
randapi = url
ctx.Send("设置好啦")
}
})
// 有保护的随机图片
zero.OnFullMatch("随机图片").SetBlock(true).SetPriority(24).
zero.OnFullMatch("随机图片", zero.OnlyGroup).SetBlock(true).SetPriority(24).
Handle(func(ctx *zero.Ctx) {
if ctx.Event.GroupID > 0 {
if classify.CanVisit(5) {
go func() {
class, lastvisit, dhash, comment := classify.Classify(randapi, false)
@ -52,12 +52,10 @@ func init() { // 插件主体
} else {
ctx.Send("你太快啦!")
}
}
})
// 直接随机图片无r18保护后果自负。如果出r18图可尽快通过发送"太涩了"撤回
zero.OnFullMatch("直接随机", zero.AdminPermission).SetBlock(true).SetPriority(24).
zero.OnFullMatch("直接随机", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(24).
Handle(func(ctx *zero.Ctx) {
if ctx.Event.GroupID > 0 {
if block {
ctx.Send("请稍后再试哦")
} else if randapi != "" {
@ -71,7 +69,6 @@ func init() { // 插件主体
setLastMsg(ctx.Event.GroupID, ctx.Send(message.Image(url).Add("cache", "0")))
block = false
}
}
})
// 撤回最后的直接随机图片
zero.OnFullMatch("太涩了").SetBlock(true).SetPriority(24).
@ -79,9 +76,8 @@ func init() { // 插件主体
go cancel(ctx)
})
// 上传一张图进行评价
zero.OnKeywordGroup([]string{"评价图片"}, picture.CmdMatch, picture.MustGiven).SetBlock(true).SetPriority(24).
zero.OnKeywordGroup([]string{"评价图片"}, zero.OnlyGroup, picture.CmdMatch, picture.MustGiven).SetBlock(true).SetPriority(24).
Handle(func(ctx *zero.Ctx) {
if ctx.Event.GroupID > 0 {
ctx.Send("少女祈祷中...")
for _, url := range ctx.State["image_url"].([]string) {
go func(target string) {
@ -89,7 +85,6 @@ func init() { // 插件主体
replyClass(ctx, dhash, class, true, lastvisit, comment)
}(url)
}
}
})
zero.OnRegex(`^给你点提示哦:(.*)$`, zero.OnlyPrivate).SetBlock(true).SetPriority(20).
Handle(func(ctx *zero.Ctx) {