From c6009fc935478e91042a8576293730322bb6c19b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=8F=B6?= <1936472877@qq.com> Date: Mon, 23 Dec 2024 23:28:15 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=89=AB=E7=A0=81?= =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/QRLogin.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/apps/QRLogin.js b/apps/QRLogin.js index 676531d..9fbdebe 100644 --- a/apps/QRLogin.js +++ b/apps/QRLogin.js @@ -14,7 +14,7 @@ const rule = { QRLoginTips: { reg: App.getReg(baseReg), fnc: async (e) => { - const tips = '将使用steamApp扫码二维码进行登录, 登录完成后机器人可获得对应账号的access_token并保存, 不会同时绑定对应的steamId, 拥有access_token后可执行各种隐私操作, 请在**特别信任**的机器人上进行扫码登录, 如果确认需要扫码登录, 请继续发送\n#steam确认扫码登录' + const tips = '将使用steamApp扫码二维码进行登录, 登录完成后机器人可获得对应账号的access_token并保存, 不会同时绑定对应的steamId, 拥有access_token后可执行各种隐私操作, 请在**特别信任**的机器人上进行扫码登录, 如果确认需要扫码登录, 请先打开steamApp进入扫码界面并继续发送\n#steam确认扫码登录' await e.reply(tips) verify[e.user_id] = true return true @@ -24,20 +24,23 @@ const rule = { reg: App.getReg(`确认${baseReg}`), fnc: async (e) => { if (!verify[e.user_id]) return true - delete verify[e.user_id] const session = await api.IAuthenticationService.BeginAuthSessionViaQR() const qrcode = (await QRCode.toDataURL(session.challenge_url)).replace('data:image/png;base64,', 'base64://') - await e.reply(['请使用30秒内使用steamApp扫描二维码进行登录', segment.image(qrcode)]) + await App.reply(e, ['请使用30秒内使用steamApp扫描二维码进行登录', segment.image(qrcode)], { + recallMsg: 30, + quote: true + }) for (let i = 0; i < 6; i++) { await new Promise(resolve => setTimeout(resolve, 1000 * 5)) - const qrcodeRes = await api.IAuthenticationService.PollAuthSessionStatus(session.client_id, session.request_id) + const qrcodeRes = await api.IAuthenticationService.PollAuthSessionStatus(session.client_id, session.request_id).catch(() => {}) if (qrcodeRes.access_token) { const dbRes = await db.TokenTableAddData(e.user_id, qrcodeRes.access_token, qrcodeRes.refresh_token) - console.log(dbRes) - await e.reply(`登录成功\nsteamId: ${dbRes.steamId}\n登录名: ${qrcodeRes.account_name.replace(/^(.)(.*)(.)$/, '$1***$3')}`) - break + await e.reply(`登录成功\nsteamId: ${dbRes.steamId}\n登录名: ${qrcodeRes.account_name.replace(/^(.)(.*)(.)$/, '$1***$3')}\n需要切换到对应的steamId才会生效`) + return true } } + await e.reply('登录超时~请重新触发指令') + return true } } }