From a804f90b9c268faaa3982f33fd71335acd560392 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: Sat, 7 Sep 2024 22:58:29 +0800 Subject: [PATCH] refactor: adapter --- src/core/adapters/NodeIDependsAdapter.ts | 9 ++++----- src/core/entities/adapter.ts | 11 +++++++++++ src/shell/napcat.ts | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 src/core/entities/adapter.ts diff --git a/src/core/adapters/NodeIDependsAdapter.ts b/src/core/adapters/NodeIDependsAdapter.ts index dbf280e3..87baf540 100644 --- a/src/core/adapters/NodeIDependsAdapter.ts +++ b/src/core/adapters/NodeIDependsAdapter.ts @@ -1,9 +1,8 @@ +import { MsfChangeReasonType, MsfStatusType } from "../entities/adapter"; + export class NodeIDependsAdapter { - onMSFStatusChange(arg1: number, arg2: number) { - // console.log(arg1, arg2); - // if (arg1 == 2 && arg2 == 2) { - // log("NapCat丢失网络连接,请检查网络") - // } + onMSFStatusChange(statusType: MsfStatusType, changeReasonType: MsfChangeReasonType) { + } onMSFSsoError(args: unknown) { diff --git a/src/core/entities/adapter.ts b/src/core/entities/adapter.ts new file mode 100644 index 00000000..3f0113ea --- /dev/null +++ b/src/core/entities/adapter.ts @@ -0,0 +1,11 @@ +export enum MsfStatusType { + KUNKNOWN, + KDISCONNECTED, + KCONNECTED +} +export enum MsfChangeReasonType { + KUNKNOWN, + KUSERLOGININ, + KUSERLOGINOUT, + KAUTO +} \ No newline at end of file diff --git a/src/shell/napcat.ts b/src/shell/napcat.ts index 4beeded5..1a2a704b 100644 --- a/src/shell/napcat.ts +++ b/src/shell/napcat.ts @@ -229,7 +229,7 @@ export async function NCoreInitShell() { sessionConfig, new NodeIDependsAdapter(), new NodeIDispatcherAdapter(), - sessionListener as any, + sessionListener, ); try { session.startNT(0);