mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
fix: 群通知重复上报
This commit is contained in:
parent
320aa964f9
commit
b8aa3131b0
@ -232,7 +232,7 @@ function onLoad() {
|
|||||||
"unreadCount": number
|
"unreadCount": number
|
||||||
}>(ReceiveCmd.UNREAD_GROUP_NOTIFY, async (payload) => {
|
}>(ReceiveCmd.UNREAD_GROUP_NOTIFY, async (payload) => {
|
||||||
if (payload.unreadCount) {
|
if (payload.unreadCount) {
|
||||||
log("开始获取群通知详情")
|
// log("开始获取群通知详情")
|
||||||
let notify: GroupNotifies;
|
let notify: GroupNotifies;
|
||||||
try {
|
try {
|
||||||
notify = await NTQQApi.getGroupNotifies();
|
notify = await NTQQApi.getGroupNotifies();
|
||||||
@ -242,14 +242,23 @@ function onLoad() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const notifies = notify.notifies.slice(0, payload.unreadCount)
|
const notifies = notify.notifies.slice(0, payload.unreadCount)
|
||||||
log("获取群通知详情完成", notifies, payload);
|
// log("获取群通知详情完成", notifies, payload);
|
||||||
try {
|
try {
|
||||||
for (const notify of notifies) {
|
for (const notify of notifies) {
|
||||||
|
notify.time = Date.now();
|
||||||
const notifyTime = parseInt(notify.seq) / 1000
|
const notifyTime = parseInt(notify.seq) / 1000
|
||||||
log(`加群通知时间${notifyTime}`, `LLOneBot启动时间${startTime}`);
|
// log(`加群通知时间${notifyTime}`, `LLOneBot启动时间${startTime}`);
|
||||||
if (notifyTime < startTime) {
|
if (notifyTime < startTime) {
|
||||||
continue;
|
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);
|
const member1 = await getGroupMember(notify.group.groupCode, null, notify.user1.uid);
|
||||||
let member2: GroupMember;
|
let member2: GroupMember;
|
||||||
if (notify.user2.uid) {
|
if (notify.user2.uid) {
|
||||||
@ -274,7 +283,6 @@ function onLoad() {
|
|||||||
// postEvent(groupDecreaseEvent, true);
|
// postEvent(groupDecreaseEvent, true);
|
||||||
} else if ([GroupNotifyTypes.JOIN_REQUEST].includes(notify.type)) {
|
} else if ([GroupNotifyTypes.JOIN_REQUEST].includes(notify.type)) {
|
||||||
log("有加群请求");
|
log("有加群请求");
|
||||||
groupNotifies[notify.seq] = notify;
|
|
||||||
let groupRequestEvent = new OB11GroupRequestEvent();
|
let groupRequestEvent = new OB11GroupRequestEvent();
|
||||||
groupRequestEvent.group_id = parseInt(notify.group.groupCode);
|
groupRequestEvent.group_id = parseInt(notify.group.groupCode);
|
||||||
let requestQQ = ""
|
let requestQQ = ""
|
||||||
@ -290,7 +298,6 @@ function onLoad() {
|
|||||||
postOB11Event(groupRequestEvent);
|
postOB11Event(groupRequestEvent);
|
||||||
}
|
}
|
||||||
else if(notify.type == GroupNotifyTypes.INVITE_ME){
|
else if(notify.type == GroupNotifyTypes.INVITE_ME){
|
||||||
groupNotifies[notify.seq] = notify;
|
|
||||||
let groupInviteEvent = new OB11GroupRequestEvent();
|
let groupInviteEvent = new OB11GroupRequestEvent();
|
||||||
groupInviteEvent.group_id = parseInt(notify.group.groupCode);
|
groupInviteEvent.group_id = parseInt(notify.group.groupCode);
|
||||||
let user_id = (await NTQQApi.getUserDetailInfo(notify.user2.uid))?.uin
|
let user_id = (await NTQQApi.getUserDetailInfo(notify.user2.uid))?.uin
|
||||||
|
@ -548,6 +548,7 @@ export class NTQQApi {
|
|||||||
if (!notify) {
|
if (!notify) {
|
||||||
throw `${seq}对应的加群通知不存在`
|
throw `${seq}对应的加群通知不存在`
|
||||||
}
|
}
|
||||||
|
delete groupNotifies[seq];
|
||||||
return await callNTQQApi<GeneralCallResult>({
|
return await callNTQQApi<GeneralCallResult>({
|
||||||
methodName: NTQQApiMethod.HANDLE_GROUP_REQUEST,
|
methodName: NTQQApiMethod.HANDLE_GROUP_REQUEST,
|
||||||
args: [
|
args: [
|
||||||
|
@ -316,7 +316,7 @@ export interface GroupNotifies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface GroupNotify {
|
export interface GroupNotify {
|
||||||
|
time: number; // 自己添加的字段,时间戳,毫秒, 用于判断收到短时间内收到重复的notify
|
||||||
seq: string, // 转成数字,再除以1000应该就是时间戳?
|
seq: string, // 转成数字,再除以1000应该就是时间戳?
|
||||||
type: GroupNotifyTypes,
|
type: GroupNotifyTypes,
|
||||||
status: 0, // 未知
|
status: 0, // 未知
|
||||||
|
Loading…
x
Reference in New Issue
Block a user