diff --git a/src/onebot11/action/group/GetGroupMemberList.ts b/src/onebot11/action/group/GetGroupMemberList.ts index 0c2420d6..d19312b6 100644 --- a/src/onebot11/action/group/GetGroupMemberList.ts +++ b/src/onebot11/action/group/GetGroupMemberList.ts @@ -16,14 +16,35 @@ class GetGroupMemberList extends BaseAction { actionName = ActionName.GetGroupMemberList; protected async _handle(payload: PayloadType) { - // logDebug(await WebApi.getGroupMembers(payload.group_id.toString())); + let MemberMap: Map = new Map(); + let WebGroupMember = await WebApi.getGroupMembers(payload.group_id.toString()); // await NTQQGroupApi.getGroupMembers(payload.group_id.toString()); const group = await getGroup(payload.group_id.toString()); - if (group) { - return OB11Constructor.groupMembers(group); - } else { + if (!group) { throw (`群${payload.group_id}不存在`); } + let GroupMember = OB11Constructor.groupMembers(group); + // 方便索引处理 + for (let i = 0, len = GroupMember.length; i < len; i++) { + MemberMap.set(GroupMember[i].user_id, GroupMember[i]); + } + // 合并数据 + for (let i = 0, len = WebGroupMember.length; i < len; i++) { + if (!WebGroupMember[i]?.uin) { + continue; + } + let MemberData = MemberMap.get(WebGroupMember[i]?.uin); + if (MemberData) { + MemberData.join_time = WebGroupMember[i]?.join_time; + MemberData.last_sent_time = WebGroupMember[i]?.last_speak_time; + MemberData.qage = WebGroupMember[i]?.qage; + MemberData.level = WebGroupMember[i]?.lv.level; + MemberMap.set(WebGroupMember[i]?.uin, MemberData); + } + } + // 还原Map到Array + let RetGroupMember: OB11GroupMember[] = Array.from(MemberMap.values()); + return RetGroupMember; } } diff --git a/src/onebot11/types.ts b/src/onebot11/types.ts index 3b4b59c8..45e705f0 100644 --- a/src/onebot11/types.ts +++ b/src/onebot11/types.ts @@ -45,6 +45,7 @@ export interface OB11GroupMember { shut_up_timestamp?: number // 以下为扩展字段 is_robot?: boolean + qage?: number } export interface OB11Group { @@ -225,13 +226,13 @@ export interface OB11MessageJson { data: { config: { token: string } } & any } -export interface OB11MessageDice{ +export interface OB11MessageDice { type: OB11MessageDataType.dice, data: { result: number } } -export interface OB11MessageRPS{ +export interface OB11MessageRPS { type: OB11MessageDataType.RPS, data: { result: number