From 09583e5de52508132cab963e7ad3b5624858c096 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: Mon, 16 Dec 2024 22:09:37 +0800 Subject: [PATCH] fuck javascript --- src/onebot/api/index.ts | 16 +--------------- src/onebot/index.ts | 5 ++--- src/onebot/network/active-http.ts | 4 +--- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/onebot/api/index.ts b/src/onebot/api/index.ts index 443159f78..f4b103155 100644 --- a/src/onebot/api/index.ts +++ b/src/onebot/api/index.ts @@ -1,19 +1,5 @@ -import type { OneBotFriendApi } from '@/onebot/api/friend'; -import type { OneBotUserApi } from '@/onebot/api/user'; -import type { OneBotGroupApi } from '@/onebot/api/group'; -import type { OneBotMsgApi } from '@/onebot/api/msg'; -import type { OneBotQuickActionApi } from '@/onebot/api/quick-action'; - export * from './friend'; export * from './group'; export * from './user'; export * from './msg'; -export * from './quick-action'; - -export interface StableOneBotApiWrapper { - FriendApi: OneBotFriendApi; - UserApi: OneBotUserApi; - GroupApi: OneBotGroupApi; - MsgApi: OneBotMsgApi; - QuickActionApi: OneBotQuickActionApi, -} +export * from './quick-action'; \ No newline at end of file diff --git a/src/onebot/index.ts b/src/onebot/index.ts index 8a4437315..70eeddd3c 100644 --- a/src/onebot/index.ts +++ b/src/onebot/index.ts @@ -31,7 +31,6 @@ import { OneBotMsgApi, OneBotQuickActionApi, OneBotUserApi, - StableOneBotApiWrapper, } from '@/onebot/api'; import { ActionMap, createActionMap } from '@/onebot/action'; import { WebUiDataRuntime } from '@/webui/src/helper/Data'; @@ -55,7 +54,7 @@ export class NapCatOneBot11Adapter { readonly context: InstanceContext; configLoader: OB11ConfigLoader; - public readonly apis: StableOneBotApiWrapper; + public readonly apis; networkManager: OB11NetworkManager; actions: ActionMap; private readonly bootTime = Date.now() / 1000; @@ -72,7 +71,7 @@ export class NapCatOneBot11Adapter { UserApi: new OneBotUserApi(this, core), FriendApi: new OneBotFriendApi(this, core), MsgApi: new OneBotMsgApi(this, core), - QuickActionApi: new OneBotQuickActionApi(this, core), + QuickActionApi: new OneBotQuickActionApi(this, core) } as const; this.actions = createActionMap(this, core); this.networkManager = new OB11NetworkManager(); diff --git a/src/onebot/network/active-http.ts b/src/onebot/network/active-http.ts index 57a7b7991..94be319f1 100644 --- a/src/onebot/network/active-http.ts +++ b/src/onebot/network/active-http.ts @@ -30,7 +30,6 @@ export class OB11ActiveHttpAdapter implements IOB11NetworkAdapter { async emitEventAsync(event: T) { if (!this.isEnable) return; - const headers: Record = { 'Content-Type': 'application/json', 'x-self-id': this.core.selfInfo.uin, @@ -46,10 +45,9 @@ 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) { + if (!this.obContext.apis || !this.obContext.apis.QuickActionApi.handleQuickOperation) { throw new Error('apis.QuickActionApi.handleQuickOperation 异常'); } - await this.obContext.apis.QuickActionApi.handleQuickOperation(event as QuickActionEvent, resJson); }