mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 05:30:07 +08:00
上一个随机图片未完成前拒绝请求
This commit is contained in:
parent
08b2102528
commit
352fd2eb79
@ -4,7 +4,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/Yiwen-Chan/ZeroBot-Plugin/msgext"
|
||||
"github.com/Yiwen-Chan/ZeroBot-Plugin/api/msgext"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
@ -3,11 +3,12 @@ package randimg
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/Yiwen-Chan/ZeroBot-Plugin/msgext"
|
||||
"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
|
||||
|
||||
func init() { // 插件主体
|
||||
zero.OnRegex(`^设置随机图片网址(.*)$`, zero.SuperUserPermission).SetBlock(true).SetPriority(20).
|
||||
@ -23,7 +24,13 @@ func init() { // 插件主体
|
||||
// 随机图片
|
||||
zero.OnFullMatchGroup([]string{"随机图片"}).SetBlock(true).SetPriority(24).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.Send(msgext.ImageNoCache(RANDOM_API_URL))
|
||||
if BLOCK_REQUEST {
|
||||
ctx.Send("请稍后再试哦")
|
||||
} else {
|
||||
BLOCK_REQUEST = true
|
||||
ctx.Send(msgext.ImageNoCache(RANDOM_API_URL))
|
||||
BLOCK_REQUEST = false
|
||||
}
|
||||
return
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user