mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
优化 danbooru
This commit is contained in:
parent
07d541be20
commit
3c01c3f0ba
@ -3,7 +3,9 @@ package saucenao
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -113,70 +115,54 @@ func init() { // 插件主体
|
|||||||
if err == nil && resp.Count() > 0 {
|
if err == nil && resp.Count() > 0 {
|
||||||
result := resp.First()
|
result := resp.First()
|
||||||
// 返回SauceNAO的结果
|
// 返回SauceNAO的结果
|
||||||
picid := 0
|
|
||||||
picidstr := ""
|
|
||||||
source := ""
|
source := ""
|
||||||
switch {
|
switch {
|
||||||
case result.IsPixiv():
|
case result.IsPixiv():
|
||||||
picid = result.Data.PixivID
|
|
||||||
source = "Pixiv"
|
source = "Pixiv"
|
||||||
case result.IsAniDB():
|
case result.IsAniDB():
|
||||||
picid = result.Data.AniDBAID
|
|
||||||
source = "AniDB"
|
source = "AniDB"
|
||||||
case result.IsBcy():
|
case result.IsBcy():
|
||||||
picid = result.Data.BcyID
|
|
||||||
source = "Bcy"
|
source = "Bcy"
|
||||||
case result.IsDanbooru():
|
case result.IsDanbooru():
|
||||||
picid = result.Data.DanbooruID
|
|
||||||
source = "Danbooru"
|
source = "Danbooru"
|
||||||
case result.IsDeviantArt():
|
case result.IsDeviantArt():
|
||||||
picid = result.Data.DeviantArtID
|
|
||||||
source = "DeviantArt"
|
source = "DeviantArt"
|
||||||
case result.IsIMDb():
|
case result.IsIMDb():
|
||||||
picidstr = result.Data.IMDbID
|
|
||||||
source = "IMDb"
|
source = "IMDb"
|
||||||
case result.IsPawoo():
|
case result.IsPawoo():
|
||||||
picid = result.Data.PawooID
|
|
||||||
source = "Pawoo"
|
source = "Pawoo"
|
||||||
case result.IsSankaku():
|
case result.IsSankaku():
|
||||||
picid = result.Data.SankakuID
|
|
||||||
source = "Sankaku"
|
source = "Sankaku"
|
||||||
case result.IsSeiga():
|
case result.IsSeiga():
|
||||||
picid = result.Data.SeigaID
|
|
||||||
source = "Seiga"
|
source = "Seiga"
|
||||||
}
|
}
|
||||||
if picid != 0 {
|
if source != "" {
|
||||||
ctx.SendChain(
|
rr := reflect.ValueOf(&result).Elem()
|
||||||
message.Text("我有把握是这个!"),
|
b := binary.NewWriterF(func(w *binary.Writer) {
|
||||||
message.Image(result.Header.Thumbnail),
|
r := rr.Type()
|
||||||
message.Text(
|
for i := 0; i < r.NumField(); i++ {
|
||||||
"\n",
|
if !rr.Field(i).IsZero() {
|
||||||
"图源: ", source, "\n",
|
w.WriteString("\n")
|
||||||
"相似度: ", result.Header.Similarity, "\n",
|
w.WriteString(r.Field(i).Name)
|
||||||
"标题: ", result.Data.Title, "\n",
|
w.WriteString(": ")
|
||||||
"插画ID: ", picid, "\n",
|
w.WriteString(fmt.Sprint(rr.Field(i).Interface()))
|
||||||
"画师: ", result.Data.MemberName, "\n",
|
}
|
||||||
"画师ID: ", result.Data.MemberID, "\n",
|
}
|
||||||
"直链: ", "https://pixivel.moe/detail?id=", result.Data.PixivID,
|
})
|
||||||
),
|
resp, err := http.Head(result.Header.Thumbnail)
|
||||||
)
|
if err == nil && resp.StatusCode == http.StatusOK {
|
||||||
continue
|
ctx.SendChain(
|
||||||
}
|
message.Text("我有把握是这个!"),
|
||||||
if picidstr != "" {
|
message.Image(result.Header.Thumbnail),
|
||||||
ctx.SendChain(
|
message.Text("\n图源: ", source, binary.BytesToString(b)),
|
||||||
message.Text("我有把握是这个!"),
|
)
|
||||||
message.Image(result.Header.Thumbnail),
|
} else {
|
||||||
message.Text(
|
ctx.SendChain(
|
||||||
"\n",
|
message.Text("我有把握是这个!"),
|
||||||
"图源: ", source, "\n",
|
message.Image(pic),
|
||||||
"相似度: ", result.Header.Similarity, "\n",
|
message.Text("\n图源: ", source, binary.BytesToString(b)),
|
||||||
"标题: ", result.Data.Title, "\n",
|
)
|
||||||
"插画ID: ", picidstr, "\n",
|
}
|
||||||
"画师: ", result.Data.MemberName, "\n",
|
|
||||||
"画师ID: ", result.Data.MemberID, "\n",
|
|
||||||
"直链: ", "https://pixivel.moe/detail?id=", result.Data.PixivID,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user