From 7ce95bca04b2472ec4284388e909e443e605700e 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: Thu, 21 Nov 2024 14:15:22 +0800 Subject: [PATCH] feat: NTGroupMemberRole --- src/core/apis/group.ts | 4 ++-- src/core/entities/contact.ts | 1 - src/core/entities/group.ts | 15 +++++++-------- src/core/entities/msg.ts | 6 +++--- src/core/entities/notify.ts | 2 +- src/onebot/action/group/SetGroupAdmin.ts | 4 ++-- src/onebot/index.ts | 4 ++-- 7 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/core/apis/group.ts b/src/core/apis/group.ts index ab4f0fa5..9dbad8d9 100644 --- a/src/core/apis/group.ts +++ b/src/core/apis/group.ts @@ -2,7 +2,7 @@ import { GeneralCallResult, Group, GroupMember, - GroupMemberRole, + NTGroupMemberRole, GroupRequestOperateTypes, InstanceContext, KickMemberV2Req, @@ -457,7 +457,7 @@ export class NTQQGroupApi { return this.context.session.getGroupService().modifyMemberCardName(groupQQ, memberUid, cardName); } - async setMemberRole(groupQQ: string, memberUid: string, role: GroupMemberRole) { + async setMemberRole(groupQQ: string, memberUid: string, role: NTGroupMemberRole) { return this.context.session.getGroupService().modifyMemberRole(groupQQ, memberUid, role); } diff --git a/src/core/entities/contact.ts b/src/core/entities/contact.ts index ab13af92..7ab61df8 100644 --- a/src/core/entities/contact.ts +++ b/src/core/entities/contact.ts @@ -1,4 +1,3 @@ - export interface FSABRecentContactParams { anchorPointContact: { contactId: string; diff --git a/src/core/entities/group.ts b/src/core/entities/group.ts index 7885bbe3..f960b203 100644 --- a/src/core/entities/group.ts +++ b/src/core/entities/group.ts @@ -113,14 +113,13 @@ export interface Group { memberUid: string; }; } - -// 群成员角色类型 -export enum GroupMemberRole { - normal = 2, - admin = 3, - owner = 4 +export enum NTGroupMemberRole { + KUNSPECIFIED = 0, + KSTRANGER = 1, + KMEMBER = 2, + KADMIN = 3, + KOWNER = 4 } - export interface GroupMember { memberRealLevel: number | undefined; memberSpecialTitle?: string; @@ -131,7 +130,7 @@ export interface GroupMember { nick: string; qid: string; remark: string; - role: GroupMemberRole; + role: NTGroupMemberRole; shutUpTime: number; // 禁言时间(S) uid: string; uin: string; diff --git a/src/core/entities/msg.ts b/src/core/entities/msg.ts index 4a6ae872..a7f37af3 100644 --- a/src/core/entities/msg.ts +++ b/src/core/entities/msg.ts @@ -1,4 +1,4 @@ -import { GroupMemberRole } from '@/core'; +import { NTGroupMemberRole } from '@/core'; import { ActionBarElement, ArkElement, AvRecordElement, CalendarElement, FaceBubbleElement, FaceElement, FileElement, GiphyElement, GrayTipElement, MarketFaceElement, PicElement, PttElement, RecommendedMsgElement, ReplyElement, ShareLocationElement, StructLongMsgElement, TaskTopMsgElement, TextElement, TofuRecordElement, VideoElement, YoloGameResultElement } from './element'; /** @@ -420,13 +420,13 @@ export interface TipGroupElement { uid: string; card: string; name: string; - role: GroupMemberRole + role: NTGroupMemberRole }; member: { uid: string card: string; name: string; - role: GroupMemberRole + role: NTGroupMemberRole } }; } diff --git a/src/core/entities/notify.ts b/src/core/entities/notify.ts index dbf3f63b..f9c7dd64 100644 --- a/src/core/entities/notify.ts +++ b/src/core/entities/notify.ts @@ -135,7 +135,7 @@ export interface FriendRequest { isDecide: boolean; friendUid: string; reqType: BuddyReqType, - reqTime: string; // 时间戳;秒 + reqTime: string; // 时间戳 秒 extWords: string; // 申请人填写的验证消息 isUnread: boolean; friendNick: string; diff --git a/src/onebot/action/group/SetGroupAdmin.ts b/src/onebot/action/group/SetGroupAdmin.ts index 899aa843..d1980380 100644 --- a/src/onebot/action/group/SetGroupAdmin.ts +++ b/src/onebot/action/group/SetGroupAdmin.ts @@ -1,5 +1,5 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; -import { GroupMemberRole } from '@/core/entities'; +import { NTGroupMemberRole } from '@/core/entities'; import { ActionName } from '@/onebot/action/router'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; @@ -23,7 +23,7 @@ export default class SetGroupAdmin extends OneBotAction { const enable = typeof payload.enable === 'string' ? payload.enable === 'true' : !!payload.enable; const uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString()); if (!uid) throw new Error('get Uid Error'); - await this.core.apis.GroupApi.setMemberRole(payload.group_id.toString(), uid, enable ? GroupMemberRole.admin : GroupMemberRole.normal); + await this.core.apis.GroupApi.setMemberRole(payload.group_id.toString(), uid, enable ? NTGroupMemberRole.KADMIN : NTGroupMemberRole.KMEMBER); return null; } } diff --git a/src/onebot/index.ts b/src/onebot/index.ts index 1fb7264b..c9938ef5 100644 --- a/src/onebot/index.ts +++ b/src/onebot/index.ts @@ -2,7 +2,7 @@ import { BuddyReqType, ChatType, DataSource, - GroupMemberRole, + NTGroupMemberRole, GroupNotifyMsgStatus, GroupNotifyMsgType, InstanceContext, @@ -524,7 +524,7 @@ export class NapCatOneBot11Adapter { this.core, parseInt(groupCode), parseInt(member.uin), - member.role === GroupMemberRole.admin ? 'set' : 'unset' + member.role === NTGroupMemberRole.KADMIN ? 'set' : 'unset' ); this.networkManager .emitEvent(groupAdminNoticeEvent)