mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-13 00:10:27 +00:00
refactor: onMsgRecall
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user