From 04593e2147d55ff566c17150aaa9d8678f787e88 Mon Sep 17 00:00:00 2001 From: Yiwen-Chan Date: Tue, 29 Jun 2021 17:36:12 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E4=B8=8A=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin_lolicon/lolicon.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin_lolicon/lolicon.go b/plugin_lolicon/lolicon.go index 7eb8b638..ad3d9ef7 100644 --- a/plugin_lolicon/lolicon.go +++ b/plugin_lolicon/lolicon.go @@ -27,22 +27,22 @@ func init() { Handle(func(ctx *zero.Ctx) { go func() { min := func(a, b int) int { - if a > b { + if a < b { return a } else { return b } } - for i := 0; i < min(10-cap(QUEUE), 2); i++ { + for i := 0; i < min(cap(QUEUE)-len(QUEUE), 2); i++ { resp, err := http.Get(API) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) } - defer resp.Body.Close() if resp.StatusCode != http.StatusOK { ctx.SendChain(message.Text("ERROR: code ", resp.StatusCode)) } data, _ := ioutil.ReadAll(resp.Body) + resp.Body.Close() json := gjson.ParseBytes(data) if e := json.Get("error").Str; e != "" { ctx.SendChain(message.Text("ERROR: ", e))