mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 13:05:09 +00:00
chore config
This commit is contained in:
76
src/onebot/helper/config.ts
Normal file
76
src/onebot/helper/config.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { ConfigBase } from '@/common/utils/ConfigBase';
|
||||
|
||||
// export interface OB11Config {
|
||||
// http: {
|
||||
// enable: boolean;
|
||||
// host: string;
|
||||
// port: number;
|
||||
// secret: string;
|
||||
// enableHeart: boolean;
|
||||
// enablePost: boolean;
|
||||
// postUrls: string[];
|
||||
// };
|
||||
// ws: {
|
||||
// enable: boolean;
|
||||
// host: string;
|
||||
// port: number;
|
||||
// };
|
||||
// reverseWs: {
|
||||
// enable: boolean;
|
||||
// urls: string[];
|
||||
// };
|
||||
|
||||
// debug: boolean;
|
||||
// heartInterval: number;
|
||||
// messagePostFormat: 'array' | 'string';
|
||||
// enableLocalFile2Url: boolean;
|
||||
// musicSignUrl: string;
|
||||
// reportSelfMessage: boolean;
|
||||
// token: string;
|
||||
// GroupLocalTime: {
|
||||
// Record: boolean,
|
||||
// RecordList: Array<string>
|
||||
// },
|
||||
// read(): OB11Config;
|
||||
|
||||
// save(config: OB11Config): void;
|
||||
// }
|
||||
|
||||
export class OB11Config extends ConfigBase<OB11Config> {
|
||||
name: string = 'onebot11';
|
||||
http = {
|
||||
enable: false,
|
||||
host: '',
|
||||
port: 3000,
|
||||
secret: '',
|
||||
enableHeart: false,
|
||||
enablePost: false,
|
||||
postUrls: [],
|
||||
};
|
||||
ws = {
|
||||
enable: false,
|
||||
host: '',
|
||||
port: 3001,
|
||||
};
|
||||
reverseWs = {
|
||||
enable: false,
|
||||
urls: [],
|
||||
};
|
||||
debug = false;
|
||||
heartInterval = 30000;
|
||||
messagePostFormat: 'array' | 'string' = 'array';
|
||||
enableLocalFile2Url = true;
|
||||
musicSignUrl = '';
|
||||
reportSelfMessage = false;
|
||||
token = '';
|
||||
GroupLocalTime = {
|
||||
Record: false,
|
||||
RecordList: [] as Array<string>
|
||||
};
|
||||
|
||||
protected getKeys(): string[] | null {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -68,8 +68,6 @@ export function postWsEvent(event: QuickActionEvent) {
|
||||
}
|
||||
|
||||
export function postOB11Event(msg: QuickActionEvent, reportSelf = false, postWs = true, coreContext: NapCatCore) {
|
||||
const config = ob11Config;
|
||||
|
||||
// 判断msg是否是event
|
||||
if (!config.reportSelfMessage && !reportSelf) {
|
||||
if (msg.post_type === 'message' && (msg as OB11Message).user_id.toString() == coreContext.selfInfo.uin) {
|
||||
@@ -105,7 +103,7 @@ export function postOB11Event(msg: QuickActionEvent, reportSelf = false, postWs
|
||||
return;
|
||||
}
|
||||
try {
|
||||
handleQuickOperation(msg as QuickActionEvent, resJson,coreContext).then().catch(logError);
|
||||
handleQuickOperation(msg as QuickActionEvent, resJson, coreContext).then().catch(coreContext.context.logger.logError);
|
||||
} catch (e: any) {
|
||||
coreContext.context.logger.logError('新消息事件HTTP上报返回快速操作失败', e);
|
||||
}
|
||||
@@ -157,8 +155,8 @@ async function handleMsg(msg: OB11Message, quickAction: QuickAction, coreContext
|
||||
}
|
||||
}
|
||||
replyMessage = replyMessage.concat(normalize(reply, quickAction.auto_escape));
|
||||
const { sendElements, deleteAfterSentFiles } = await createSendElements(replyMessage, peer);
|
||||
sendMsg(peer, sendElements, deleteAfterSentFiles, false).then().catch(logError);
|
||||
const { sendElements, deleteAfterSentFiles } = await createSendElements(coreContext, replyMessage, peer);
|
||||
sendMsg(coreContext, peer, sendElements, deleteAfterSentFiles, false).then().catch(coreContext.context.logger.logError);
|
||||
}
|
||||
}
|
||||
async function handleGroupRequest(request: OB11GroupRequestEvent, quickAction: QuickActionGroupRequest, coreContext: NapCatCore) {
|
||||
|
||||
Reference in New Issue
Block a user