mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-20 14:30:10 +08:00
imgfinder add more info
This commit is contained in:
parent
b9fd590095
commit
9f748a8119
2
go.mod
2
go.mod
@ -6,7 +6,7 @@ require (
|
|||||||
github.com/FloatTech/AnimeAPI v1.4.1-0.20220610045824-90f281c6eece
|
github.com/FloatTech/AnimeAPI v1.4.1-0.20220610045824-90f281c6eece
|
||||||
github.com/FloatTech/sqlite v0.2.1
|
github.com/FloatTech/sqlite v0.2.1
|
||||||
github.com/FloatTech/zbpctrl v1.4.1-0.20220604065149-1ca23316481c
|
github.com/FloatTech/zbpctrl v1.4.1-0.20220604065149-1ca23316481c
|
||||||
github.com/FloatTech/zbputils v1.4.1-0.20220604095022-69b69d618e08
|
github.com/FloatTech/zbputils v1.4.1-0.20220610052426-fd549a8c7867
|
||||||
github.com/antchfx/htmlquery v1.2.4
|
github.com/antchfx/htmlquery v1.2.4
|
||||||
github.com/corona10/goimagehash v1.0.3
|
github.com/corona10/goimagehash v1.0.3
|
||||||
github.com/fogleman/gg v1.3.0
|
github.com/fogleman/gg v1.3.0
|
||||||
|
|||||||
4
go.sum
4
go.sum
@ -14,8 +14,8 @@ github.com/FloatTech/sqlite v0.2.1 h1:9t6Me48XJJCIoPy4nLRvcdhcVKfT0c2lilp7SEKROG
|
|||||||
github.com/FloatTech/sqlite v0.2.1/go.mod h1:6NfHRzqOo9RWeMJEoAQVuo51Omd5LFNxCNQhMF02/9U=
|
github.com/FloatTech/sqlite v0.2.1/go.mod h1:6NfHRzqOo9RWeMJEoAQVuo51Omd5LFNxCNQhMF02/9U=
|
||||||
github.com/FloatTech/zbpctrl v1.4.1-0.20220604065149-1ca23316481c h1:1LhskkE5oP1Y2Vi9f4/s5Lns5M5vIzvGAAwJ4z23h+o=
|
github.com/FloatTech/zbpctrl v1.4.1-0.20220604065149-1ca23316481c h1:1LhskkE5oP1Y2Vi9f4/s5Lns5M5vIzvGAAwJ4z23h+o=
|
||||||
github.com/FloatTech/zbpctrl v1.4.1-0.20220604065149-1ca23316481c/go.mod h1:x57TwTlC6zGhs+HHzWATD0sabyoDpSt8b7OzV3Mvrdc=
|
github.com/FloatTech/zbpctrl v1.4.1-0.20220604065149-1ca23316481c/go.mod h1:x57TwTlC6zGhs+HHzWATD0sabyoDpSt8b7OzV3Mvrdc=
|
||||||
github.com/FloatTech/zbputils v1.4.1-0.20220604095022-69b69d618e08 h1:5L+ucTyGTgEop0lUIZtGcih4Ro/quen2BxhjSHhv+us=
|
github.com/FloatTech/zbputils v1.4.1-0.20220610052426-fd549a8c7867 h1:bGCxabeJfHZDG2jw63fguzt/y8cyWZpDjjyxQ8rNJNQ=
|
||||||
github.com/FloatTech/zbputils v1.4.1-0.20220604095022-69b69d618e08/go.mod h1:xlw8tTnwv+pglm2WZTDr/9Gl767ALYBguwsqibDqYpI=
|
github.com/FloatTech/zbputils v1.4.1-0.20220610052426-fd549a8c7867/go.mod h1:xlw8tTnwv+pglm2WZTDr/9Gl767ALYBguwsqibDqYpI=
|
||||||
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
||||||
github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c h1:cNPOdTNiVwxLpROLjXCgbIPvdkE+BwvxDvgmdYmWx6Q=
|
github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c h1:cNPOdTNiVwxLpROLjXCgbIPvdkE+BwvxDvgmdYmWx6Q=
|
||||||
github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c/go.mod h1:KqZzu7slNKROh3TSYEH/IUMG6f4M+1qubZ5e52QypsE=
|
github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c/go.mod h1:KqZzu7slNKROh3TSYEH/IUMG6f4M+1qubZ5e52QypsE=
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/http3"
|
"github.com/lucas-clemente/quic-go/http3"
|
||||||
@ -17,6 +18,7 @@ import (
|
|||||||
"github.com/FloatTech/AnimeAPI/pixiv"
|
"github.com/FloatTech/AnimeAPI/pixiv"
|
||||||
|
|
||||||
ctrl "github.com/FloatTech/zbpctrl"
|
ctrl "github.com/FloatTech/zbpctrl"
|
||||||
|
"github.com/FloatTech/zbputils/binary"
|
||||||
"github.com/FloatTech/zbputils/control"
|
"github.com/FloatTech/zbputils/control"
|
||||||
"github.com/FloatTech/zbputils/ctxext"
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
"github.com/FloatTech/zbputils/img/pool"
|
"github.com/FloatTech/zbputils/img/pool"
|
||||||
@ -52,7 +54,6 @@ type resultjson struct {
|
|||||||
Image string `json:"image"`
|
Image string `json:"image"`
|
||||||
} `json:"illusts"`
|
} `json:"illusts"`
|
||||||
Scores []float64 `json:"scores"`
|
Scores []float64 `json:"scores"`
|
||||||
Highlight []string `json:"highlight"`
|
|
||||||
HasNext bool `json:"has_next"`
|
HasNext bool `json:"has_next"`
|
||||||
} `json:"data"`
|
} `json:"data"`
|
||||||
}
|
}
|
||||||
@ -71,7 +72,8 @@ func init() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
rannum := rand.Intn(len(soutujson.Data.Illusts))
|
rannum := rand.Intn(len(soutujson.Data.Illusts))
|
||||||
illust, err := pixiv.Works(soutujson.Data.Illusts[rannum].ID)
|
il := soutujson.Data.Illusts[rannum]
|
||||||
|
illust, err := pixiv.Works(il.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR:", err))
|
ctx.SendChain(message.Text("ERROR:", err))
|
||||||
return
|
return
|
||||||
@ -83,7 +85,19 @@ func init() {
|
|||||||
err = pool.SendImageFromPool(n, f, func() error {
|
err = pool.SendImageFromPool(n, f, func() error {
|
||||||
// 下载图片
|
// 下载图片
|
||||||
return illust.DownloadToCache(0)
|
return illust.DownloadToCache(0)
|
||||||
}, ctxext.SendFakeForwardToGroup(ctx), ctxext.GetFirstMessageInForward(ctx))
|
}, ctxext.SendFakeForwardToGroup(ctx,
|
||||||
|
message.Text(
|
||||||
|
il.Width, "x", il.Height, "\n",
|
||||||
|
"标题: ", il.Title, "\n",
|
||||||
|
"副标题: ", il.AltTitle, "\n",
|
||||||
|
"ID: ", il.ID,
|
||||||
|
"简介: ", il.Description, "\n",
|
||||||
|
"画师: ", illust.UserName, "\n",
|
||||||
|
"画师ID: ", illust.UserId, "\n",
|
||||||
|
"分级:", il.Sanity, "\n",
|
||||||
|
printtags(reflect.ValueOf(&il.Tags)),
|
||||||
|
),
|
||||||
|
), ctxext.GetFirstMessageInForward(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR:", err))
|
ctx.SendChain(message.Text("ERROR:", err))
|
||||||
return
|
return
|
||||||
@ -109,3 +123,21 @@ func soutuapi(keyword string) (r resultjson, err error) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func printtags(r reflect.Value) string {
|
||||||
|
tags := r.Elem()
|
||||||
|
s := binary.BytesToString(binary.NewWriterF(func(w *binary.Writer) {
|
||||||
|
for i := 0; i < tags.Len(); i++ {
|
||||||
|
tag := tags.Index(i)
|
||||||
|
_ = w.WriteByte('#')
|
||||||
|
w.WriteString(tag.Field(0).String())
|
||||||
|
w.WriteString(" (")
|
||||||
|
w.WriteString(tag.Field(1).String())
|
||||||
|
w.WriteString(")\n")
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
if len(s) > 0 {
|
||||||
|
s = s[:len(s)-1]
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user