From b8aa3131b05671a7de13492c2453bbf4e784dae4 Mon Sep 17 00:00:00 2001 From: linyuchen Date: Tue, 27 Feb 2024 20:31:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BE=A4=E9=80=9A=E7=9F=A5=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/main.ts | 17 ++++++++++++----- src/ntqqapi/ntcall.ts | 1 + src/ntqqapi/types.ts | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/main.ts b/src/main/main.ts index 3a13c42..413d4b1 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -232,7 +232,7 @@ function onLoad() { "unreadCount": number }>(ReceiveCmd.UNREAD_GROUP_NOTIFY, async (payload) => { if (payload.unreadCount) { - log("开始获取群通知详情") + // log("开始获取群通知详情") let notify: GroupNotifies; try { notify = await NTQQApi.getGroupNotifies(); @@ -242,14 +242,23 @@ function onLoad() { } const notifies = notify.notifies.slice(0, payload.unreadCount) - log("获取群通知详情完成", notifies, payload); + // log("获取群通知详情完成", notifies, payload); try { for (const notify of notifies) { + notify.time = Date.now(); const notifyTime = parseInt(notify.seq) / 1000 - log(`加群通知时间${notifyTime}`, `LLOneBot启动时间${startTime}`); + // log(`加群通知时间${notifyTime}`, `LLOneBot启动时间${startTime}`); if (notifyTime < startTime) { continue; } + let existNotify = groupNotifies[notify.seq]; + if (existNotify){ + if (Date.now() - existNotify.time < 3000){ + continue + } + } + log("收到群通知", notify); + groupNotifies[notify.seq] = notify; const member1 = await getGroupMember(notify.group.groupCode, null, notify.user1.uid); let member2: GroupMember; if (notify.user2.uid) { @@ -274,7 +283,6 @@ function onLoad() { // postEvent(groupDecreaseEvent, true); } else if ([GroupNotifyTypes.JOIN_REQUEST].includes(notify.type)) { log("有加群请求"); - groupNotifies[notify.seq] = notify; let groupRequestEvent = new OB11GroupRequestEvent(); groupRequestEvent.group_id = parseInt(notify.group.groupCode); let requestQQ = "" @@ -290,7 +298,6 @@ function onLoad() { postOB11Event(groupRequestEvent); } else if(notify.type == GroupNotifyTypes.INVITE_ME){ - groupNotifies[notify.seq] = notify; let groupInviteEvent = new OB11GroupRequestEvent(); groupInviteEvent.group_id = parseInt(notify.group.groupCode); let user_id = (await NTQQApi.getUserDetailInfo(notify.user2.uid))?.uin diff --git a/src/ntqqapi/ntcall.ts b/src/ntqqapi/ntcall.ts index 09d9142..d4cae12 100644 --- a/src/ntqqapi/ntcall.ts +++ b/src/ntqqapi/ntcall.ts @@ -548,6 +548,7 @@ export class NTQQApi { if (!notify) { throw `${seq}对应的加群通知不存在` } + delete groupNotifies[seq]; return await callNTQQApi({ methodName: NTQQApiMethod.HANDLE_GROUP_REQUEST, args: [ diff --git a/src/ntqqapi/types.ts b/src/ntqqapi/types.ts index ef9fae1..fe2d5da 100644 --- a/src/ntqqapi/types.ts +++ b/src/ntqqapi/types.ts @@ -316,7 +316,7 @@ export interface GroupNotifies { } export interface GroupNotify { - + time: number; // 自己添加的字段,时间戳,毫秒, 用于判断收到短时间内收到重复的notify seq: string, // 转成数字,再除以1000应该就是时间戳? type: GroupNotifyTypes, status: 0, // 未知