From adc366a959bc0fcc9140ed05d563b54403fbfc09 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: Sun, 25 Aug 2024 21:54:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?style:=20=E6=B8=85=E7=90=86=E4=B8=8D?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/framework/event-legacy.ts | 33 ++-------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/src/common/framework/event-legacy.ts b/src/common/framework/event-legacy.ts index c6ec3d2d..6aa6a13e 100644 --- a/src/common/framework/event-legacy.ts +++ b/src/common/framework/event-legacy.ts @@ -27,8 +27,7 @@ export class LegacyNTEventWrapper { } createProxyDispatch(ListenerMainName: string) { - // eslint-disable-next-line @typescript-eslint/no-this-alias - const current = this; + const dispatcherListenerFunc = this.dispatcherListener.bind(this); return new Proxy( {}, { @@ -36,7 +35,7 @@ export class LegacyNTEventWrapper { if (typeof target[prop] === 'undefined') { // 如果方法不存在,返回一个函数,这个函数调用existentMethod return (...args: any[]) => { - current.dispatcherListener.apply(current, [ListenerMainName, prop, ...args]).then(); + dispatcherListenerFunc(ListenerMainName, prop, ...args).then(); }; } // 如果方法存在,正常返回 @@ -54,8 +53,6 @@ export class LegacyNTEventWrapper { if (eventNameArr.length > 1) { const serviceName = 'get' + eventNameArr[0].replace('NodeIKernel', ''); const eventName = eventNameArr[1]; - //getNodeIKernelGroupListener,GroupService - //console.log('2', eventName); const services = (this.WrapperSession as unknown as eventType)[serviceName](); let event = services[eventName]; //重新绑定this @@ -207,7 +204,6 @@ export class LegacyNTEventWrapper { checker: checkerListener, func: (...args: any[]) => { complete++; - //console.log('func', ...args); retData = args as Parameters; if (complete >= waitTimes) { clearTimeout(Timeouter); @@ -311,28 +307,3 @@ export class LegacyNTEventWrapper { ); } } - -// 示例代码 快速创建事件 -// let NTEvent = new NTEventWrapper(); -// let TestEvent = NTEvent.CreatEventFunction<(force: boolean) => Promise>('NodeIKernelProfileLikeService/GetTest'); -// if (TestEvent) { -// TestEvent(true); -// } - -// 示例代码 快速创建监听Listener类 -// let NTEvent = new NTEventWrapper(); -// NTEvent.CreatListenerFunction('NodeIKernelMsgListener', 'core') - -// 调用接口 -//let NTEvent = new NTEventWrapper(); -//let ret = await NTEvent.CallNormalEvent<(force: boolean) => Promise, (data1: string, data2: number) => void>('NodeIKernelProfileLikeService/GetTest', 'NodeIKernelMsgListener/onAddSendMsg', 1, 3000, true); - -// 注册监听 解除监听 -// NTEventDispatch.RigisterListener('NodeIKernelMsgListener/onAddSendMsg','core',cb); -// NTEventDispatch.UnRigisterListener('NodeIKernelMsgListener/onAddSendMsg','core'); - -// let GetTest = NTEventDispatch.CreatEvent('NodeIKernelProfileLikeService/GetTest','NodeIKernelMsgListener/onAddSendMsg',Mode); -// GetTest('test'); - -// always模式 -// NTEventDispatch.CreatEvent('NodeIKernelProfileLikeService/GetTest','NodeIKernelMsgListener/onAddSendMsg',Mode,(...args:any[])=>{ console.log(args) }); From 8f465e376e908d7f768578004a38bf63e1e62f97 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: Sun, 25 Aug 2024 21:59:07 +0800 Subject: [PATCH 2/2] style: type --- src/common/utils/QQBasicInfo.ts | 2 -- src/onebot/types/message.ts | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/common/utils/QQBasicInfo.ts b/src/common/utils/QQBasicInfo.ts index 8125b614..f7501835 100644 --- a/src/common/utils/QQBasicInfo.ts +++ b/src/common/utils/QQBasicInfo.ts @@ -77,5 +77,3 @@ export class QQBasicInfoWrapper { return { appid: systemPlatform === 'linux' ? '537240795' : '537240709', qua: this.getQUAInternal() }; } } - -export let QQBasicInfo: QQBasicInfoWrapper | undefined; diff --git a/src/onebot/types/message.ts b/src/onebot/types/message.ts index e9a06612..25465dea 100644 --- a/src/onebot/types/message.ts +++ b/src/onebot/types/message.ts @@ -156,7 +156,7 @@ export interface OB11MessageCustomMusic { export interface OB11MessageJson { type: OB11MessageDataType.json; - data: { config: { token: string } } & any; + data: { config: { token: string }, data: string }; } export interface OB11MessageDice {