feat: oicq 掉线提醒

This commit is contained in:
Clansty 2022-04-09 17:56:36 +08:00
parent e870e6bff3
commit 991b1280a7
No known key found for this signature in database
GPG Key ID: 3A6BE8BAF2EDE134
2 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,11 @@
import Instance from '../models/Instance';
import OicqClient from '../client/OicqClient';
export default class OicqErrorNotifyController {
public constructor(private readonly instance: Instance,
private readonly oicq: OicqClient) {
oicq.on('system.offline', async ({ message }) => {
await instance.ownerChat.sendMessage(`<i>QQ 机器人掉线</i>\n${message}`);
});
}
}

View File

@ -16,6 +16,7 @@ import { Api } from 'telegram';
import commands from '../constants/commands';
import TelegramChat from '../client/TelegramChat';
import RequestController from '../controllers/RequestController';
import OicqErrorNotifyController from '../controllers/OicqErrorNotifyController';
export default class Instance {
private _owner = 0;
@ -37,6 +38,7 @@ export default class Instance {
public forwardPairs: ForwardPairs;
private setupController: SetupController;
private instanceManageController: InstanceManageController;
private oicqErrorNotifyController: OicqErrorNotifyController;
private requestController: RequestController;
private configController: ConfigController;
private deleteMessageController: DeleteMessageController;
@ -108,6 +110,7 @@ export default class Instance {
if (this.id === 0) {
this.instanceManageController = new InstanceManageController(this, this.tgBot);
}
this.oicqErrorNotifyController = new OicqErrorNotifyController(this, this.oicq);
this.requestController = new RequestController(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);