fix: 独立窗口下撤回消息重复上报

This commit is contained in:
linyuchen 2024-03-15 11:41:11 +08:00
parent 712f0a8256
commit 2bfe9e236b

View File

@ -151,18 +151,9 @@ function onLoad() {
log(arg);
})
let postedMsgIds: Record<string, any> = {}
async function postReceiveMsg(msgList: RawMessage[]) {
const {debug, reportSelfMessage} = getConfigUtil().getConfig();
for (let message of msgList) {
if (postedMsgIds[message.msgId]) { // 如果QQ开启了独立窗口会导致消息重复上报这里加个记录避免重复上报
continue
}
postedMsgIds[message.msgId] = true
// 超过容量清空
if (Object.keys(postedMsgIds).length > 10000) {
postedMsgIds = {}
}
// log("收到新消息", message.msgId, message.msgSeq)
// if (message.senderUin !== selfInfo.uin){
@ -200,7 +191,7 @@ function onLoad() {
registerReceiveHook<{ msgList: Array<RawMessage> }>(ReceiveCmd.UPDATE_MSG, async (payload) => {
for (const message of payload.msgList) {
// log("message update", message.sendStatus, message.msgId, message.msgSeq)
if (message.recallTime != "0") {
if (message.recallTime != "0") { //todo: 这个判断方法不太好,应该使用灰色消息元素来判断
// 撤回消息上报
const oriMessage = await dbUtil.getMsgByLongId(message.msgId)
if (!oriMessage) {
@ -362,6 +353,7 @@ function onLoad() {
let startTime = 0;
async function start() {
log("llonebot pid", process.pid)
startTime = Date.now();
startReceiveHook().then();
NTQQApi.getGroups(true).then()
@ -428,6 +420,10 @@ function onLoad() {
// 创建窗口时触发
function onBrowserWindowCreated(window: BrowserWindow) {
if (selfInfo.uid) {
return
}
log("window create", window.webContents.getURL().toString())
try {
hookNTQQApiCall(window);
hookNTQQApiReceive(window);