diff --git a/packages/napcat-onebot/action/go-cqhttp/UploadGroupFile.ts b/packages/napcat-onebot/action/go-cqhttp/UploadGroupFile.ts index d6bfef0a..d9d09d5c 100644 --- a/packages/napcat-onebot/action/go-cqhttp/UploadGroupFile.ts +++ b/packages/napcat-onebot/action/go-cqhttp/UploadGroupFile.ts @@ -41,7 +41,7 @@ export default class GoCQHTTPUploadGroupFile extends OneBotAction { - return await this.core.apis.FileApi.createValidSendPicElement( + return await this.obContext.apis.FileApi.createValidSendPicElement( context, (await this.handleOb11FileLikeMessage(sendMsg, context)).path, sendMsg.data.summary, @@ -676,7 +676,7 @@ export class OneBotMsgApi { [OB11MessageDataType.file]: async (sendMsg, context) => { const { path, fileName } = await this.handleOb11FileLikeMessage(sendMsg, context); - return await this.core.apis.FileApi.createValidSendFileElement(context, path, fileName); + return await this.obContext.apis.FileApi.createValidSendFileElement(context, path, fileName); }, [OB11MessageDataType.video]: async (sendMsg, context) => { @@ -691,11 +691,11 @@ export class OneBotMsgApi { } } - return await this.core.apis.FileApi.createValidSendVideoElement(context, path, fileName, thumb); + return await this.obContext.apis.FileApi.createValidSendVideoElement(context, path, fileName, thumb); }, [OB11MessageDataType.voice]: async (sendMsg, context) => - this.core.apis.FileApi.createValidSendPttElement(context, + this.obContext.apis.FileApi.createValidSendPttElement(context, (await this.handleOb11FileLikeMessage(sendMsg, context)).path), [OB11MessageDataType.json]: async ({ data: { data } }) => ({ diff --git a/packages/napcat-onebot/index.ts b/packages/napcat-onebot/index.ts index 99641e10..0a74bfe6 100644 --- a/packages/napcat-onebot/index.ts +++ b/packages/napcat-onebot/index.ts @@ -54,6 +54,7 @@ import { IOB11NetworkAdapter } from '@/napcat-onebot/network/adapter'; import { OB11HttpSSEServerAdapter } from './network/http-server-sse'; import { OB11PluginMangerAdapter } from './network/plugin-manger'; import { existsSync } from 'node:fs'; +import { OneBotFileApi } from './api/file'; interface ApiListType { GroupApi: OneBotGroupApi; @@ -61,6 +62,7 @@ interface ApiListType { FriendApi: OneBotFriendApi; MsgApi: OneBotMsgApi; QuickActionApi: OneBotQuickActionApi; + FileApi: OneBotFileApi; } // OneBot实现类 export class NapCatOneBot11Adapter { @@ -83,6 +85,7 @@ export class NapCatOneBot11Adapter { FriendApi: new OneBotFriendApi(this, core), MsgApi: new OneBotMsgApi(this, core), QuickActionApi: new OneBotQuickActionApi(this, core), + FileApi: new OneBotFileApi(this, core), } as const; this.actions = createActionMap(this, core); this.networkManager = new OB11NetworkManager();