mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 05:30:07 +08:00
🐛 搜图 有时无法下载图片
This commit is contained in:
parent
95e8bf2f55
commit
b3b50e1353
4
go.mod
4
go.mod
@ -3,9 +3,9 @@ module github.com/FloatTech/ZeroBot-Plugin
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/FloatTech/AnimeAPI v1.3.1
|
||||
github.com/FloatTech/AnimeAPI v1.3.2-0.20220313050941-09c687419791
|
||||
github.com/FloatTech/sqlite v0.2.1
|
||||
github.com/FloatTech/zbputils v1.3.1
|
||||
github.com/FloatTech/zbputils v1.3.2-0.20220313050647-f542a820183c
|
||||
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,10 +1,10 @@
|
||||
github.com/FloatTech/AnimeAPI v1.3.1 h1:EBNz9pzfH5vYqs8HyME9AL3gXjO+iJ5DgWmqOfdNb18=
|
||||
github.com/FloatTech/AnimeAPI v1.3.1/go.mod h1:rEBMdnN1yPKt9DdL/BRSRibp7jR1SQiLIaEeQ53R+dk=
|
||||
github.com/FloatTech/AnimeAPI v1.3.2-0.20220313050941-09c687419791 h1:wgBjKq4B3vTES/iRXy/8HBiv/NmgXN1mb9D6ZXY07As=
|
||||
github.com/FloatTech/AnimeAPI v1.3.2-0.20220313050941-09c687419791/go.mod h1:ZraPslbw7AL9h9P1FMxbl8JMRvSuXC3PWXOX9inr7w8=
|
||||
github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ=
|
||||
github.com/FloatTech/sqlite v0.2.1 h1:9t6Me48XJJCIoPy4nLRvcdhcVKfT0c2lilp7SEKROG8=
|
||||
github.com/FloatTech/sqlite v0.2.1/go.mod h1:6NfHRzqOo9RWeMJEoAQVuo51Omd5LFNxCNQhMF02/9U=
|
||||
github.com/FloatTech/zbputils v1.3.1 h1:ZdK5vkjdtDoeB83FoPAd+vIRmKdILeDSsLLiDIdanVI=
|
||||
github.com/FloatTech/zbputils v1.3.1/go.mod h1:ByNutpHjwyrhaxo54dRjJDEppko0Fcot2iOv7WrIDUg=
|
||||
github.com/FloatTech/zbputils v1.3.2-0.20220313050647-f542a820183c h1:14Ybaf7Zo5CfgVnD5cxp/nJsmw1NWIna2KqsH9ZTKKc=
|
||||
github.com/FloatTech/zbputils v1.3.2-0.20220313050647-f542a820183c/go.mod h1:ByNutpHjwyrhaxo54dRjJDEppko0Fcot2iOv7WrIDUg=
|
||||
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=
|
||||
|
||||
@ -231,7 +231,7 @@ func bilibiliPushDaily() {
|
||||
}
|
||||
|
||||
func checkBuid(buid int64) (status int, name string) {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), fmt.Sprintf(infoURL, buid), "GET", referer, ua)
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), fmt.Sprintf(infoURL, buid), "GET", referer, ua)
|
||||
if err != nil {
|
||||
log.Errorln("[bilibilipush]:", err)
|
||||
}
|
||||
@ -289,7 +289,7 @@ func unsubscribeLive(buid, groupid int64) (err error) {
|
||||
}
|
||||
|
||||
func getUserDynamicCard(buid int64) (cardList []gjson.Result) {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), fmt.Sprintf(userDynamicURL, buid), "GET", referer, ua)
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), fmt.Sprintf(userDynamicURL, buid), "GET", referer, ua)
|
||||
if err != nil {
|
||||
log.Errorln("[bilibilipush]:", err)
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ func init() {
|
||||
}).ApplySingle(ctxext.DefaultSingle).OnFullMatch("coser", zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByGroup).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text("少女祈祷中......"))
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), coserURL, "GET", "", ua)
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), coserURL, "GET", "", ua)
|
||||
if err != nil {
|
||||
log.Println("err为:", err)
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ func init() {
|
||||
cid := gjson.Get(g, `list.`+strconv.Itoa(i)+`.CardID`).String()
|
||||
cachefile := cachedir + cid
|
||||
if file.IsNotExist(cachefile) {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(),
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(),
|
||||
`https://res.fbigame.com/hs/v13/`+cid+`.png?auth_key=`+
|
||||
gjson.Get(g, `list.`+strconv.Itoa(i)+`.auth_key`).String(),
|
||||
reqconf[0], reqconf[1], reqconf[2])
|
||||
@ -98,10 +98,10 @@ func init() {
|
||||
}
|
||||
|
||||
func sh(s string) string {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), "https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2])
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), "https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2])
|
||||
if err == nil {
|
||||
url := hs + para + "&hash=" + strings.SplitN(strings.SplitN(helper.BytesToString(data), `var hash = "`, 2)[1], `"`, 2)[0] + "&search=" + s
|
||||
r, err := web.GetDataWith(web.NewDefaultClient(), url, reqconf[0], reqconf[1], reqconf[2])
|
||||
r, err := web.RequestDataWith(web.NewDefaultClient(), url, reqconf[0], reqconf[1], reqconf[2])
|
||||
if err == nil {
|
||||
return helper.BytesToString(r)
|
||||
}
|
||||
@ -110,10 +110,10 @@ func sh(s string) string {
|
||||
}
|
||||
|
||||
func kz(s string) string {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), "https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2])
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), "https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2])
|
||||
if err == nil {
|
||||
url := hs + para + "mod=general_deck_image&deck_code=" + s + "&deck_text=&hash=" + strings.SplitN(strings.SplitN(helper.BytesToString(data), `var hash = "`, 2)[1], `"`, 2)[0] + "&search=" + s
|
||||
r, err := web.GetDataWith(web.NewDefaultClient(), url, reqconf[0], reqconf[1], reqconf[2])
|
||||
r, err := web.RequestDataWith(web.NewDefaultClient(), url, reqconf[0], reqconf[1], reqconf[2])
|
||||
if err == nil {
|
||||
return "base64://" + gjson.Get(helper.BytesToString(r), "img").String()
|
||||
}
|
||||
|
||||
@ -53,6 +53,7 @@ func init() { // 插件主体
|
||||
continue
|
||||
}
|
||||
logrus.Debugln("[sausenao]开始下载", n)
|
||||
logrus.Debugln("[sausenao]urls:", illust.ImageUrls)
|
||||
err1 := illust.DownloadToCache(i)
|
||||
if err1 == nil {
|
||||
m.SetFile(f)
|
||||
|
||||
@ -203,12 +203,12 @@ func getLevel(count int) int {
|
||||
|
||||
func initPic(picFile string) {
|
||||
if file.IsNotExist(picFile) {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), backgroundURL, "GET", referer, ua)
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), backgroundURL, "GET", referer, ua)
|
||||
if err != nil {
|
||||
log.Errorln("[score]", err)
|
||||
}
|
||||
picURL := gjson.Get(string(data), "pic").String()
|
||||
data, err = web.GetDataWith(web.NewDefaultClient(), picURL, "GET", "", ua)
|
||||
data, err = web.RequestDataWith(web.NewDefaultClient(), picURL, "GET", "", ua)
|
||||
if err != nil {
|
||||
log.Errorln("[score]", err)
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ import (
|
||||
|
||||
func init() {
|
||||
engine.OnFullMatch("哄我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), chpURL, "GET", chpReferer, ua)
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), chpURL, "GET", chpReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
|
||||
@ -11,7 +11,7 @@ import (
|
||||
|
||||
func init() {
|
||||
engine.OnFullMatch("来碗毒鸡汤").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), duURL, "GET", duReferer, ua)
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), duURL, "GET", duReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
|
||||
@ -11,7 +11,7 @@ import (
|
||||
|
||||
func init() {
|
||||
engine.OnFullMatch("发个朋友圈").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), pyqURL, "GET", pyqReferer, ua)
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), pyqURL, "GET", pyqReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
|
||||
@ -12,7 +12,7 @@ import (
|
||||
|
||||
func init() {
|
||||
engine.OnFullMatch("来碗绿茶").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), chayiURL, "GET", loveliveReferer, ua)
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), chayiURL, "GET", loveliveReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
@ -22,7 +22,7 @@ func init() {
|
||||
})
|
||||
|
||||
engine.OnFullMatch("渣我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), ganhaiURL, "GET", loveliveReferer, ua)
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), ganhaiURL, "GET", loveliveReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
|
||||
@ -14,7 +14,7 @@ import (
|
||||
|
||||
func init() {
|
||||
engine.OnFullMatch("讲个段子").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), yduanziURL, "POST", yduanziReferer, ua)
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), yduanziURL, "POST", yduanziReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
|
||||
@ -24,7 +24,7 @@ func init() {
|
||||
Help: "wangyiyun \n- 来份网易云热评",
|
||||
}).OnFullMatch("来份网易云热评").SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), wangyiyunURL, "GET", wangyiyunReferer, ua)
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), wangyiyunURL, "GET", wangyiyunReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
|
||||
@ -54,11 +54,11 @@ func getdata() error { // 获取图片链接并且下载
|
||||
if picdata != nil && time.Since(pictime) <= time.Hour*20 {
|
||||
return nil
|
||||
}
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), api, "GET", "", ua)
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), api, "GET", "", ua)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
picdata, err = web.GetDataWith(web.NewDefaultClient(), gjson.Get(binary.BytesToString(data), "url").String(), "GET", referer, ua)
|
||||
picdata, err = web.RequestDataWith(web.NewDefaultClient(), gjson.Get(binary.BytesToString(data), "url").String(), "GET", referer, ua)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user