fix: 一处错误推断

This commit is contained in:
手瓜一十雪 2024-08-24 21:47:39 +08:00
parent 56ec8559a0
commit 9560afd4a7
3 changed files with 13 additions and 11 deletions

View File

@ -22,18 +22,18 @@ export interface GroupNotifies {
notifies: GroupNotify[]; notifies: GroupNotify[];
} }
export enum GroupNotifyStatus { export enum GroupNotifyMsgStatus {
IGNORE = 0, KINIT,//初始化
WAIT_HANDLE = 1, KUNHANDLE,//未处理
APPROVE = 2, KAGREED,//同意
REJECT = 3 KREFUSED,//拒绝
KIGNORED//忽略
} }
export interface GroupNotify { export interface GroupNotify {
time: number; // 自己添加的字段,时间戳,毫秒, 用于判断收到短时间内收到重复的notify time: number; // 自己添加的字段,时间戳,毫秒, 用于判断收到短时间内收到重复的notify
seq: string; // 唯一标识符转成数字再除以1000应该就是时间戳 seq: string; // 唯一标识符转成数字再除以1000应该就是时间戳
type: GroupNotifyMsgType; type: GroupNotifyMsgType;
status: GroupNotifyStatus; // 0是已忽略1是未处理2是已同意 status: GroupNotifyMsgStatus;
group: { groupCode: string; groupName: string }; group: { groupCode: string; groupName: string };
user1: { uid: string; nickName: string }; // 被设置管理员的人 user1: { uid: string; nickName: string }; // 被设置管理员的人
user2: { uid: string; nickName: string }; // 操作者 user2: { uid: string; nickName: string }; // 操作者

View File

@ -1,3 +1,4 @@
import { GroupNotifyMsgStatus } from '@/core';
import BaseAction from '../BaseAction'; import BaseAction from '../BaseAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@ -28,7 +29,7 @@ export class GetGroupSystemMsg extends BaseAction<void, any> {
invitor_nick: SSNotify.user1?.nickName, invitor_nick: SSNotify.user1?.nickName,
group_id: SSNotify.group?.groupCode, group_id: SSNotify.group?.groupCode,
group_name: SSNotify.group?.groupName, 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, actor: await NTQQUserApi.getUinByUidV2(SSNotify.user2?.uid) || 0,
}); });
} else if (SSNotify.type == 7) { } else if (SSNotify.type == 7) {
@ -38,7 +39,7 @@ export class GetGroupSystemMsg extends BaseAction<void, any> {
requester_nick: SSNotify.user1?.nickName, requester_nick: SSNotify.user1?.nickName,
group_id: SSNotify.group?.groupCode, group_id: SSNotify.group?.groupCode,
group_name: SSNotify.group?.groupName, 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, actor: await NTQQUserApi.getUinByUidV2(SSNotify.user2?.uid) || 0,
}); });
} }

View File

@ -10,6 +10,7 @@ import {
SendStatusType, SendStatusType,
GroupMemberRole, GroupMemberRole,
GroupNotifyMsgType, GroupNotifyMsgType,
GroupNotifyMsgStatus,
} from '@/core'; } from '@/core';
import { OB11Config, OB11ConfigLoader } from '@/onebot/helper/config'; import { OB11Config, OB11ConfigLoader } from '@/onebot/helper/config';
import { OneBotApiContextType } from '@/onebot/types'; import { OneBotApiContextType } from '@/onebot/types';
@ -387,7 +388,7 @@ export class NapCatOneBot11Adapter {
// notify.status == 1 表示未处理 2表示处理完成 // notify.status == 1 表示未处理 2表示处理完成
} else if ([ } else if ([
GroupNotifyMsgType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS, GroupNotifyMsgType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS,
].includes(notify.type) && notify.status == 1) { ].includes(notify.type) && notify.status == GroupNotifyMsgStatus.KUNHANDLE) {
this.context.logger.logDebug('有加群请求'); this.context.logger.logDebug('有加群请求');
try { try {
let requestUin = (await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid))!; let requestUin = (await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid))!;
@ -407,7 +408,7 @@ export class NapCatOneBot11Adapter {
} catch (e) { } catch (e) {
this.context.logger.logError('获取加群人QQ号失败 Uid:', notify.user1.uid, 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}`); this.context.logger.logDebug(`收到邀请我加群通知:${notify}`);
const groupInviteEvent = new OB11GroupRequestEvent( const groupInviteEvent = new OB11GroupRequestEvent(
this.core, this.core,