mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-12 02:00:24 +00:00
💩👌 make lint happy
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package plugin_image_finder
|
||||
package imagefinder
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
type AutoGenerated struct {
|
||||
type resultjson struct {
|
||||
Illusts []struct {
|
||||
ID int `json:"id"`
|
||||
Title string `json:"title"`
|
||||
@@ -63,7 +63,7 @@ func init() {
|
||||
keyword := ctx.State["regex_matched"].([]string)[1]
|
||||
soutujson := soutuapi(keyword)
|
||||
pom1 := "https://i.pixiv.cat"
|
||||
rannum := Suiji()
|
||||
rannum := rand_int()
|
||||
pom2 := soutujson.Illusts[rannum].ImageUrls.Large[19:]
|
||||
ctx.SendChain(message.Image(pom1 + pom2))
|
||||
})
|
||||
@@ -71,7 +71,7 @@ func init() {
|
||||
}
|
||||
|
||||
// soutuapi 请求api
|
||||
func soutuapi(keyword string) *AutoGenerated {
|
||||
func soutuapi(keyword string) *resultjson {
|
||||
|
||||
url := "https://api.pixivel.moe/pixiv?type=search&page=0&mode=partial_match_for_tags&word=" + keyword
|
||||
method := "GET"
|
||||
@@ -90,15 +90,15 @@ func soutuapi(keyword string) *AutoGenerated {
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
result := &AutoGenerated{}
|
||||
result := &resultjson{}
|
||||
if err := json.NewDecoder(res.Body).Decode(result); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Suiji 从json里的30条数据中随机获取一条返回
|
||||
func Suiji() int {
|
||||
// rand_int 从json里的30条数据中随机获取一条返回
|
||||
func rand_int() int {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
return rand.Intn(30)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user