From 63237bc1128c8ceebd3db731e6f17596da4a27ac Mon Sep 17 00:00:00 2001 From: "Wesley F. Young" Date: Sat, 10 Aug 2024 20:43:50 +0800 Subject: [PATCH 1/3] refactor: rename postEvent -> emitEvent to prevent ambiguity --- src/onebot/network/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/onebot/network/index.ts b/src/onebot/network/index.ts index f357dab2..3c378613 100644 --- a/src/onebot/network/index.ts +++ b/src/onebot/network/index.ts @@ -18,7 +18,7 @@ export class OB11NetworkManager { return this.adapters; } - async PostEvent(event: OB11BaseEvent) { + async emitEvent(event: OB11BaseEvent) { // Mlikiowa V2.0.0 Refactor Todo return Promise.all(this.adapters.map(adapter => adapter.onEvent(event))); } From 9feab4bc79adb587deb5156b882b875431589440 Mon Sep 17 00:00:00 2001 From: "Wesley F. Young" Date: Sat, 10 Aug 2024 20:53:29 +0800 Subject: [PATCH 2/3] chore: make BaseAction abstract --- src/onebot/action/BaseAction.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/onebot/action/BaseAction.ts b/src/onebot/action/BaseAction.ts index 90990eb2..719bff31 100644 --- a/src/onebot/action/BaseAction.ts +++ b/src/onebot/action/BaseAction.ts @@ -5,7 +5,7 @@ import Ajv, { ErrorObject, ValidateFunction } from 'ajv'; import { NapCatCore } from '@/core'; import { NapCatOneBot11Adapter } from '../main'; -class BaseAction { +abstract class BaseAction { actionName: ActionName = ActionName.Unknown; CoreContext: NapCatCore; private validate: undefined | ValidateFunction = undefined; @@ -64,9 +64,7 @@ class BaseAction { } } - protected async _handle(payload: PayloadType): Promise { - throw `pleas override ${this.actionName} _handle`; - } + abstract _handle(payload: PayloadType): PromiseLike; } export default BaseAction; From 2c14281168aa37df373e25988ff5634487f29385 Mon Sep 17 00:00:00 2001 From: "Wesley F. Young" Date: Sat, 10 Aug 2024 20:56:46 +0800 Subject: [PATCH 3/3] refactor: specify the arg type of onInputStatusPush --- src/core/listeners/NodeIKernelMsgListener.ts | 22 ++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/core/listeners/NodeIKernelMsgListener.ts b/src/core/listeners/NodeIKernelMsgListener.ts index 3b2db538..14dc0ebe 100644 --- a/src/core/listeners/NodeIKernelMsgListener.ts +++ b/src/core/listeners/NodeIKernelMsgListener.ts @@ -105,7 +105,16 @@ export interface IKernelMsgListener { onImportOldDbProgressUpdate(importOldDbMsgNotifyInfo: unknown): void; - onInputStatusPush(inputStatusInfo: unknown): void; + onInputStatusPush(inputStatusInfo: { + chatType: number; + eventType: number; + fromUin: string; + interval: string; + showTime: string; + statusText: string; + timestamp: string; + toUin: string; + }): void; onKickedOffLine(kickedInfo: unknown): void; @@ -341,7 +350,16 @@ export class MsgListener implements IKernelMsgListener { } - onInputStatusPush(inputStatusInfo: unknown) { + onInputStatusPush(inputStatusInfo: { + chatType: number; + eventType: number; + fromUin: string; + interval: string; + showTime: string; + statusText: string; + timestamp: string; + toUin: string; + }) { }