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
|
||||
}>(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
|
||||
|
@ -548,6 +548,7 @@ export class NTQQApi {
|
||||
if (!notify) {
|
||||
throw `${seq}对应的加群通知不存在`
|
||||
}
|
||||
delete groupNotifies[seq];
|
||||
return await callNTQQApi<GeneralCallResult>({
|
||||
methodName: NTQQApiMethod.HANDLE_GROUP_REQUEST,
|
||||
args: [
|
||||
|
@ -316,7 +316,7 @@ export interface GroupNotifies {
|
||||
}
|
||||
|
||||
export interface GroupNotify {
|
||||
|
||||
time: number; // 自己添加的字段,时间戳,毫秒, 用于判断收到短时间内收到重复的notify
|
||||
seq: string, // 转成数字,再除以1000应该就是时间戳?
|
||||
type: GroupNotifyTypes,
|
||||
status: 0, // 未知
|
||||
|
Loading…
x
Reference in New Issue
Block a user