mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 05:30:07 +08:00
🐛 修正 imgpool
This commit is contained in:
parent
f826b4d0bc
commit
6ece644a7b
4
go.mod
4
go.mod
@ -3,8 +3,8 @@ module github.com/FloatTech/ZeroBot-Plugin
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/FloatTech/AnimeAPI v1.2.4-beta22
|
||||
github.com/FloatTech/zbputils v1.2.4-beta7
|
||||
github.com/FloatTech/AnimeAPI v1.2.4-beta23
|
||||
github.com/FloatTech/zbputils v1.2.4-beta8
|
||||
github.com/antchfx/htmlquery v1.2.4
|
||||
github.com/corona10/goimagehash v1.0.3
|
||||
github.com/fogleman/gg v1.3.0
|
||||
|
||||
8
go.sum
8
go.sum
@ -1,8 +1,8 @@
|
||||
github.com/FloatTech/AnimeAPI v1.2.4-beta22 h1:v1Zyfzrkss0bnpH7iMN0ajpMM4JUT5bNerQ4ntN3dI0=
|
||||
github.com/FloatTech/AnimeAPI v1.2.4-beta22/go.mod h1:rhYvzqLH2YTKBOk7DfJsXsdZlnxhpBP3HvctwqlLykM=
|
||||
github.com/FloatTech/AnimeAPI v1.2.4-beta23 h1:Ed51hkj9uBj4751xMMnksWAnq4YUzVm4akwV3fsRNdY=
|
||||
github.com/FloatTech/AnimeAPI v1.2.4-beta23/go.mod h1:3V4u+0bha5zI5leWC3EObxycwokJDR25Q8IQ+fSHvlg=
|
||||
github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ=
|
||||
github.com/FloatTech/zbputils v1.2.4-beta7 h1:DofQTSVEBU1BQnLb4GahNZqsqVqoj4Lu5GDJa2rJW9o=
|
||||
github.com/FloatTech/zbputils v1.2.4-beta7/go.mod h1:mPVpKu2scTyBiitNmzCrxGc9aIKs9rwfb6iqz/+heck=
|
||||
github.com/FloatTech/zbputils v1.2.4-beta8 h1:yaxF2tA2V4r5klonecb89wPTwMoHxRhxnO/0pqFT6/8=
|
||||
github.com/FloatTech/zbputils v1.2.4-beta8/go.mod h1:mPVpKu2scTyBiitNmzCrxGc9aIKs9rwfb6iqz/+heck=
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb h1:Rkj28fqIwGx/EgBzRYtpmJRfH6wqVn7cNdc7aJ0QE4M=
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb/go.mod h1:imVKbfKqqeit+C/eaWGb4MKQ3z3gN6pRpBU5RMtp5so=
|
||||
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
||||
|
||||
@ -23,6 +23,7 @@ import (
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/math"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/FloatTech/zbputils/txt2img"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
@ -146,7 +147,7 @@ func init() {
|
||||
digest := md5.Sum(helper.StringToBytes(zipfile + strconv.Itoa(index) + title + text))
|
||||
cachefile := cache + hex.EncodeToString(digest[:])
|
||||
|
||||
m, err := imgpool.NewImage(ctx, cachefile, file.BOTPATH+"/"+cachefile)
|
||||
m, err := imgpool.GetImage(ctx, cachefile)
|
||||
if err != nil {
|
||||
logrus.Debugln("[fortune]", err)
|
||||
if file.IsNotExist(cachefile) {
|
||||
@ -163,6 +164,11 @@ func init() {
|
||||
}
|
||||
}
|
||||
m, err = imgpool.NewImage(ctx, cachefile, file.BOTPATH+"/"+cachefile)
|
||||
process.SleepAbout1sTo2s() // 防止风控
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + cachefile))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
||||
@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/imgpool"
|
||||
@ -76,7 +76,7 @@ func init() {
|
||||
rannum := randintn(len(soutujson.Illusts))
|
||||
pom2 := soutujson.Illusts[rannum].ImageUrls.Medium[19:]
|
||||
u := pom1 + pom2
|
||||
m, err := imgpool.NewImage(ctx, strconv.Itoa(soutujson.Illusts[rannum].ID), u)
|
||||
m, err := imgpool.NewImage(ctx, u[strings.LastIndex(u, "/")+1:], u)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Image(u))
|
||||
return
|
||||
|
||||
@ -14,6 +14,7 @@ import (
|
||||
"github.com/FloatTech/AnimeAPI/imgpool"
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/math"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
)
|
||||
@ -54,7 +55,12 @@ func init() {
|
||||
}
|
||||
url := json.Get("data.0.urls.original").Str
|
||||
url = strings.ReplaceAll(url, "i.pixiv.cat", "i.pixiv.re")
|
||||
m, err := imgpool.NewImage(ctx, url[:strings.LastIndex(url, "/")+1], url)
|
||||
name := url[strings.LastIndex(url, "/")+1:]
|
||||
m, err := imgpool.GetImage(ctx, name)
|
||||
if err != nil {
|
||||
m, err = imgpool.NewImage(ctx, name, url)
|
||||
process.SleepAbout1sTo2s()
|
||||
}
|
||||
if err == nil {
|
||||
queue <- m.String()
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user