From 9560afd4a70645b7d2661f48b1e32f3f48b7c499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sat, 24 Aug 2024 21:47:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=80=E5=A4=84=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=8E=A8=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/entities/notify.ts | 14 +++++++------- src/onebot/action/group/GetGroupSystemMsg.ts | 5 +++-- src/onebot/index.ts | 5 +++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/core/entities/notify.ts b/src/core/entities/notify.ts index e399582e..6c619984 100644 --- a/src/core/entities/notify.ts +++ b/src/core/entities/notify.ts @@ -22,18 +22,18 @@ export interface GroupNotifies { notifies: GroupNotify[]; } -export enum GroupNotifyStatus { - IGNORE = 0, - WAIT_HANDLE = 1, - APPROVE = 2, - REJECT = 3 +export enum GroupNotifyMsgStatus { + KINIT,//初始化 + KUNHANDLE,//未处理 + KAGREED,//同意 + KREFUSED,//拒绝 + KIGNORED//忽略 } - export interface GroupNotify { time: number; // 自己添加的字段,时间戳,毫秒, 用于判断收到短时间内收到重复的notify seq: string; // 唯一标识符,转成数字再除以1000应该就是时间戳? type: GroupNotifyMsgType; - status: GroupNotifyStatus; // 0是已忽略?,1是未处理,2是已同意 + status: GroupNotifyMsgStatus; group: { groupCode: string; groupName: string }; user1: { uid: string; nickName: string }; // 被设置管理员的人 user2: { uid: string; nickName: string }; // 操作者 diff --git a/src/onebot/action/group/GetGroupSystemMsg.ts b/src/onebot/action/group/GetGroupSystemMsg.ts index 53a04dbf..bb465e82 100644 --- a/src/onebot/action/group/GetGroupSystemMsg.ts +++ b/src/onebot/action/group/GetGroupSystemMsg.ts @@ -1,3 +1,4 @@ +import { GroupNotifyMsgStatus } from '@/core'; import BaseAction from '../BaseAction'; import { ActionName } from '../types'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; @@ -28,7 +29,7 @@ export class GetGroupSystemMsg extends BaseAction { invitor_nick: SSNotify.user1?.nickName, group_id: SSNotify.group?.groupCode, group_name: SSNotify.group?.groupName, - checked: SSNotify.status === 1 ? false : true, + checked: SSNotify.status === GroupNotifyMsgStatus.KUNHANDLE ? false : true, actor: await NTQQUserApi.getUinByUidV2(SSNotify.user2?.uid) || 0, }); } else if (SSNotify.type == 7) { @@ -38,7 +39,7 @@ export class GetGroupSystemMsg extends BaseAction { requester_nick: SSNotify.user1?.nickName, group_id: SSNotify.group?.groupCode, group_name: SSNotify.group?.groupName, - checked: SSNotify.status === 1 ? false : true, + checked: SSNotify.status === GroupNotifyMsgStatus.KUNHANDLE ? false : true, actor: await NTQQUserApi.getUinByUidV2(SSNotify.user2?.uid) || 0, }); } diff --git a/src/onebot/index.ts b/src/onebot/index.ts index 9b71dfa8..531e4483 100644 --- a/src/onebot/index.ts +++ b/src/onebot/index.ts @@ -10,6 +10,7 @@ import { SendStatusType, GroupMemberRole, GroupNotifyMsgType, + GroupNotifyMsgStatus, } from '@/core'; import { OB11Config, OB11ConfigLoader } from '@/onebot/helper/config'; import { OneBotApiContextType } from '@/onebot/types'; @@ -387,7 +388,7 @@ export class NapCatOneBot11Adapter { // notify.status == 1 表示未处理 2表示处理完成 } else if ([ GroupNotifyMsgType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS, - ].includes(notify.type) && notify.status == 1) { + ].includes(notify.type) && notify.status == GroupNotifyMsgStatus.KUNHANDLE) { this.context.logger.logDebug('有加群请求'); try { let requestUin = (await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid))!; @@ -407,7 +408,7 @@ export class NapCatOneBot11Adapter { } catch (e) { this.context.logger.logError('获取加群人QQ号失败 Uid:', notify.user1.uid, e); } - } else if (notify.type == GroupNotifyMsgType.INVITED_BY_MEMBER && notify.status == 1) { + } else if (notify.type == GroupNotifyMsgType.INVITED_BY_MEMBER && notify.status == GroupNotifyMsgStatus.KUNHANDLE) { this.context.logger.logDebug(`收到邀请我加群通知:${notify}`); const groupInviteEvent = new OB11GroupRequestEvent( this.core,