Skip to content

Commit

Permalink
refactor: GetGroupInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
MliKiowa committed Dec 6, 2024
1 parent 0ae3a41 commit 4b319d1
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 12 deletions.
14 changes: 14 additions & 0 deletions src/core/apis/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
MemberExtSourceType,
NapCatCore,
GroupNotify,
GroupInfoSource,
} from '@/core';
import { isNumeric, solveAsyncProblem } from '@/common/helper';
import { LimitedHashTable } from '@/common/message-unique';
Expand All @@ -24,6 +25,19 @@ export class NTQQGroupApi {
this.core = core;
}

async fetchGroupDetail(groupCode: string) {
let [, detailInfo] = await this.core.eventWrapper.callNormalEventV2(
'NodeIKernelGroupService/getGroupDetailInfo',
'NodeIKernelGroupListener/onGroupDetailInfoChange',
[groupCode, GroupInfoSource.KDATACARD],
(ret) => ret.result === 0,
(detailInfo) => detailInfo.groupCode === groupCode,
1,
5000
);
return detailInfo;
}

async initApi() {
this.initCache().then().catch(e => this.context.logger.logError(e));
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/listeners/NodeIKernelGroupListener.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataSource, Group, GroupListUpdateType, GroupMember, GroupNotify, ShutUpGroupMember } from '@/core/types';
import { DataSource, Group, GroupDetailInfo, GroupListUpdateType, GroupMember, GroupNotify, ShutUpGroupMember } from '@/core/types';

