mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
✨ 修正代码问题
This commit is contained in:
parent
5e064249be
commit
09a9dd53fd
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/FloatTech/AnimeAPI/picture"
|
"github.com/FloatTech/AnimeAPI/picture"
|
||||||
"github.com/FloatTech/AnimeAPI/pixiv"
|
"github.com/FloatTech/AnimeAPI/pixiv"
|
||||||
"github.com/FloatTech/AnimeAPI/saucenao"
|
"github.com/FloatTech/AnimeAPI/saucenao"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
|
|
||||||
@ -50,22 +51,22 @@ func init() { // 插件主体
|
|||||||
filepath := datapath + name
|
filepath := datapath + name
|
||||||
switch {
|
switch {
|
||||||
case file.IsExist(filepath + ".jpg"):
|
case file.IsExist(filepath + ".jpg"):
|
||||||
filepath += ".jpg"
|
filepath = "file:///" + filepath + ".jpg"
|
||||||
case file.IsExist(filepath + ".png"):
|
case file.IsExist(filepath + ".png"):
|
||||||
filepath += ".png"
|
filepath = "file:///" + filepath + ".png"
|
||||||
case file.IsExist(filepath + ".gif"):
|
case file.IsExist(filepath + ".gif"):
|
||||||
filepath += ".gif"
|
filepath = "file:///" + filepath + ".gif"
|
||||||
default:
|
default:
|
||||||
filepath = ""
|
filepath = ""
|
||||||
}
|
}
|
||||||
if filepath == "" {
|
if filepath == "" {
|
||||||
|
logrus.Debug("[sausenao]开始下载", name)
|
||||||
filepath, err = pixiv.Download(illust.ImageUrls, datapath, name)
|
filepath, err = pixiv.Download(illust.ImageUrls, datapath, name)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
filepath = "file:///" + filepath
|
filepath = "file:///" + filepath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txt := message.Text(
|
txt := message.Text(
|
||||||
"\n",
|
|
||||||
"标题:", illust.Title, "\n",
|
"标题:", illust.Title, "\n",
|
||||||
"插画ID:", illust.Pid, "\n",
|
"插画ID:", illust.Pid, "\n",
|
||||||
"画师:", illust.UserName, "\n",
|
"画师:", illust.UserName, "\n",
|
||||||
@ -74,7 +75,7 @@ func init() { // 插件主体
|
|||||||
)
|
)
|
||||||
if filepath != "" {
|
if filepath != "" {
|
||||||
// 发送搜索结果
|
// 发送搜索结果
|
||||||
ctx.SendChain(message.Image(filepath), txt)
|
ctx.SendChain(message.Image(filepath), message.Text("\n"), txt)
|
||||||
}
|
}
|
||||||
// 图片下载失败,仅发送文字结果
|
// 图片下载失败,仅发送文字结果
|
||||||
ctx.SendChain(txt)
|
ctx.SendChain(txt)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user