mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 13:01:14 +00:00
fix: 创建OB上下文
This commit is contained in:
parent
a710821c35
commit
6c87e15a52
11
src/onebot/api/friend.ts
Normal file
11
src/onebot/api/friend.ts
Normal file
@ -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;
|
||||
}
|
||||
}
|
10
src/onebot/api/group.ts
Normal file
10
src/onebot/api/group.ts
Normal file
@ -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;
|
||||
}
|
||||
}
|
3
src/onebot/api/index.ts
Normal file
3
src/onebot/api/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export * from './friend';
|
||||
export * from './group';
|
||||
export * from './user';
|
10
src/onebot/api/user.ts
Normal file
10
src/onebot/api/user.ts
Normal file
@ -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;
|
||||
}
|
||||
}
|
@ -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)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
7
src/onebot/types/adapter.ts
Normal file
7
src/onebot/types/adapter.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { OneBotFriendApi, OneBotGroupApi, OneBotUserApi } from "../api";
|
||||
|
||||
export interface OneBotApiContextType {
|
||||
FriendApi: OneBotFriendApi;
|
||||
UserApi: OneBotUserApi;
|
||||
GroupApi: OneBotGroupApi;
|
||||
}
|
Loading…
Reference in New Issue
Block a user