From 7266fea29914a74e62c71dc85be42147fdaff051 Mon Sep 17 00:00:00 2001 From: touchscale <11134128+touchscale_admin@user.noreply.gitee.com> Date: Sun, 14 May 2023 21:20:35 +0000 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=99=BB=E5=BD=95=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E7=A0=81=E8=87=AA=E5=8A=A8=E8=8E=B7=E5=8F=96ticket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: touchscale <11134128+touchscale_admin@user.noreply.gitee.com> --- lib/events/login.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/events/login.js b/lib/events/login.js index 8f5bb9f..ce3d9b7 100644 --- a/lib/events/login.js +++ b/lib/events/login.js @@ -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')