diff --git a/package.json b/package.json index c537e5dc7..406766615 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,8 @@ "@eslint/js": "^9.14.0", "@log4js-node/log4js-api": "^1.0.2", "@napneko/nap-proto-core": "^0.0.4", - "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-typescript": "^12.1.2", + "@rollup/plugin-node-resolve": "^16.0.0", "@types/cors": "^2.8.17", "@sinclair/typebox": "^0.34.9", "@types/express": "^5.0.0", diff --git a/src/onebot/api/quick-action.ts b/src/onebot/api/quick-action.ts index 9fc61eb4e..5a66c858a 100644 --- a/src/onebot/api/quick-action.ts +++ b/src/onebot/api/quick-action.ts @@ -18,8 +18,8 @@ import { ContextMode, createContext, normalize } from '@/onebot/action/msg/SendM import { isNull } from '@/common/helper'; export class OneBotQuickActionApi { - private obContext: NapCatOneBot11Adapter; - private core: NapCatCore; + obContext: NapCatOneBot11Adapter; + core: NapCatCore; constructor(obContext: NapCatOneBot11Adapter, core: NapCatCore) { this.obContext = obContext; this.core = core; diff --git a/src/onebot/network/active-http.ts b/src/onebot/network/active-http.ts index 42e34e024..57a7b7991 100644 --- a/src/onebot/network/active-http.ts +++ b/src/onebot/network/active-http.ts @@ -45,6 +45,11 @@ export class OB11ActiveHttpAdapter implements IOB11NetworkAdapter { const data = await RequestUtil.HttpGetText(this.config.url, 'POST', msgStr, headers); const resJson: QuickAction = data ? JSON.parse(data) : {}; + + if (!this.obContext.apis.QuickActionApi.handleQuickOperation) { + throw new Error('apis.QuickActionApi.handleQuickOperation 异常'); + } + await this.obContext.apis.QuickActionApi.handleQuickOperation(event as QuickActionEvent, resJson); } diff --git a/src/onebot/network/active-websocket.ts b/src/onebot/network/active-websocket.ts index 47d75a6e0..b73e95e5b 100644 --- a/src/onebot/network/active-websocket.ts +++ b/src/onebot/network/active-websocket.ts @@ -2,7 +2,7 @@ import { IOB11NetworkAdapter, OB11EmitEventContent, OB11NetworkReloadType } from import { WebSocket } from 'ws'; import { OB11HeartbeatEvent } from '@/onebot/event/meta/OB11HeartbeatEvent'; import { NapCatCore } from '@/core'; -import { ActionName } from '@/onebot/action/router'; +import { ActionName } from '@/onebot/action/router'; import { OB11Response } from '@/onebot/action/OneBotAction'; import { LogWrapper } from '@/common/log'; import { ActionMap } from '@/onebot/action'; @@ -133,7 +133,7 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter { } private async handleMessage(message: any) { - let receiveData: { action: ActionName, params?: any, echo?: any } = { action: ActionName.Unknown, params: {} }; + let receiveData: { action: typeof ActionName[keyof typeof ActionName], params?: any, echo?: any } = { action: ActionName.Unknown, params: {} }; let echo = undefined; try { @@ -145,7 +145,7 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter { return; } receiveData.params = (receiveData?.params) ? receiveData.params : {};// 兼容类型验证 - const action = this.actions.get(receiveData.action); + const action = this.actions.get(receiveData.action as any); if (!action) { this.logger.logError('[OneBot] [WebSocket Client] 发生错误', '不支持的Api ' + receiveData.action); this.checkStateAndReply(OB11Response.error('不支持的Api ' + receiveData.action, 1404, echo)); diff --git a/src/onebot/network/passive-websocket.ts b/src/onebot/network/passive-websocket.ts index 85a73a947..a5b7cb1f8 100644 --- a/src/onebot/network/passive-websocket.ts +++ b/src/onebot/network/passive-websocket.ts @@ -166,7 +166,7 @@ export class OB11PassiveWebSocketAdapter implements IOB11NetworkAdapter { } private async handleMessage(wsClient: WebSocket, message: any) { - let receiveData: { action: ActionName, params?: any, echo?: any } = { action: ActionName.Unknown, params: {} }; + let receiveData: { action: typeof ActionName[keyof typeof ActionName], params?: any, echo?: any } = { action: ActionName.Unknown, params: {} }; let echo = undefined; try { receiveData = JSON.parse(message.toString()); @@ -177,7 +177,7 @@ export class OB11PassiveWebSocketAdapter implements IOB11NetworkAdapter { return; } receiveData.params = (receiveData?.params) ? receiveData.params : {};//兼容类型验证 不然类型校验爆炸 - const action = this.actions.get(receiveData.action); + const action = this.actions.get(receiveData.action as any); if (!action) { this.logger.logError('[OneBot] [WebSocket Client] 发生错误', '不支持的API ' + receiveData.action); this.checkStateAndReply(OB11Response.error('不支持的API ' + receiveData.action, 1404, echo), wsClient);