This commit is contained in:
fumiama 2022-02-27 19:31:53 +08:00
parent a469000d7a
commit 0a0cc807dc
14 changed files with 26 additions and 33 deletions

4
go.mod
View File

@ -3,9 +3,9 @@ module github.com/FloatTech/ZeroBot-Plugin
go 1.17 go 1.17
require ( require (
github.com/FloatTech/AnimeAPI v1.3.0 github.com/FloatTech/AnimeAPI v1.3.1-0.20220227112758-da30b39dd7a7
github.com/FloatTech/sqlite v0.2.0 github.com/FloatTech/sqlite v0.2.0
github.com/FloatTech/zbputils v1.3.0 github.com/FloatTech/zbputils v1.3.1-0.20220227112438-2ccf42cc85d3
github.com/antchfx/htmlquery v1.2.4 github.com/antchfx/htmlquery v1.2.4
github.com/corona10/goimagehash v1.0.3 github.com/corona10/goimagehash v1.0.3
github.com/fogleman/gg v1.3.0 github.com/fogleman/gg v1.3.0

8
go.sum
View File

@ -1,10 +1,10 @@
github.com/FloatTech/AnimeAPI v1.3.0 h1:99WNHJ/VqqdzN8q3ul0oY4j5FxT+wp8fnvBtsN6qpa4= github.com/FloatTech/AnimeAPI v1.3.1-0.20220227112758-da30b39dd7a7 h1:JOmelUrxBef/Sg/15PgkBC3IV4BpORQwiSWfqV1nCD0=
github.com/FloatTech/AnimeAPI v1.3.0/go.mod h1:uEzRyhIgYA5/pcBhlvHOfGiTvLH1qZkICxnVGU+4b/8= github.com/FloatTech/AnimeAPI v1.3.1-0.20220227112758-da30b39dd7a7/go.mod h1:AuFa+9NWdJujJc2PvCoO2NqLOwwwFXKy69X0zexsZS0=
github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ= 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 h1:x3uls/hExXH1+bbaNLkvilce6ATtWlDx4IqoxBW/bv8=
github.com/FloatTech/sqlite v0.2.0/go.mod h1:xIDWIvpOFl8AXmZm0FC8t3PZjiR6ZutytCpBv2EWCns= github.com/FloatTech/sqlite v0.2.0/go.mod h1:xIDWIvpOFl8AXmZm0FC8t3PZjiR6ZutytCpBv2EWCns=
github.com/FloatTech/zbputils v1.3.0 h1:gCJbDpKdMu1bavA8FGr2kmMFgeL8Dcsj9BBOkYiMprI= github.com/FloatTech/zbputils v1.3.1-0.20220227112438-2ccf42cc85d3 h1:BA9mbIE2D2hhZnGaFjgIbiUrwG4h6VjVYf4UoDnBVn8=
github.com/FloatTech/zbputils v1.3.0/go.mod h1:NXv73hWyC4Q4S4wg01DEwLzznSHSmde0o03PnsS1DtY= github.com/FloatTech/zbputils v1.3.1-0.20220227112438-2ccf42cc85d3/go.mod h1:NXv73hWyC4Q4S4wg01DEwLzznSHSmde0o03PnsS1DtY=
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= 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 h1:AAx50/fb/xS4lvsdQg+bFbGvqSDhyV1MF+p2PLCamZ0=
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc/go.mod h1:OMmITAib6POA37xCichWM0aRnoVpSMZO1rB/G01wrr0= github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc/go.mod h1:OMmITAib6POA37xCichWM0aRnoVpSMZO1rB/G01wrr0=

View File

@ -232,7 +232,7 @@ func bilibiliPushDaily() {
} }
func checkBuid(buid int64) (status int, name string) { func checkBuid(buid int64) (status int, name string) {
data, err := web.ReqWith(fmt.Sprintf(infoURL, buid), "GET", referer, ua) data, err := web.GetDataWith(web.NewDefaultClient(), fmt.Sprintf(infoURL, buid), "GET", referer, ua)
if err != nil { if err != nil {
log.Errorln("[bilibilipush]:", err) log.Errorln("[bilibilipush]:", err)
} }
@ -290,7 +290,7 @@ func unsubscribeLive(buid, groupid int64) (err error) {
} }
func getUserDynamicCard(buid int64) (cardList []gjson.Result) { func getUserDynamicCard(buid int64) (cardList []gjson.Result) {
data, err := web.ReqWith(fmt.Sprintf(userDynamicURL, buid), "GET", referer, ua) data, err := web.GetDataWith(web.NewDefaultClient(), fmt.Sprintf(userDynamicURL, buid), "GET", referer, ua)
if err != nil { if err != nil {
log.Errorln("[bilibilipush]:", err) log.Errorln("[bilibilipush]:", err)
} }

View File

@ -28,7 +28,7 @@ func init() {
}).ApplySingle(ctxext.DefaultSingle).OnFullMatch("coser", zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByGroup). }).ApplySingle(ctxext.DefaultSingle).OnFullMatch("coser", zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByGroup).
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text("少女祈祷中......")) ctx.SendChain(message.Text("少女祈祷中......"))
data, err := web.ReqWith(coserURL, "GET", "", ua) data, err := web.GetDataWith(web.NewDefaultClient(), coserURL, "GET", "", ua)
if err != nil { if err != nil {
log.Println("err为:", err) log.Println("err为:", err)
} }

