From 76db0b6fb4dce5cb594650427c0fe86e95d6d299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Thu, 7 Oct 2021 12:21:20 +0800 Subject: [PATCH] Update keyword.go --- 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 dad70110..a1e4d78d 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(len(soutujson.Illusts)) + rannum := randintn(len(soutujson.Illusts)) pom2 := soutujson.Illusts[rannum].ImageUrls.Large[19:] ctx.SendChain(message.Image(pom1 + pom2)) }) @@ -102,8 +102,8 @@ func soutuapi(keyword string) *resultjson { return result } -// randint 从json里的30条数据中随机获取一条返回 -func randint(len int) int { +// randintn 从json里的30条数据中随机获取一条返回 +func randintn(len int) int { rand.Seed(time.Now().UnixNano()) return rand.Intn(len) }