Skip to content

Commit

Permalink
🐛 搜图 有时无法下载图片
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Mar 13, 2022
1 parent 95e8bf2 commit b3b50e1
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 25 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand Down
4 changes: 2 additions & 2 deletions plugin/bilibili_push/bilibili_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/coser/coser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
10 changes: 5 additions & 5 deletions plugin/hs/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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)
}
Expand All @@ -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()
}
Expand Down
1 change: 1 addition & 0 deletions plugin/saucenao/searcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions plugin/score/sign_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/shadiao/caihongpi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plugin/shadiao/dujitang.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plugin/shadiao/pengyouquan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions plugin/shadiao/sweetnothings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plugin/shadiao/yduanzi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plugin/wangyiyun/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions plugin/zaobao/zaobao.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit b3b50e1

Please sign in to comment.