Skip to content

Commit

Permalink
fix: 一处错误推断
Browse files Browse the repository at this point in the history
  • Loading branch information
MliKiowa committed Aug 24, 2024
1 parent 56ec855 commit 9560afd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/core/entities/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }; // 操作者
Expand Down
5 changes: 3 additions & 2 deletions src/onebot/action/group/GetGroupSystemMsg.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { GroupNotifyMsgStatus } from '@/core';
import BaseAction from '../BaseAction';
import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
Expand Down Expand Up @@ -28,7 +29,7 @@ export class GetGroupSystemMsg extends BaseAction<void, any> {
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) {
Expand All @@ -38,7 +39,7 @@ export class GetGroupSystemMsg extends BaseAction<void, any> {
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,
});
}
Expand Down
5 changes: 3 additions & 2 deletions src/onebot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
SendStatusType,
GroupMemberRole,
GroupNotifyMsgType,
GroupNotifyMsgStatus,
} from '@/core';
import { OB11Config, OB11ConfigLoader } from '@/onebot/helper/config';
import { OneBotApiContextType } from '@/onebot/types';
Expand Down Expand Up @@ -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))!;
Expand All @@ -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,
Expand Down

0 comments on commit 9560afd

Please sign in to comment.