mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 04:45:46 +00:00
refactor: 开始重构群成员信息获取
This commit is contained in:
parent
6533a25404
commit
67dcbcb842
@ -81,6 +81,9 @@ export class NTQQGroupApi {
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
static async getGroupMemberAll(GroupCode: string, forced = false) {
|
||||
return napCatCore.session.getGroupService().getAllMemberList(GroupCode, forced);
|
||||
}
|
||||
static async getLastestMsg(GroupCode: string, uins: string[]) {
|
||||
let uids: Array<string> = [];
|
||||
for (let uin of uins) {
|
||||
@ -155,6 +158,11 @@ export class NTQQGroupApi {
|
||||
);
|
||||
return notifies;
|
||||
}
|
||||
static async getGroupMemberV2(GroupCode: string, uid: string, forced = false) {
|
||||
//type ListenerType = NodeIKernelGroupListener['onGroupMemberInfoUpdate'];
|
||||
// NTEventDispatch.CreatListenerFunction('NodeIKernelGroupListener/onGroupMemberInfoUpdate',
|
||||
return napCatCore.session.getGroupService().getMemberInfo(GroupCode, [uid], forced);
|
||||
}
|
||||
static async getGroupMembers(groupQQ: string, num = 3000): Promise<Map<string, GroupMember>> {
|
||||
const groupService = napCatCore.session.getGroupService();
|
||||
const sceneId = groupService.createMemberListScene(groupQQ, 'groupMemberList_MainWindow');
|
||||
|
@ -8,7 +8,10 @@ import {
|
||||
} from '@/core/entities';
|
||||
import { GeneralCallResult } from '@/core/services/common';
|
||||
|
||||
//高版本的接口不应该随意使用 使用应该严格进行pr审核 同时部分ipc中未出现的接口不要过于依赖 应该做好数据兜底
|
||||
|
||||
export interface NodeIKernelGroupService {
|
||||
getMemberCommonInfo(...arg: unknown[]): unknown;
|
||||
//26702
|
||||
getGroupMemberLevelInfo(groupCode: string): Promise<unknown>;
|
||||
//26702
|
||||
@ -53,7 +56,19 @@ export interface NodeIKernelGroupService {
|
||||
//26702(其实更早 但是我不知道)
|
||||
fetchGroupEssenceList(Req: { groupCode: string, pageStart: number, pageLimit: number }, Arg: unknown): Promise<unknown>;
|
||||
//26702
|
||||
getAllMemberList(groupCode: string, refresh: boolean): Promise<unknown>;
|
||||
getAllMemberList(groupCode: string, forceFetch: boolean): Promise<{
|
||||
errCode: number,
|
||||
errMsg: string,
|
||||
result: {
|
||||
ids: Array<{
|
||||
uid: string,
|
||||
index: number//0
|
||||
}>,
|
||||
infos: {},
|
||||
finish: true,
|
||||
hasRobot: false
|
||||
}
|
||||
}>;
|
||||
|
||||
setHeader(uid: string, path: string): unknown;
|
||||
|
||||
@ -74,9 +89,9 @@ export interface NodeIKernelGroupService {
|
||||
|
||||
monitorMemberList(): unknown;
|
||||
|
||||
searchMember(uid: string): unknown;
|
||||
searchMember(sceneId: string, keywords: string[]): unknown;
|
||||
|
||||
getMemberInfo(uid: string): unknown;
|
||||
getMemberInfo(group_id: string, uids: string[], forceFetch: boolean): unknown;
|
||||
//getMemberInfo [ '56729xxxx', [ 'u_4Nj08cwW5Hxxxxx' ], true ]
|
||||
|
||||
kickMember(groupCode: string, memberUids: string[], refuseForever: boolean, kickReason: string): Promise<void>;
|
||||
|
@ -26,6 +26,7 @@ class GetGroupMemberInfo extends BaseAction<Payload, OB11GroupMember> {
|
||||
actionName = ActionName.GetGroupMemberInfo;
|
||||
PayloadSchema = SchemaData;
|
||||
protected async _handle(payload: Payload) {
|
||||
|
||||
const group = await getGroup(payload.group_id.toString());
|
||||
const role = (await getGroupMember(payload.group_id, selfInfo.uin))?.role;
|
||||
const isPrivilege = role === 3 || role === 4;
|
||||
@ -40,6 +41,7 @@ class GetGroupMemberInfo extends BaseAction<Payload, OB11GroupMember> {
|
||||
if (!member) {
|
||||
throw (`群(${payload.group_id})成员${payload.user_id}不存在`);
|
||||
}
|
||||
//console.log('GetGroupMemberInfo', JSON.stringify(await NTQQGroupApi.getGroupMemberV2(payload.group_id.toString(), member.uid, true), null, 4));
|
||||
try {
|
||||
const info = (await NTQQUserApi.getUserDetailInfo(member.uid));
|
||||
logDebug('群成员详细信息结果', info);
|
||||
|
@ -291,7 +291,7 @@ export class NapCatOnebot11 {
|
||||
}
|
||||
};
|
||||
groupListener.onMemberInfoChange = async (groupCode: string, changeType: number, members: Map<string, GroupMember>) => {
|
||||
//console.log("ob11 onMemberInfoChange", groupCode, changeType, members)
|
||||
console.log("ob11 onMemberInfoChange", groupCode, changeType, members)
|
||||
if (changeType === 1) {
|
||||
let member;
|
||||
for (const [key, value] of members) {
|
||||
|
Loading…
Reference in New Issue
Block a user