Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MliKiowa committed Apr 29, 2024
1 parent 09405de commit 0118dbd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
29 changes: 25 additions & 4 deletions src/onebot11/action/group/GetGroupMemberList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,35 @@ class GetGroupMemberList extends BaseAction<PayloadType, OB11GroupMember[]> {
actionName = ActionName.GetGroupMemberList;

protected async _handle(payload: PayloadType) {
// logDebug(await WebApi.getGroupMembers(payload.group_id.toString()));
let MemberMap: Map<number, OB11GroupMember> = new Map<number, OB11GroupMember>();
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;
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/onebot11/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface OB11GroupMember {
shut_up_timestamp?: number
// 以下为扩展字段
is_robot?: boolean
qage?: number
}

export interface OB11Group {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0118dbd

Please sign in to comment.