mirror of https://github.com/Nofated095/Q2TG.git
feat: 发送密码后自动删除
This commit is contained in:
parent
a59c02ae64
commit
081ecde6b7
|
@ -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(`登录成功`);
|
||||
|
|
|
@ -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` +
|
||||
|
|
Loading…
Reference in New Issue