refactor: onMsgRecall

This commit is contained in:
手瓜一十雪
2024-11-25 22:36:07 +08:00
parent 988c52ecc0
commit 5188e3c6b3
5 changed files with 24 additions and 17 deletions

View File

@@ -265,16 +265,22 @@ export class NapCatOneBot11Adapter {
};
const msgIdSend = new LRUCache<string, number>(100);
const recallMsgs = new LRUCache<string, boolean>(100);
msgListener.onAddSendMsg = async (msg) => {
if (msg.sendStatus == SendStatusType.KSEND_STATUS_SENDING) {
msgIdSend.put(msg.msgId, 0);
}
};
msgListener.onMsgRecall = async (chatType: ChatType, uid: string, msgSeq: string) => {
const peer: Peer = {
chatType: chatType,
peerUid: uid,
guildId: ''
};
let msg = (await this.core.apis.MsgApi.queryMsgsWithFilterExWithSeq(peer, msgSeq)).msgList;
console.log(JSON.stringify(msg));
}
msgListener.onMsgInfoListUpdate = async (msgList) => {
this.emitRecallMsg(msgList, recallMsgs).catch((e) =>
this.context.logger.logError.bind(this.context.logger)('处理消息失败', e)
);
for (const msg of msgList.filter((e) => e.senderUin == this.core.selfInfo.uin)) {
if (msg.sendStatus == SendStatusType.KSEND_STATUS_SUCCESS && msgIdSend.get(msg.msgId) == 0) {
msgIdSend.put(msg.msgId, 1);