diff --git a/go.mod b/go.mod index 12cddda1..6c5e95f7 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module github.com/FloatTech/ZeroBot-Plugin go 1.17 require ( - github.com/FloatTech/AnimeAPI v1.3.0-beta8.0.20220224052148-f7a1379d4a00 + github.com/FloatTech/AnimeAPI v1.3.0-beta8.0.20220227060429-ae266747b1df github.com/FloatTech/sqlite v0.2.0 - github.com/FloatTech/zbputils v1.3.0-beta8.0.20220226150734-48567d2365af + github.com/FloatTech/zbputils v1.3.0-beta8.0.20220227042832-376a84a3ea87 github.com/antchfx/htmlquery v1.2.4 github.com/corona10/goimagehash v1.0.3 github.com/fogleman/gg v1.3.0 diff --git a/go.sum b/go.sum index 39414d79..a9d9e501 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,10 @@ -github.com/FloatTech/AnimeAPI v1.3.0-beta8.0.20220224052148-f7a1379d4a00 h1:idUMQfvkooUapF1B2WDrm84QQqz7t+/bVnSTIrs4Khg= -github.com/FloatTech/AnimeAPI v1.3.0-beta8.0.20220224052148-f7a1379d4a00/go.mod h1:WGkFlN/5QbdptbQuvGrS7KQl5nAdQbvZLFsbrM7rWCU= +github.com/FloatTech/AnimeAPI v1.3.0-beta8.0.20220227060429-ae266747b1df h1:pz6mcz4pC8hEbyygM/QX/mX7pgvQOIpYF8H940/4Z8Q= +github.com/FloatTech/AnimeAPI v1.3.0-beta8.0.20220227060429-ae266747b1df/go.mod h1:uMe7TzdyGnyRn6AzMmkvDXp+GfTTWV/vBlv6mhhP8kg= github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ= github.com/FloatTech/sqlite v0.2.0 h1:x3uls/hExXH1+bbaNLkvilce6ATtWlDx4IqoxBW/bv8= github.com/FloatTech/sqlite v0.2.0/go.mod h1:xIDWIvpOFl8AXmZm0FC8t3PZjiR6ZutytCpBv2EWCns= -github.com/FloatTech/zbputils v1.3.0-beta8.0.20220224051618-597cdb58b3fe/go.mod h1:Jn5LmnwqYivr64qQJBdhDwm2gRut8Hhq5gPBydV0Gvg= -github.com/FloatTech/zbputils v1.3.0-beta8.0.20220226150734-48567d2365af h1:nwXPR9+RuTbjk0zh+4Sg37wWaqfQb8kGvSfPA1wsF+0= -github.com/FloatTech/zbputils v1.3.0-beta8.0.20220226150734-48567d2365af/go.mod h1:Jn5LmnwqYivr64qQJBdhDwm2gRut8Hhq5gPBydV0Gvg= +github.com/FloatTech/zbputils v1.3.0-beta8.0.20220227042832-376a84a3ea87 h1:nyUTZLGUAJP/kLXx48j2qdxQBPVqaZgypjjIqpIRqwk= +github.com/FloatTech/zbputils v1.3.0-beta8.0.20220227042832-376a84a3ea87/go.mod h1:Jn5LmnwqYivr64qQJBdhDwm2gRut8Hhq5gPBydV0Gvg= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc h1:AAx50/fb/xS4lvsdQg+bFbGvqSDhyV1MF+p2PLCamZ0= github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc/go.mod h1:OMmITAib6POA37xCichWM0aRnoVpSMZO1rB/G01wrr0= diff --git a/plugin/saucenao/searcher.go b/plugin/saucenao/searcher.go index 43d8d52a..6af260cf 100644 --- a/plugin/saucenao/searcher.go +++ b/plugin/saucenao/searcher.go @@ -58,6 +58,9 @@ func init() { // 插件主体 m.SetFile(f) _, _ = m.Push(ctxext.SendToSelf(ctx), ctxext.GetMessage(ctx)) } + if err1 != nil { + logrus.Debugln("[sausenao]下载err:", err1) + } } imgs = append(imgs, message.Image("file:///"+f)) } diff --git a/plugin/setutime/setu_geter.go b/plugin/setutime/setu_geter.go index 9ace5186..5519f397 100644 --- a/plugin/setutime/setu_geter.go +++ b/plugin/setutime/setu_geter.go @@ -2,7 +2,6 @@ package setutime import ( - "errors" "fmt" "strconv" "strings" @@ -158,10 +157,12 @@ func (p *imgpool) push(ctx *zero.Ctx, imgtype string, illust *pixiv.Illust) { var msg message.MessageSegment f := fileutil.BOTPATH + "/" + illust.Path(0) if err != nil { - // 下载图片 - if err := illust.DownloadToCache(0); err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return + if fileutil.IsNotExist(f) { + // 下载图片 + if err := illust.DownloadToCache(0); err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } } if err != imagepool.ErrImgFileAsync { m.SetFile(f) @@ -190,21 +191,6 @@ func (p *imgpool) pop(imgtype string) (msg *message.MessageSegment) { return } -func (p *imgpool) cachefile(i *pixiv.Illust) string { - filename := fmt.Sprint(i.Pid) + "_p0" - filepath := fileutil.BOTPATH + `/` + p.path + filename - if fileutil.IsExist(filepath + ".jpg") { - return `file:///` + filepath + ".jpg" - } - if fileutil.IsExist(filepath + ".png") { - return `file:///` + filepath + ".png" - } - if fileutil.IsExist(filepath + ".gif") { - return `file:///` + filepath + ".gif" - } - return "" -} - // fill 补充池子 func (p *imgpool) fill(ctx *zero.Ctx, imgtype string) { times := math.Min(p.max-p.size(imgtype), 2) @@ -235,14 +221,12 @@ func (p *imgpool) add(ctx *zero.Ctx, imgtype string, id int64) error { if err != nil { return err } - // 下载插画 - if err := illust.DownloadToCache(0); err != nil { + err = imagepool.SendImageFromPool(strconv.FormatInt(illust.Pid, 10)+"_p0", illust.Path(0), func() error { + return illust.DownloadToCache(0) + }, ctxext.Send(ctx), ctxext.GetMessage(ctx)) + if err != nil { return err } - // 发送到发送者 - if id := ctx.SendChain(message.Image(p.cachefile(illust))); id.ID() == 0 { - return errors.New("可能被风控,发送失败") - } // 添加插画到对应的数据库table if err := p.db.Insert(imgtype, illust); err != nil { return err