diff --git a/src/onebot/api/friend.ts b/src/onebot/api/friend.ts new file mode 100644 index 00000000..72438965 --- /dev/null +++ b/src/onebot/api/friend.ts @@ -0,0 +1,11 @@ +import { NapCatCore } from "@/core"; +import { NapCatOneBot11Adapter } from "../main"; + +export class OneBotFriendApi { + obContext: NapCatOneBot11Adapter; + coreContext: NapCatCore; + constructor(obContext: NapCatOneBot11Adapter, coreContext: NapCatCore) { + this.obContext = obContext; + this.coreContext = coreContext; + } +} \ No newline at end of file diff --git a/src/onebot/api/group.ts b/src/onebot/api/group.ts new file mode 100644 index 00000000..773458e7 --- /dev/null +++ b/src/onebot/api/group.ts @@ -0,0 +1,10 @@ +import { NapCatCore } from "@/core"; +import { NapCatOneBot11Adapter } from "../main"; +export class OneBotGroupApi{ + obContext: NapCatOneBot11Adapter; + coreContext: NapCatCore; + constructor(obContext: NapCatOneBot11Adapter, coreContext: NapCatCore) { + this.obContext = obContext; + this.coreContext = coreContext; + } +} \ No newline at end of file diff --git a/src/onebot/api/index.ts b/src/onebot/api/index.ts new file mode 100644 index 00000000..59c832bb --- /dev/null +++ b/src/onebot/api/index.ts @@ -0,0 +1,3 @@ +export * from './friend'; +export * from './group'; +export * from './user'; \ No newline at end of file diff --git a/src/onebot/api/user.ts b/src/onebot/api/user.ts new file mode 100644 index 00000000..a31aa32c --- /dev/null +++ b/src/onebot/api/user.ts @@ -0,0 +1,10 @@ +import { NapCatCore } from "@/core"; +import { NapCatOneBot11Adapter } from "../main"; +export class OneBotUserApi{ + obContext: NapCatOneBot11Adapter; + coreContext: NapCatCore; + constructor(obContext: NapCatOneBot11Adapter, coreContext: NapCatCore) { + this.obContext = obContext; + this.coreContext = coreContext; + } +} \ No newline at end of file diff --git a/src/onebot/main.ts b/src/onebot/main.ts index 15e64197..d361e8e6 100644 --- a/src/onebot/main.ts +++ b/src/onebot/main.ts @@ -1,16 +1,23 @@ import { NapCatCore, InstanceContext } from "@/core"; import { OB11Config } from "./helper/config"; import { NapCatPathWrapper } from "@/common/framework/napcat"; +import { OneBotApiContextType } from "./types/adapter"; +import { OneBotFriendApi, OneBotGroupApi, OneBotUserApi } from "./api"; //OneBot实现类 export class NapCatOneBot11Adapter { readonly core: NapCatCore; readonly context: InstanceContext; config: OB11Config; - + apiContext: OneBotApiContextType; constructor(core: NapCatCore, context: InstanceContext, pathWrapper: NapCatPathWrapper) { this.core = core; this.context = context; this.config = new OB11Config(core, pathWrapper.configPath); + this.apiContext = { + GroupApi: new OneBotGroupApi(this, core), + UserApi: new OneBotUserApi(this, core), + FriendApi: new OneBotFriendApi(this, core) + }; } } diff --git a/src/onebot/types/adapter.ts b/src/onebot/types/adapter.ts new file mode 100644 index 00000000..3659ad07 --- /dev/null +++ b/src/onebot/types/adapter.ts @@ -0,0 +1,7 @@ +import { OneBotFriendApi, OneBotGroupApi, OneBotUserApi } from "../api"; + +export interface OneBotApiContextType { + FriendApi: OneBotFriendApi; + UserApi: OneBotUserApi; + GroupApi: OneBotGroupApi; +} \ No newline at end of file