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