Merge pull request #58 from tdf1939/master

炉石插件
This commit is contained in:
源文雨 2021-08-27 15:47:21 +08:00 committed by GitHub
commit 820daa7b1e
3 changed files with 108 additions and 2 deletions

View File

@ -48,8 +48,8 @@
- [x] 设置欢迎语[欢迎~]
- [x] 在MM月dd日的hh点mm分时(用http://url)提醒大家xxx
- [x] 在MM月[每周|周几]的hh点mm分时(用http://url)提醒大家xxx
- [x] 取消在MM月dd日的hh点mm分的提醒
- [x] 取消在MM月[每周|周几]的hh点mm分的提醒
- [x] 取消在MM月dd日的hh点mm分的提醒
- [x] 取消在MM月[每周|周几]的hh点mm分的提醒
- [x] 列出所有提醒
- [x] 翻牌
- [x] [开启|关闭]入群验证
@ -114,6 +114,10 @@
- **minecraft** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_minecraft"`
- [x] 具体指令看代码
- 注:此功能实现依赖[MCSManager](https://github.com/Suwings/MCSManager)项目对服务器的管理apimc服务器如果没有在该管理平台部署此功能无效
- **炉石** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs"`
- [x] 搜卡[xxxx]
- [x] [卡组代码xxx]
- 注更多搜卡指令参数https://hs.fbigame.com/misc/searchhelp
- **TODO...**
## 使用方法

View File

@ -22,6 +22,7 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_music" // 点歌
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_omikuji" // 浅草寺求签
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_shindan" // 测定
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs" // 炉石
// b站相关
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili" // 查询b站用户信息

101
plugin_hs/run.go Normal file
View File

@ -0,0 +1,101 @@
package hs
import (
"fmt"
"os"
"strconv"
"strings"
"github.com/imroc/req"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
var header = req.Header{
"user-agent": `Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Mobile Safari/537.36`,
"referer": `https://hs.fbigame.com`,
}
func init() {
zero.OnRegex(`^搜卡(.+)$`).
SetBlock(true).SetPriority(20).Handle(func(ctx *zero.Ctx) {
List := ctx.State["regex_matched"].([]string)[1]
g := sh(List)
im, _ := req.Get(`https://res.fbigame.com/hs/v13/`+
gjson.Get(g, `list.0.CardID`).String()+
`.png?auth_key=`+
gjson.Get(g, `list.0.auth_key`).String(), header)
im.ToFile("data/image/1.png")
file, _ := os.Open("data/image/1.png")
sg, _ := req.Post("https://pic.sogou.com/pic/upload_pic.jsp", req.FileUpload{
File: file,
FieldName: "image", // FieldName 是表单字段名
FileName: "avatar.png", // Filename 是要上传的文件的名称我们使用它来猜测mimetype并将其上传到服务器上
})
var tx string
t := int(gjson.Get(g, `list.#`).Int())
if t == 0 {
ctx.SendChain(message.Text("查询为空!"))
return
}
for i := 0; i < t && i < 10; i++ {
tx += strconv.Itoa(i+1) + ". 法力:" +
gjson.Get(g, `list.`+strconv.Itoa(i)+`.COST`).String() +
" " +
gjson.Get(g, `list.`+strconv.Itoa(i)+`.CARDNAME`).String() +
"\n"
}
ctx.SendChain(
message.Image(sg.String()),
message.Text(tx),
)
})
//卡组
zero.OnRegex(`^[\s\S]*?(AAE[a-zA-Z0-9/\+=]{70,})[\s\S]*$`).
SetBlock(true).SetPriority(20).Handle(func(ctx *zero.Ctx) {
fmt.Print("成功")
List := ctx.State["regex_matched"].([]string)[1]
ctx.SendChain(
message.Image(kz(List)),
)
})
}
func sh(s string) string {
var hs = `https://hs.fbigame.com/ajax.php`
h, _ := req.Get("https://hs.fbigame.com", header)
var param = req.Param{
"mod": `get_cards_list`,
"mode": `-1`,
"extend": `-1`,
"mutil_extend": ``,
"hero": `-1`,
"rarity": `-1`,
"cost": `-1`,
"mutil_cost": ``,
"techlevel": `-1`,
"type": `-1`,
"collectible": `-1`,
"isbacon": `-1`,
"page": `1`,
"search_type": `1`,
"deckmode": "normal",
"hash": strings.SplitN(strings.SplitN(h.String(), `var hash = "`, 2)[1], `"`, 2)[0],
}
r, _ := req.Get(hs, header, param, req.Param{"search": s})
return r.String()
}
func kz(s string) string {
h, _ := req.Get("https://hs.fbigame.com")
param := req.Param{
"mod": `general_deck_image`,
"deck_code": s,
"deck_text": ``,
"hash": strings.SplitN(strings.SplitN(h.String(), `var hash = "`, 2)[1], `"`, 2)[0],
}
r, _ := req.Get(`https://hs.fbigame.com/ajax.php`, param, h.Request().Header)
im := gjson.Get(r.String(), "img").String()
return `base64://` + im
}