mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
fix: #444
This commit is contained in:
parent
7b1ac224f6
commit
36c2c567b7
@ -822,6 +822,8 @@ export interface RawMessage {
|
|||||||
elements: MessageElement[];
|
elements: MessageElement[];
|
||||||
|
|
||||||
sourceType: MsgSourceType;
|
sourceType: MsgSourceType;
|
||||||
|
|
||||||
|
isOnlineMsg: boolean;
|
||||||
}
|
}
|
||||||
export interface QueryMsgsParams {
|
export interface QueryMsgsParams {
|
||||||
chatInfo: Peer;
|
chatInfo: Peer;
|
||||||
|
@ -311,33 +311,51 @@ export class NapCatOneBot11Adapter {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const msgIdSend = new LRUCache<string, boolean>(100);
|
//const msgIdSend = new LRUCache<string, boolean>(100);
|
||||||
const recallMsgs = new LRUCache<string, boolean>(100);
|
const recallMsgs = new LRUCache<string, boolean>(100);
|
||||||
|
msgListener.onAddSendMsg = async msg => {
|
||||||
|
if (msg.sendStatus == SendStatusType.KSEND_STATUS_SUCCESS) {
|
||||||
|
this.apis.MsgApi.parseMessage(msg)
|
||||||
|
.then((ob11Msg) => {
|
||||||
|
if (!ob11Msg) return;
|
||||||
|
ob11Msg.target_id = parseInt(msg.peerUin);
|
||||||
|
if (this.configLoader.configData.reportSelfMessage) {
|
||||||
|
msg.id = MessageUnique.createUniqueMsgId({
|
||||||
|
chatType: msg.chatType,
|
||||||
|
peerUid: msg.peerUid,
|
||||||
|
guildId: '',
|
||||||
|
}, msg.msgId);
|
||||||
|
this.emitMsg(msg);
|
||||||
|
} else {
|
||||||
|
// logOB11Message(this.core, ob11Msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
msgListener.onMsgInfoListUpdate = async msgList => {
|
msgListener.onMsgInfoListUpdate = async msgList => {
|
||||||
this.emitRecallMsg(msgList, recallMsgs)
|
this.emitRecallMsg(msgList, recallMsgs)
|
||||||
.catch(e => this.context.logger.logError.bind(this.context.logger)('处理消息失败', e));
|
.catch(e => this.context.logger.logError.bind(this.context.logger)('处理消息失败', e));
|
||||||
|
// for (const msg of msgList.filter(e => e.senderUin == this.core.selfInfo.uin)) {
|
||||||
for (const msg of msgList.filter(e => e.senderUin == this.core.selfInfo.uin)) {
|
// if (msg.sendStatus == SendStatusType.KSEND_STATUS_SUCCESS && !msgIdSend.get(msg.msgId)) {
|
||||||
if (msg.sendStatus == SendStatusType.KSEND_STATUS_SUCCESS && !msgIdSend.get(msg.msgId)) {
|
// msgIdSend.put(msg.msgId, true);
|
||||||
msgIdSend.put(msg.msgId, true);
|
// // 完成后再post
|
||||||
// 完成后再post
|
// this.apis.MsgApi.parseMessage(msg)
|
||||||
this.apis.MsgApi.parseMessage(msg)
|
// .then((ob11Msg) => {
|
||||||
.then((ob11Msg) => {
|
// if (!ob11Msg) return;
|
||||||
if (!ob11Msg) return;
|
// ob11Msg.target_id = parseInt(msg.peerUin);
|
||||||
ob11Msg.target_id = parseInt(msg.peerUin);
|
// if (this.configLoader.configData.reportSelfMessage) {
|
||||||
if (this.configLoader.configData.reportSelfMessage) {
|
// msg.id = MessageUnique.createUniqueMsgId({
|
||||||
msg.id = MessageUnique.createUniqueMsgId({
|
// chatType: msg.chatType,
|
||||||
chatType: msg.chatType,
|
// peerUid: msg.peerUid,
|
||||||
peerUid: msg.peerUid,
|
// guildId: '',
|
||||||
guildId: '',
|
// }, msg.msgId);
|
||||||
}, msg.msgId);
|
// this.emitMsg(msg);
|
||||||
this.emitMsg(msg);
|
// } else {
|
||||||
} else {
|
// // logOB11Message(this.core, ob11Msg);
|
||||||
// logOB11Message(this.core, ob11Msg);
|
// }
|
||||||
}
|
// });
|
||||||
});
|
// }
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.context.session.getMsgService().addKernelMsgListener(
|
this.context.session.getMsgService().addKernelMsgListener(
|
||||||
@ -523,7 +541,7 @@ export class NapCatOneBot11Adapter {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async emitMsg(message: RawMessage) {
|
private async emitMsg(message: RawMessage, parseEvent: boolean = true) {
|
||||||
const { debug, reportSelfMessage, messagePostFormat } = this.configLoader.configData;
|
const { debug, reportSelfMessage, messagePostFormat } = this.configLoader.configData;
|
||||||
this.context.logger.logDebug('收到新消息 RawMessage', message);
|
this.context.logger.logDebug('收到新消息 RawMessage', message);
|
||||||
this.apis.MsgApi.parseMessage(message, messagePostFormat).then((ob11Msg) => {
|
this.apis.MsgApi.parseMessage(message, messagePostFormat).then((ob11Msg) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user