-
Notifications
You must be signed in to change notification settings - Fork 19
/
王者战力_Bncr.js
94 lines (90 loc) · 2.88 KB
/
王者战力_Bncr.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**作者
* @author 薛定谔的大灰机
* @name 王者战力
* @origin 大灰机
* @version 1.0.2
* @description 查询王者战力
* @platform tgBot qq ssh HumanTG wxQianxun wxXyo
* @rule ^王者战力$
* @rule ^战力$
* @rule ^([^ \n]+)战力$
* @rule ^战力([^ \n]+)$
* @rule ^战力([^ \n]+)([^ \n]+)$
* @admin false
* @disable false
*/
const mo = require('./mod/subassembly') // 此脚本依赖仓库模块,请拉取全部文件
const axios = require("axios")
module.exports = async s => {
let msg_wait = 2
types = [
"aqq",
"awx",
"iqq",
"iwx",
]
let api = `https://www.sapi.run/hero/select.php`
if (!(hero = s.param(1))) {
msgid_ids = await s.reply(`输入英雄名`)
if (!(hero = await talks())) return
}
if (!(type = s.param(2))) {
msgid_ids = await s.reply(`输入序号:\n1:安卓QQ\n2:安卓微信\n3:苹果QQ\n4:苹果微信`)
if (!(type = types[(await talks()) - 1])) return
}
s.delMsg(s.getMsgId())
let url = `${api}?hero=${encodeURI(hero)}&type=${type}`
let data = (await get(url)).data
// console.log(data)
if (data && data.code == 200) {
msg = `英雄名称:${data.data.alias}`
msg += `\n平台大区:${data.data.platform}`
msg += `\n最低县标:${data.data.area}:${data.data.areaPower}`
msg += `\n最低市标:${data.data.city}:${data.data.cityPower}`
msg += `\n最低省标:${data.data.province}:${data.data.provincePower}`
msg += `\n最低国标:${data.data.guobiao}`
msg += `\n数据更新:${data.data.updatetime}`
path = data.data.photo
} else {
msg = data.msg
path = ``
};
// console.log(msg);
await mo.reply(s, {
type: `image`,
msg: msg,
path: {
path: path,
suffix: `jpg`,
},
})
async function talks() {
let content = await s.waitInput(async (s) => {
let msg = s.getMsg();
if (msg === 'q') {
} else if (!msg || (((await get(`${api}?hero=${encodeURI(hero || msg)}&type=aqq`)).data.code) == 400)) {
s.delMsg(await s.reply('错误'), { wait: msg_wait })
// return 'again'
return
}
}, 30);
if (content === null) return s.delMsg(await s.reply('超时已退出'), msgid_ids, { wait: msg_wait });
if (content.getMsg() === 'q') return s.delMsg(await s.reply('已退出'), msgid_ids, content.getMsgId(), { wait: msg_wait });
//撤回用户发的信息
s.delMsg(content.getMsgId(), msgid_ids);
return content.getMsg()
}
}
// get请求
async function get(url) {
var data = await axios({
url: url,
method: "get",
});
console.log(url);
if (data.status === 200) {
return data
} else {
return
}
}