Update Instance.ts

This commit is contained in:
Nofated 2023-01-19 00:01:01 +08:00 committed by GitHub
parent 37022d8f33
commit 7cc5e331de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 7 deletions

View File

@ -36,6 +36,7 @@ export default class Instance {
private readonly log: Logger;
private tgBot: Telegram;
private tgUser: Telegram;
private oicq: OicqClient;
private _ownerChat: TelegramChat;
@ -110,8 +111,9 @@ export default class Instance {
this._ownerChat = await this.tgBot.getChat(this.owner);
}
else {
this.log.debug('正在登录 TG UserBot /// skip by Nofated095');
this.log.info('TG UserBot 登录完成 /// skip by Nofated095');
this.log.debug('正在登录 TG UserBot');
this.tgUser = await Telegram.connect(this._userSessionId);
this.log.info('TG UserBot 登录完成');
this._ownerChat = await this.tgBot.getChat(this.owner);
this.log.debug('正在登录 OICQ');
this.oicq = await OicqClient.create({
@ -138,7 +140,7 @@ export default class Instance {
});
this.log.info('OICQ 登录完成');
}
this.statusReportController = new StatusReportController(this, this.tgBot, this.oicq);
this.statusReportController = new StatusReportController(this, this.tgBot, this.tgUser, this.oicq);
this.forwardPairs = await ForwardPairs.load(this.id, this.oicq, this.tgBot);
this.setupCommands()
.then(() => this.log.info('命令设置成功'))
@ -148,13 +150,13 @@ export default class Instance {
}
this.oicqErrorNotifyController = new OicqErrorNotifyController(this, this.oicq);
this.requestController = new RequestController(this, this.tgBot, this.oicq);
this.configController = new ConfigController(this, this.tgBot, this.oicq);
this.deleteMessageController = new DeleteMessageController(this, this.tgBot, this.oicq);
this.inChatCommandsController = new InChatCommandsController(this, this.tgBot, this.oicq);
this.configController = new ConfigController(this, this.tgBot, this.tgUser, this.oicq);
this.deleteMessageController = new DeleteMessageController(this, this.tgBot, this.tgUser, this.oicq);
this.inChatCommandsController = new InChatCommandsController(this, this.tgBot, this.tgUser, this.oicq);
if (this.workMode === 'group') {
this.hugController = new HugController(this, this.tgBot, this.oicq);
}
this.forwardController = new ForwardController(this, this.tgBot, this.oicq);
this.forwardController = new ForwardController(this, this.tgBot, this.tgUser, this.oicq);
if (this.workMode === 'group') {
// 希望那个 /q 也被转发
this.quotLyController = new QuotLyController(this, this.tgBot, this.oicq);
@ -241,6 +243,10 @@ export default class Instance {
return this.tgBot.me;
}
get userMe() {
return this.tgUser.me;
}
get ownerChat() {
return this._ownerChat;
}