From 217fa620048a2a7ce4aa780acfb330a439319e5e Mon Sep 17 00:00:00 2001 From: hutiance Date: Thu, 30 Sep 2021 14:42:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E7=BB=93=E6=9E=9C=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E7=9A=84=E9=95=BF=E5=BA=A6=E4=BD=9C=E4=B8=BA=E9=9A=8F=E6=9C=BA?= =?UTF-8?q?=E6=95=B0=E6=9C=80=E5=A4=A7=E5=80=BC=E3=80=81=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E8=B6=8A=E7=95=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin_image_finder/keyword.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin_image_finder/keyword.go b/plugin_image_finder/keyword.go index cdcb882d..dad70110 100644 --- a/plugin_image_finder/keyword.go +++ b/plugin_image_finder/keyword.go @@ -70,7 +70,7 @@ func init() { keyword := ctx.State["regex_matched"].([]string)[1] soutujson := soutuapi(keyword) pom1 := "https://i.pixiv.cat" - rannum := randint() + rannum := randint(len(soutujson.Illusts)) pom2 := soutujson.Illusts[rannum].ImageUrls.Large[19:] ctx.SendChain(message.Image(pom1 + pom2)) }) @@ -103,7 +103,7 @@ func soutuapi(keyword string) *resultjson { } // randint 从json里的30条数据中随机获取一条返回 -func randint() int { +func randint(len int) int { rand.Seed(time.Now().UnixNano()) - return rand.Intn(30) + return rand.Intn(len) }