From b970a83834efa5aff662205e879cf87205962827 Mon Sep 17 00:00:00 2001 From: Clansty Date: Fri, 13 Dec 2024 00:55:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=9D=E5=A7=8B=E5=8C=96=E6=9C=AA?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=9C=A8=20/alive=20=E4=B8=AD=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/src/constants/commands.ts | 25 +++++++++++++------- main/src/controllers/AliveCheckController.ts | 2 +- main/src/models/Instance.ts | 2 ++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/main/src/constants/commands.ts b/main/src/constants/commands.ts index bdc4a70..2b2f703 100644 --- a/main/src/constants/commands.ts +++ b/main/src/constants/commands.ts @@ -7,8 +7,24 @@ const preSetupCommands = [ }), ]; +const commonPrivateCommands = [ + new Api.BotCommand({ + command: 'login', + description: '当 QQ 处于下线状态时,使用此命令重新登录 QQ', + }), + new Api.BotCommand({ + command: 'flags', + description: 'WARNING: EXPERIMENTAL FEATURES AHEAD!', + }), + new Api.BotCommand({ + command: 'alive', + description: '状态信息', + }), +] + // 这里的 group 指群组模式,Private 指在与机器人的私聊会话中 const groupPrivateCommands = [ + ...commonPrivateCommands, new Api.BotCommand({ command: 'add', description: '添加新的群转发', @@ -16,6 +32,7 @@ const groupPrivateCommands = [ ]; const personalPrivateCommands = [ + ...commonPrivateCommands, new Api.BotCommand({ command: 'addfriend', description: '添加新的好友转发', @@ -24,14 +41,6 @@ const personalPrivateCommands = [ command: 'addgroup', description: '添加新的群转发', }), - new Api.BotCommand({ - command: 'login', - description: '当 QQ 处于下线状态时,使用此命令重新登录 QQ', - }), - new Api.BotCommand({ - command: 'flags', - description: 'WARNING: EXPERIMENTAL FEATURES AHEAD!', - }), ]; // 服务器零号实例的管理员 diff --git a/main/src/controllers/AliveCheckController.ts b/main/src/controllers/AliveCheckController.ts index 93273fb..82ab7d4 100644 --- a/main/src/controllers/AliveCheckController.ts +++ b/main/src/controllers/AliveCheckController.ts @@ -41,7 +41,7 @@ export default class AliveCheckController { const tgUserName = (tgUser.me.username || tgUser.me.usernames.length) ? '@' + (tgUser.me.username || tgUser.me.usernames[0].username) : tgUser.me.firstName; messageParts.push([ - `Instance #${instance.id}`, + `Instance #${instance.id} (${instance.workMode}) ${instance.isInit ? '' : '初始化未完成'}`, `QQ ${instance.qqUin} (${oicq.constructor.name})\t` + `${boolToStr(await oicq.isOnline())}`, diff --git a/main/src/models/Instance.ts b/main/src/models/Instance.ts index 43b56fc..79d3112 100644 --- a/main/src/models/Instance.ts +++ b/main/src/models/Instance.ts @@ -42,6 +42,7 @@ export default class Instance { public tgBot: Telegram; public tgUser: Telegram; public oicq: QQClient; + public isInit = false; private _ownerChat: TelegramChat; @@ -165,6 +166,7 @@ export default class Instance { this.hugController = new HugController(this, this.tgBot, this.oicq); } this.fileAndFlashPhotoController = new FileAndFlashPhotoController(this, this.tgBot, this.oicq); + this.isInit = true; })() .then(() => this.log.info('初始化已完成')); }