From 081ecde6b78c5264b3cd41c2771a1272208088fb Mon Sep 17 00:00:00 2001 From: Clansty Date: Sat, 26 Feb 2022 00:15:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8F=91=E9=80=81=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E5=90=8E=E8=87=AA=E5=8A=A8=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/SetupController.ts | 2 +- src/services/SetupService.ts | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/controllers/SetupController.ts b/src/controllers/SetupController.ts index 77b85ed..f33b1f1 100644 --- a/src/controllers/SetupController.ts +++ b/src/controllers/SetupController.ts @@ -88,7 +88,7 @@ export default class SetupController { [Button.text('二维码登录', true, true)], ]); if (isPasswordLogin === '密码登录') { - password = await this.setupService.waitForOwnerInput('请输入密码'); + password = await this.setupService.waitForOwnerInput('请输入密码', undefined, true); } this.oicq = await this.setupService.createOicq(uin, password, platform); await this.setupService.informOwner(`登录成功`); diff --git a/src/services/SetupService.ts b/src/services/SetupService.ts index f76d9a0..b96fd43 100644 --- a/src/services/SetupService.ts +++ b/src/services/SetupService.ts @@ -47,16 +47,17 @@ export default class SetupService { if (!this.owner) { throw new Error('应该不会运行到这里'); } - await this.owner.sendMessage({ message, buttons: buttons || Button.clear(), linkPreview: false }); + return await this.owner.sendMessage({ message, buttons: buttons || Button.clear(), linkPreview: false }); } - public async waitForOwnerInput(message?: string, buttons?: MarkupLike) { + public async waitForOwnerInput(message?: string, buttons?: MarkupLike, remove = false) { if (!this.owner) { throw new Error('应该不会运行到这里'); } message && await this.informOwner(message, buttons); - const { message: reply } = await this.owner.waitForInput(); - return reply; + const reply = await this.owner.waitForInput(); + remove && await reply.delete({ revoke: true }); + return reply.message; } public async createUserBot(phoneNumber: string) { @@ -66,7 +67,8 @@ export default class SetupService { return await Telegram.create({ phoneNumber, password: async (hint?: string) => { - return await this.waitForOwnerInput(`请输入你的二步验证密码${hint ? '\n密码提示:' + hint : ''}`); + return await this.waitForOwnerInput( + `请输入你的二步验证密码${hint ? '\n密码提示:' + hint : ''}`, undefined, true); }, phoneCode: async (isCodeViaApp?: boolean) => { await this.informOwner(`请输入你${isCodeViaApp ? ' Telegram APP 中' : '手机上'}收到的验证码\n` +