chore: config

This commit is contained in:
手瓜一十雪 2024-08-12 00:12:52 +08:00
parent ecee642e10
commit 32d4febf10
3 changed files with 20 additions and 1 deletions

View File

@ -9,6 +9,8 @@ import { LegacyNTEventWrapper } from '@/common/framework/event-legacy';
import { NTQQFileApi, NTQQFriendApi, NTQQGroupApi, NTQQMsgApi, NTQQSystemApi, NTQQUserApi, NTQQWebApi } from './apis';
import os from 'node:os';
import { NTQQCollectionApi } from './apis/collection';
import { OB11Config } from '@/onebot/helper/config';
import { NapCatConfig } from './helper/config';
export enum NapCatCoreWorkingEnv {
Unknown = 0,
@ -36,6 +38,7 @@ export class NapCatCore {
// runtime info, not readonly
selfInfo: SelfInfo;
util: NodeQQNTWrapperUtil;
config: any;
// 通过构造器递过去的 runtime info 应该尽量少
constructor(context: InstanceContext, selfInfo: SelfInfo) {
@ -53,6 +56,7 @@ export class NapCatCore {
UserApi: new NTQQUserApi(this.context, this),
GroupApi: new NTQQGroupApi(this.context, this),
};
this.config = new NapCatConfig(this,this.context.pathWrapper.cachePath);
this.NapCatDataPath = path.join(this.dataPath, 'NapCat');
fs.mkdirSync(this.NapCatDataPath, { recursive: true });
this.NapCatTempPath = path.join(this.NapCatDataPath, 'temp');

16
src/core/helper/config.ts Normal file
View File

@ -0,0 +1,16 @@
import { ConfigBase } from "@/common/utils/ConfigBase";
import { LogLevel } from "@/common/utils/log";
export interface NapCatConfig {
fileLog: boolean,
consoleLog: boolean,
fileLogLevel: LogLevel,
consoleLogLevel: LogLevel,
}
export class NapCatConfig extends ConfigBase<NapCatConfig> {
getConfigName() {
return 'onebot11';
}
}

View File

@ -37,5 +37,4 @@ export class OB11Config extends ConfigBase<OB11Config> {
getConfigName() {
return 'onebot11';
}
}