mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-23 09:40:04 +08:00
✨ 私聊获取图片
This commit is contained in:
parent
a094d1c2ba
commit
1d2960a51c
@ -31,46 +31,43 @@ var (
|
|||||||
func init() { // 插件主体
|
func init() { // 插件主体
|
||||||
// 初始化 classify
|
// 初始化 classify
|
||||||
classify.Init(datapath)
|
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) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
url := ctx.State["regex_matched"].([]string)[1]
|
url := ctx.State["regex_matched"].([]string)[1]
|
||||||
if !strings.HasPrefix(url, "http") {
|
if !strings.HasPrefix(url, "http") {
|
||||||
ctx.Send("URL非法!")
|
ctx.Send("URL非法!")
|
||||||
} else {
|
} else {
|
||||||
randapi = url
|
randapi = url
|
||||||
|
ctx.Send("设置好啦")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 有保护的随机图片
|
// 有保护的随机图片
|
||||||
zero.OnFullMatch("随机图片").SetBlock(true).SetPriority(24).
|
zero.OnFullMatch("随机图片", zero.OnlyGroup).SetBlock(true).SetPriority(24).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if ctx.Event.GroupID > 0 {
|
if classify.CanVisit(5) {
|
||||||
if classify.CanVisit(5) {
|
go func() {
|
||||||
go func() {
|
class, lastvisit, dhash, comment := classify.Classify(randapi, false)
|
||||||
class, lastvisit, dhash, comment := classify.Classify(randapi, false)
|
replyClass(ctx, dhash, class, false, lastvisit, comment)
|
||||||
replyClass(ctx, dhash, class, false, lastvisit, comment)
|
}()
|
||||||
}()
|
} else {
|
||||||
} else {
|
ctx.Send("你太快啦!")
|
||||||
ctx.Send("你太快啦!")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 直接随机图片,无r18保护,后果自负。如果出r18图可尽快通过发送"太涩了"撤回
|
// 直接随机图片,无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) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if ctx.Event.GroupID > 0 {
|
if block {
|
||||||
if block {
|
ctx.Send("请稍后再试哦")
|
||||||
ctx.Send("请稍后再试哦")
|
} else if randapi != "" {
|
||||||
} else if randapi != "" {
|
block = true
|
||||||
block = true
|
var url string
|
||||||
var url string
|
if randapi[0] == '&' {
|
||||||
if randapi[0] == '&' {
|
url = lolipxy
|
||||||
url = lolipxy
|
} else {
|
||||||
} else {
|
url = randapi
|
||||||
url = randapi
|
|
||||||
}
|
|
||||||
setLastMsg(ctx.Event.GroupID, ctx.Send(message.Image(url).Add("cache", "0")))
|
|
||||||
block = false
|
|
||||||
}
|
}
|
||||||
|
setLastMsg(ctx.Event.GroupID, ctx.Send(message.Image(url).Add("cache", "0")))
|
||||||
|
block = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 撤回最后的直接随机图片
|
// 撤回最后的直接随机图片
|
||||||
@ -79,16 +76,14 @@ func init() { // 插件主体
|
|||||||
go cancel(ctx)
|
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) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if ctx.Event.GroupID > 0 {
|
ctx.Send("少女祈祷中...")
|
||||||
ctx.Send("少女祈祷中...")
|
for _, url := range ctx.State["image_url"].([]string) {
|
||||||
for _, url := range ctx.State["image_url"].([]string) {
|
go func(target string) {
|
||||||
go func(target string) {
|
class, lastvisit, dhash, comment := classify.Classify(target, true)
|
||||||
class, lastvisit, dhash, comment := classify.Classify(target, true)
|
replyClass(ctx, dhash, class, true, lastvisit, comment)
|
||||||
replyClass(ctx, dhash, class, true, lastvisit, comment)
|
}(url)
|
||||||
}(url)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
zero.OnRegex(`^给你点提示哦:(.*)$`, zero.OnlyPrivate).SetBlock(true).SetPriority(20).
|
zero.OnRegex(`^给你点提示哦:(.*)$`, zero.OnlyPrivate).SetBlock(true).SetPriority(20).
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user