mirror of https://github.com/Nofated095/Q2TG.git
Update SetupController.ts
This commit is contained in:
parent
5060ba5189
commit
1273fb8a97
|
@ -15,9 +15,8 @@ export default class SetupController {
|
|||
private readonly setupService: SetupService;
|
||||
private readonly log: Logger;
|
||||
private isInProgress = false;
|
||||
private waitForFinishCallbacks: Array<(ret: { tgUser: Telegram, oicq: OicqClient }) => unknown> = [];
|
||||
private waitForFinishCallbacks: Array<(ret: { oicq: OicqClient }) => unknown> = [];
|
||||
// 创建的 UserBot
|
||||
private tgUser: Telegram;
|
||||
private oicq: OicqClient;
|
||||
|
||||
constructor(private readonly instance: Instance,
|
||||
|
@ -99,19 +98,20 @@ export default class SetupController {
|
|||
if (this.instance.userSessionId) {
|
||||
await this.setupService.informOwner('userSessionId 已经存在,跳过');
|
||||
}
|
||||
else
|
||||
try {
|
||||
const phoneNumber = await this.setupService.waitForOwnerInput('创建 Telegram UserBot,请输入你的手机号码(需要带国家区号,例如:+86)');
|
||||
await this.setupService.informOwner('正在登录,请稍候…');
|
||||
this.tgUser = await this.setupService.createUserBot(phoneNumber);
|
||||
this.instance.userSessionId = this.tgUser.sessionId;
|
||||
await this.setupService.informOwner(`登录成功`);
|
||||
}
|
||||
catch (e) {
|
||||
this.log.error('创建 UserBot 失败', e);
|
||||
this.isInProgress = false;
|
||||
throw e;
|
||||
}
|
||||
else {
|
||||
await this.setupService.informOwner(`UserBot 创建被跳过`);
|
||||
// try {
|
||||
// const phoneNumber = await this.setupService.waitForOwnerInput('创建 Telegram UserBot,请输入你的手机号码(需要带国家区号,例如:+86)');
|
||||
// await this.setupService.informOwner('正在登录,请稍候…');
|
||||
// this.tgUser = await this.setupService.createUserBot(phoneNumber);
|
||||
// this.instance.userSessionId = this.tgUser.sessionId;
|
||||
// await this.setupService.informOwner(`登录成功`);
|
||||
// }
|
||||
// catch (e) {
|
||||
// this.log.error('创建 UserBot 失败', e);
|
||||
// this.isInProgress = false;
|
||||
// throw e;
|
||||
// }
|
||||
}
|
||||
|
||||
private async finishSetup() {
|
||||
|
@ -119,13 +119,12 @@ export default class SetupController {
|
|||
this.isInProgress = false;
|
||||
await this.setupService.finishConfig();
|
||||
this.waitForFinishCallbacks.forEach(e => e({
|
||||
tgUser: this.tgUser,
|
||||
oicq: this.oicq,
|
||||
}));
|
||||
}
|
||||
|
||||
public waitForFinish() {
|
||||
return new Promise<{ tgUser: Telegram, oicq: OicqClient }>(resolve => {
|
||||
return new Promise<{ oicq: OicqClient }>(resolve => {
|
||||
this.waitForFinishCallbacks.push(resolve);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue