From e323e32f646249544603eda0494d881d416ac920 Mon Sep 17 00:00:00 2001 From: fumiama Date: Thu, 17 Jun 2021 22:22:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=A6=BB=E9=9A=8F=E6=9C=BA=E4=B8=8E?= =?UTF-8?q?=E8=AF=84=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- randimg/setu_geter.go | 44 ++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/randimg/setu_geter.go b/randimg/setu_geter.go index 5af8aa13..4674efe6 100644 --- a/randimg/setu_geter.go +++ b/randimg/setu_geter.go @@ -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 @@ -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)) @@ -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) @@ -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) {