View File

@ -66,7 +66,7 @@ func init() {
cid := gjson.Get(g, `list.`+strconv.Itoa(i)+`.CardID`).String() cid := gjson.Get(g, `list.`+strconv.Itoa(i)+`.CardID`).String()
cachefile := cachedir + cid cachefile := cachedir + cid
if file.IsNotExist(cachefile) { if file.IsNotExist(cachefile) {
data, err := web.ReqWith( data, err := web.GetDataWith(web.NewDefaultClient(),
`https://res.fbigame.com/hs/v13/`+cid+`.png?auth_key=`+ `https://res.fbigame.com/hs/v13/`+cid+`.png?auth_key=`+
gjson.Get(g, `list.`+strconv.Itoa(i)+`.auth_key`).String(), gjson.Get(g, `list.`+strconv.Itoa(i)+`.auth_key`).String(),
reqconf[0], reqconf[1], reqconf[2]) reqconf[0], reqconf[1], reqconf[2])
@ -105,10 +105,10 @@ func init() {
} }
func sh(s string) string { func sh(s string) string {
data, err := web.ReqWith("https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2]) data, err := web.GetDataWith(web.NewDefaultClient(), "https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2])
if err == nil { if err == nil {
url := hs + para + "&hash=" + strings.SplitN(strings.SplitN(helper.BytesToString(data), `var hash = "`, 2)[1], `"`, 2)[0] + "&search=" + s url := hs + para + "&hash=" + strings.SplitN(strings.SplitN(helper.BytesToString(data), `var hash = "`, 2)[1], `"`, 2)[0] + "&search=" + s
r, err := web.ReqWith(url, reqconf[0], reqconf[1], reqconf[2]) r, err := web.GetDataWith(web.NewDefaultClient(), url, reqconf[0], reqconf[1], reqconf[2])
if err == nil { if err == nil {
return helper.BytesToString(r) return helper.BytesToString(r)
} }
@ -117,10 +117,10 @@ func sh(s string) string {
} }
func kz(s string) string { func kz(s string) string {
data, err := web.ReqWith("https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2]) data, err := web.GetDataWith(web.NewDefaultClient(), "https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2])
if err == nil { 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 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.ReqWith(url, reqconf[0], reqconf[1], reqconf[2]) r, err := web.GetDataWith(web.NewDefaultClient(), url, reqconf[0], reqconf[1], reqconf[2])
if err == nil { if err == nil {
return "base64://" + gjson.Get(helper.BytesToString(r), "img").String() return "base64://" + gjson.Get(helper.BytesToString(r), "img").String()
} }

View File

@ -70,7 +70,7 @@ func init() {
// soutuapi 请求api // soutuapi 请求api
func soutuapi(keyword string) (r resultjson, err error) { func soutuapi(keyword string) (r resultjson, err error) {
url := "https://api.pixivel.moe/v2/pixiv/illust/search/" + keyword + "?page=0" url := "https://api.pixivel.moe/v2/pixiv/illust/search/" + keyword + "?page=0"
data, err := web.ReqWith(url, "GET", "https://pixivel.moe/", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36") data, err := web.GetDataWith(web.NewTLS12Client(), url, "GET", "https://pixivel.moe/", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36")
if err != nil { if err != nil {
return return
} }

View File

@ -204,12 +204,12 @@ func getLevel(count int) int {
func initPic(picFile string) { func initPic(picFile string) {
if file.IsNotExist(picFile) { if file.IsNotExist(picFile) {
data, err := web.ReqWith(backgroundURL, "GET", referer, ua) data, err := web.GetDataWith(web.NewDefaultClient(), backgroundURL, "GET", referer, ua)
if err != nil { if err != nil {
log.Errorln("[score]", err) log.Errorln("[score]", err)
} }
picURL := gjson.Get(string(data), "pic").String() picURL := gjson.Get(string(data), "pic").String()
data, err = web.ReqWith(picURL, "GET", "", ua) data, err = web.GetDataWith(web.NewDefaultClient(), picURL, "GET", "", ua)
if err != nil { if err != nil {
log.Errorln("[score]", err) log.Errorln("[score]", err)
} }

View File

@ -11,7 +11,7 @@ import (
func init() { func init() {
engine.OnFullMatch("哄我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { engine.OnFullMatch("哄我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
data, err := web.ReqWith(chpURL, "GET", chpReferer, ua) data, err := web.GetDataWith(web.NewDefaultClient(), chpURL, "GET", chpReferer, ua)
if err != nil { if err != nil {
ctx.SendChain(message.Text("ERROR:", err)) ctx.SendChain(message.Text("ERROR:", err))
return return

View File

@ -11,7 +11,7 @@ import (
func init() { func init() {
engine.OnFullMatch("来碗毒鸡汤").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { engine.OnFullMatch("来碗毒鸡汤").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
data, err := web.ReqWith(duURL, "GET", duReferer, ua) data, err := web.GetDataWith(web.NewDefaultClient(), duURL, "GET", duReferer, ua)
if err != nil { if err != nil {
ctx.SendChain(message.Text("ERROR:", err)) ctx.SendChain(message.Text("ERROR:", err))
return return

View File

@ -11,7 +11,7 @@ import (
func init() { func init() {
engine.OnFullMatch("发个朋友圈").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { engine.OnFullMatch("发个朋友圈").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
data, err := web.ReqWith(pyqURL, "GET", pyqReferer, ua) data, err := web.GetDataWith(web.NewDefaultClient(), pyqURL, "GET", pyqReferer, ua)
if err != nil { if err != nil {
ctx.SendChain(message.Text("ERROR:", err)) ctx.SendChain(message.Text("ERROR:", err))
return return

View File

@ -12,7 +12,7 @@ import (
func init() { func init() {
engine.OnFullMatch("来碗绿茶").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { engine.OnFullMatch("来碗绿茶").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
data, err := web.ReqWith(chayiURL, "GET", loveliveReferer, ua) data, err := web.GetDataWith(web.NewDefaultClient(), chayiURL, "GET", loveliveReferer, ua)
if err != nil { if err != nil {
ctx.SendChain(message.Text("ERROR:", err)) ctx.SendChain(message.Text("ERROR:", err))
return return
@ -22,7 +22,7 @@ func init() {
}) })
engine.OnFullMatch("渣我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { engine.OnFullMatch("渣我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
data, err := web.ReqWith(ganhaiURL, "GET", loveliveReferer, ua) data, err := web.GetDataWith(web.NewDefaultClient(), ganhaiURL, "GET", loveliveReferer, ua)
if err != nil { if err != nil {
ctx.SendChain(message.Text("ERROR:", err)) ctx.SendChain(message.Text("ERROR:", err))
return return

View File

@ -14,7 +14,7 @@ import (
func init() { func init() {
engine.OnFullMatch("讲个段子").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { engine.OnFullMatch("讲个段子").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
data, err := web.ReqWith(yduanziURL, "POST", yduanziReferer, ua) data, err := web.GetDataWith(web.NewDefaultClient(), yduanziURL, "POST", yduanziReferer, ua)
if err != nil { if err != nil {
ctx.SendChain(message.Text("ERROR:", err)) ctx.SendChain(message.Text("ERROR:", err))
return return

View File

@ -2,7 +2,6 @@
package vtbquotation package vtbquotation
import ( import (
"crypto/tls"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
@ -22,6 +21,7 @@ import (
control "github.com/FloatTech/zbputils/control" control "github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/file" "github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/img/text" "github.com/FloatTech/zbputils/img/text"
"github.com/FloatTech/zbputils/web"
"github.com/FloatTech/zbputils/control/order" "github.com/FloatTech/zbputils/control/order"
@ -255,14 +255,7 @@ func init() {
func initRecord(recordFile, recordURL string) { func initRecord(recordFile, recordURL string) {
if file.IsNotExist(recordFile) { if file.IsNotExist(recordFile) {
transport := http.Transport{ client := web.NewTLS12Client()
TLSClientConfig: &tls.Config{
MaxVersion: tls.VersionTLS12,
},
}
client := &http.Client{
Transport: &transport,
}
req, _ := http.NewRequest("GET", recordURL, nil) req, _ := http.NewRequest("GET", recordURL, nil)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded") req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0") req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0")

View File

@ -24,7 +24,7 @@ func init() {
Help: "wangyiyun \n- 来份网易云热评", Help: "wangyiyun \n- 来份网易云热评",
}).OnFullMatch("来份网易云热评").SetBlock(true).Limit(ctxext.LimitByUser). }).OnFullMatch("来份网易云热评").SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
data, err := web.ReqWith(wangyiyunURL, "GET", wangyiyunReferer, ua) data, err := web.GetDataWith(web.NewDefaultClient(), wangyiyunURL, "GET", wangyiyunReferer, ua)
if err != nil { if err != nil {
ctx.SendChain(message.Text("ERROR:", err)) ctx.SendChain(message.Text("ERROR:", err))
return return