optimize: log

This commit is contained in:
linyuchen
2024-04-27 18:40:45 +08:00
parent 8f113c0578
commit 8ed54eb155
5 changed files with 118 additions and 27 deletions

View File

@@ -14,6 +14,7 @@ import { isNull } from '@/common/utils/helper';
import { dbUtil } from '@/common/utils/db';
import { friendRequests, getGroup, groupNotifies, selfInfo } from '@/common/data';
import { NTQQFriendApi, NTQQGroupApi, NTQQMsgApi } from '../../core/src/apis';
import { logMessage, logNotice, logRequest } from '@/onebot11/log';
export type PostEventType = OB11Message | OB11BaseMetaEvent | OB11BaseNoticeEvent
@@ -69,8 +70,15 @@ export function postWsEvent(event: PostEventType) {
}
}
export function postOB11Event(msg: PostEventType, reportSelf = false, postWs= true) {
export function postOB11Event(msg: PostEventType, reportSelf = false, postWs = true) {
const config = ob11Config;
if (msg.post_type === 'message' || msg.post_type === 'message_sent') {
logMessage(msg as OB11Message).then().catch(logError);
} else if (msg.post_type === 'notice') {
logNotice(msg).then().catch(logError);
} else if (msg.post_type === 'request') {
logRequest(msg).then().catch(logError);
}
// 判断msg是否是event
if (!config.reportSelfMessage && !reportSelf) {
if (msg.post_type === 'message' && (msg as OB11Message).user_id.toString() == selfInfo.uin) {
@@ -181,7 +189,7 @@ export function postOB11Event(msg: PostEventType, reportSelf = false, postWs= tr
});
}
}
if (postWs){
if (postWs) {
postWsEvent(msg);
}
}