新增登录验证码自动获取ticket

Signed-off-by: touchscale <11134128+touchscale_admin@user.noreply.gitee.com>
This commit is contained in:
touchscale 2023-05-14 21:20:35 +00:00 committed by Gitee
parent d208a5758a
commit 7266fea299
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 27 additions and 1 deletions

View File

@ -73,13 +73,18 @@ export default class loginEvent extends EventListener {
type: 'list', type: 'list',
name: 'type', name: 'type',
message: '触发滑动验证需要获取ticket通过验证请选择获取方式:', message: '触发滑动验证需要获取ticket通过验证请选择获取方式:',
choices: ['1.手动获取ticket', '2.滑动验证app请求码获取'] choices: ['0.自动获取ticket', '1.手动获取ticket', '2.滑动验证app请求码获取']
} }
]) ])
await common.sleep(200) await common.sleep(200)
let ticket 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请求码获取') { if (ret.type == '2.滑动验证app请求码获取') {
ticket = await this.requestCode(event.url) ticket = await this.requestCode(event.url)
if (!ticket) console.log('\n请求错误返回手动获取ticket方式\n') if (!ticket) console.log('\n请求错误返回手动获取ticket方式\n')
@ -103,6 +108,27 @@ export default class loginEvent extends EventListener {
this.client.submitSlider(ticket.trim()) 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) { async requestCode (url) {
let txhelper = { let txhelper = {
url: url.replace('ssl.captcha.qq.com', 'txhelper.glitch.me') url: url.replace('ssl.captcha.qq.com', 'txhelper.glitch.me')