From 5b7f241d61361c6604e5af9ddffd898ccf32b326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Thu, 14 Nov 2024 10:34:38 +0800 Subject: [PATCH] refactor: Shell Init --- src/onebot/index.ts | 5 +---- src/shell/napcat.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/onebot/index.ts b/src/onebot/index.ts index 6221d434..1cd65819 100644 --- a/src/onebot/index.ts +++ b/src/onebot/index.ts @@ -72,11 +72,8 @@ export class NapCatOneBot11Adapter { }; this.actions = createActionMap(this, core); this.networkManager = new OB11NetworkManager(); - // this.registerNative(core, context).catch(e => this.context.logger.logWarn.bind(this.context.logger)('初始化Native失败', e)).then(); - this.InitOneBot() - .catch(e => this.context.logger.logError.bind(this.context.logger)('初始化OneBot失败', e)); - } + async InitOneBot() { const selfInfo = this.core.selfInfo; const ob11Config = this.configLoader.configData; diff --git a/src/shell/napcat.ts b/src/shell/napcat.ts index ff5f59d3..93655418 100644 --- a/src/shell/napcat.ts +++ b/src/shell/napcat.ts @@ -232,7 +232,7 @@ export async function NCoreInitShell() { logger.log(`可用于快速登录的 QQ:\n${historyLoginList .map((u, index) => `${index + 1}. ${u.uin} ${u.nickName}`) .join('\n') - }`); + }`); } loginService.getQRCodePicture(); } @@ -327,8 +327,12 @@ export class NapCatShell { }; this.core = new NapCatCore(this.context, selfInfo); - // TODO: complete ob11 adapter initialization logic - new NapCatOneBot11Adapter(this.core, this.context, pathWrapper); + + + } + async InitNapCat() { + new NapCatOneBot11Adapter(this.core, this.context, this.context.pathWrapper).InitOneBot() + .catch(e => this.context.logger.logError.bind(this.context.logger)('初始化OneBot失败', e)); } }