Skip to content

Commit

Permalink
上一个随机图片未完成前拒绝请求
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Jun 4, 2021
1 parent 08b2102 commit 352fd2e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
11 changes: 9 additions & 2 deletions randimg/setu_geter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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
})
}

0 comments on commit 352fd2e

Please sign in to comment.