Skip to content

Commit

Permalink
分离随机与评价
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Jun 17, 2021
1 parent 445d2e9 commit e323e32
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions randimg/setu_geter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var (
RANDOM_API_URL = "https://api.pixivweb.com/anime18r.php?return=img"
CLASSIFY_RANDOM_API_URL = "http://saki.fumiama.top:62002/dice?url=" + RANDOM_API_URL
VOTE_API_URL = "http://saki.fumiama.top/vote?uuid=零号&img=%s&class=%d"
BLOCK_REQUEST_CLASS = false
BLOCK_REQUEST = false
CACHE_IMG_FILE = "/tmp/setugt"
CACHE_URI = "file:///" + CACHE_IMG_FILE
Expand All @@ -35,15 +36,15 @@ func init() { // 插件主体
}
return
})
// 随机图片
zero.OnFullMatch("随机图片").SetBlock(true).SetPriority(24).
Handle(func(ctx *zero.Ctx) {
if ctx.Event.GroupID > 0 {
if BLOCK_REQUEST {
ctx.Send("请稍后再试哦")
} else {
BLOCK_REQUEST = true
if CLASSIFY_RANDOM_API_URL != "" {
// 有保护的随机图片
if CLASSIFY_RANDOM_API_URL != "" {
zero.OnFullMatch("评价图片").SetBlock(true).SetPriority(24).
Handle(func(ctx *zero.Ctx) {
if ctx.Event.GroupID > 0 {
if BLOCK_REQUEST_CLASS {
ctx.Send("请稍后再试哦")
} else {
BLOCK_REQUEST_CLASS = true
resp, err := http.Get(CLASSIFY_RANDOM_API_URL)
if err != nil {
ctx.Send(fmt.Sprintf("ERROR: %v", err))
Expand Down Expand Up @@ -78,14 +79,13 @@ func init() { // 插件主体
}
}
}
} else {
ctx.Send(msgext.ImageNoCache(RANDOM_API_URL))
BLOCK_REQUEST_CLASS = false
}
BLOCK_REQUEST = false
}
}
return
})
return
})
}

zero.OnFullMatch("不许好").SetBlock(true).SetPriority(24).
Handle(func(ctx *zero.Ctx) {
vote(ctx, 5)
Expand All @@ -94,6 +94,20 @@ func init() { // 插件主体
Handle(func(ctx *zero.Ctx) {
vote(ctx, 6)
})
// 直接随机图片
zero.OnFullMatch("随机图片").SetBlock(true).SetPriority(24).
Handle(func(ctx *zero.Ctx) {
if ctx.Event.GroupID > 0 {
if BLOCK_REQUEST {
ctx.Send("请稍后再试哦")
} else {
BLOCK_REQUEST = true
ctx.Send(msgext.ImageNoCache(RANDOM_API_URL))
BLOCK_REQUEST = false
}
}
return
})
}

func vote(ctx *zero.Ctx, class int) {
Expand Down

0 comments on commit e323e32

Please sign in to comment.