export class NodeIKernelGroupListener {
onGroupListInited(listEmpty: boolean): any { }
Expand Down Expand Up @@ -28,7 +28,7 @@ export class NodeIKernelGroupListener {
onGroupConfMemberChange(...args: unknown[]): any {
}

onGroupDetailInfoChange(...args: unknown[]): any {
onGroupDetailInfoChange(detailInfo: GroupDetailInfo): any {
}

onGroupExtListUpdate(...args: unknown[]): any {
Expand Down
2 changes: 1 addition & 1 deletion src/core/services/NodeIKernelGroupService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export interface NodeIKernelGroupService {

getGroupExtList(force: boolean): Promise<GeneralCallResult>;

getGroupDetailInfo(groupCode: string, groupInfoSource: GroupInfoSource): Promise<unknown>;
getGroupDetailInfo(groupCode: string, groupInfoSource: GroupInfoSource): Promise<GeneralCallResult>;

getMemberExtInfo(param: GroupExtParam): Promise<unknown>;//req

Expand Down
2 changes: 1 addition & 1 deletion src/core/services/NodeIKernelSearchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface NodeIKernelSearchService {
penetrate: string
}): Promise<GeneralCallResult>;// needs 1 arguments

searchLocalInfo(keywords: string, unknown: number/*4*/): unknown;
searchLocalInfo(keywords: string, type: number/*4*/): unknown;

cancelSearchLocalInfo(...args: any[]): unknown;// needs 3 arguments

Expand Down
155 changes: 154 additions & 1 deletion src/core/types/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,160 @@ export enum GroupInfoSource {
KRECENTCONTACT,
KMOREPANEL
}

export interface GroupDetailInfo {
groupCode: string;
groupUin: string;
ownerUid: string;
ownerUin: string;
groupFlag: number;
groupFlagExt: number;
maxMemberNum: number;
memberNum: number;
groupOption: number;
classExt: number;
groupName: string;
fingerMemo: string;
groupQuestion: string;
certType: number;
richFingerMemo: string;
tagRecord: any[];
shutUpAllTimestamp: number;
shutUpMeTimestamp: number;
groupTypeFlag: number;
privilegeFlag: number;
groupSecLevel: number;
groupFlagExt3: number;
isConfGroup: number;
isModifyConfGroupFace: number;
isModifyConfGroupName: number;
groupFlagExt4: number;
groupMemo: string;
cmdUinMsgSeq: number;
cmdUinJoinTime: number;
cmdUinUinFlag: number;
cmdUinMsgMask: number;
groupSecLevelInfo: number;
cmdUinPrivilege: number;
cmdUinFlagEx2: number;
appealDeadline: number;
remarkName: string;
isTop: boolean;
groupFace: number;
groupGeoInfo: {
ownerUid: string;
SetTime: number;
CityId: number;
Longitude: string;
Latitude: string;
GeoContent: string;
poiId: string;
};
certificationText: string;
cmdUinRingtoneId: number;
longGroupName: string;
autoAgreeJoinGroupUserNumForConfGroup: number;
autoAgreeJoinGroupUserNumForNormalGroup: number;
cmdUinFlagExt3Grocery: number;
groupCardPrefix: {
introduction: string;
rptPrefix: any[];
};
groupExt: {
groupInfoExtSeq: number;
reserve: number;
luckyWordId: string;
lightCharNum: number;
luckyWord: string;
starId: number;
essentialMsgSwitch: number;
todoSeq: number;
blacklistExpireTime: number;
isLimitGroupRtc: number;
companyId: number;
hasGroupCustomPortrait: number;
bindGuildId: string;
groupOwnerId: {
memberUin: string;
memberUid: string;
memberQid: string;
};
essentialMsgPrivilege: number;
msgEventSeq: string;
inviteRobotSwitch: number;
gangUpId: string;
qqMusicMedalSwitch: number;
showPlayTogetherSwitch: number;
groupFlagPro1: string;
groupBindGuildIds: {
guildIds: any[];
};
viewedMsgDisappearTime: string;
groupExtFlameData: {
switchState: number;
state: number;
dayNums: any[];
version: number;
updateTime: string;
isDisplayDayNum: boolean;
};
groupBindGuildSwitch: number;
groupAioBindGuildId: string;
groupExcludeGuildIds: {
guildIds: any[];
};
fullGroupExpansionSwitch: number;
fullGroupExpansionSeq: string;
inviteRobotMemberSwitch: number;
inviteRobotMemberExamine: number;
groupSquareSwitch: number;
};
msgLimitFrequency: number;
hlGuildAppid: number;
hlGuildSubType: number;
isAllowRecallMsg: number;
confUin: string;
confMaxMsgSeq: number;
confToGroupTime: number;
groupSchoolInfo: {
location: string;
grade: number;
school: string;
};
activeMemberNum: number;
groupGrade: number;
groupCreateTime: number;
subscriptionUin: string;
subscriptionUid: string;
noFingerOpenFlag: number;
noCodeFingerOpenFlag: number;
isGroupFreeze: number;
allianceId: string;
groupExtOnly: {
tribeId: number;
moneyForAddGroup: number;
};
isAllowConfGroupMemberModifyGroupName: number;
isAllowConfGroupMemberNick: number;
isAllowConfGroupMemberAtAll: number;
groupClassText: string;
groupFreezeReason: number;
headPortraitSeq: number;
groupHeadPortrait: {
portraitCnt: number;
portraitInfo: any[];
defaultId: number;
verifyingPortraitCnt: number;
verifyingPortraitInfo: any[];
};
cmdUinJoinMsgSeq: number;
cmdUinJoinRealMsgSeq: number;
groupAnswer: string;
groupAdminMaxNum: number;
inviteNoAuthNumLimit: string;
hlGuildOrgId: number;
isAllowHlGuildBinary: number;
localExitGroupReason: number;
}
export interface GroupExt0xEF0InfoFilter {
bindGuildId: number;
blacklistExpireTime: number;
Expand Down
13 changes: 6 additions & 7 deletions src/onebot/action/group/GetGroupInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ class GetGroupInfo extends OneBotAction<Payload, OB11Group> {
async _handle(payload: Payload) {
const group = (await this.core.apis.GroupApi.getGroups()).find(e => e.groupCode == payload.group_id.toString());
if (!group) {
const data = await this.core.apis.GroupApi.searchGroup(payload.group_id.toString());
if (!data) throw new Error('Group not found');
const data = await this.core.apis.GroupApi.fetchGroupDetail(payload.group_id.toString());
return {
...data.searchGroupInfo,
...data,
group_id: +payload.group_id,
group_name: data.searchGroupInfo.groupName,
member_count: data.searchGroupInfo.memberNum,
max_member_count: data.searchGroupInfo.maxMemberNum,
};
group_name: data.groupName,
member_count: data.memberNum,
max_member_count: data.maxMemberNum,
}
}
return OB11Construct.group(group);
}
Expand Down

0 comments on commit 4b319d1

Please sign in to comment.