Skip to content

Commit

Permalink
fuck javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
MliKiowa committed Dec 16, 2024
1 parent 38b0b7c commit 09583e5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 21 deletions.
16 changes: 1 addition & 15 deletions src/onebot/api/index.ts
Original file line number Diff line number Diff line change
@@ -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';
5 changes: 2 additions & 3 deletions src/onebot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand All @@ -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();
Expand Down
4 changes: 1 addition & 3 deletions src/onebot/network/active-http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export class OB11ActiveHttpAdapter implements IOB11NetworkAdapter {

async emitEventAsync<T extends OB11EmitEventContent>(event: T) {
if (!this.isEnable) return;

const headers: Record<string, string> = {
'Content-Type': 'application/json',
'x-self-id': this.core.selfInfo.uin,
Expand All @@ -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);
}

Expand Down

0 comments on commit 09583e5

Please sign in to comment.