新增登录验证码自动获取ticket
Signed-off-by: touchscale <11134128+touchscale_admin@user.noreply.gitee.com>
This commit is contained in:
parent
d208a5758a
commit
7266fea299
|
@ -73,13 +73,18 @@ export default class loginEvent extends EventListener {
|
|||
type: 'list',
|
||||
name: 'type',
|
||||
message: '触发滑动验证,需要获取ticket通过验证,请选择获取方式:',
|
||||
choices: ['1.手动获取ticket', '2.滑动验证app请求码获取']
|
||||
choices: ['0.自动获取ticket', '1.手动获取ticket', '2.滑动验证app请求码获取']
|
||||
}
|
||||
])
|
||||
|
||||
await common.sleep(200)
|
||||
let ticket
|
||||
|
||||
if (ret.type == '0.自动获取ticket') {
|
||||
ticket = await this.getTicket(event.url)
|
||||
if (!ticket) console.log('\n请求错误,返回手动获取ticket方式\n')
|
||||
}
|
||||
|
||||
if (ret.type == '2.滑动验证app请求码获取') {
|
||||
ticket = await this.requestCode(event.url)
|
||||
if (!ticket) console.log('\n请求错误,返回手动获取ticket方式\n')
|
||||
|
@ -103,6 +108,27 @@ export default class loginEvent extends EventListener {
|
|||
this.client.submitSlider(ticket.trim())
|
||||
}
|
||||
|
||||
async getTicket (url) {
|
||||
let req = `https://hlhs-nb.cn/captcha/slider?key=${Bot.uin}`
|
||||
await fetch(req, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ url })
|
||||
})
|
||||
|
||||
console.log('\n----请打开下方链接并在2分钟内进行验证----')
|
||||
console.log(`${logger.green(req)}\n----完成后将自动进行登录----`)
|
||||
|
||||
for (let i = 0; i < 40; i++) {
|
||||
let res = await fetch(req, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ submit: Bot.uin })
|
||||
})
|
||||
res = await res.json()
|
||||
if (res.data?.ticket) return res.data.ticket
|
||||
await common.sleep(3000)
|
||||
}
|
||||
}
|
||||
|
||||
async requestCode (url) {
|
||||
let txhelper = {
|
||||
url: url.replace('ssl.captcha.qq.com', 'txhelper.glitch.me')
|
||||
|
|
Loading…
Reference in New Issue