mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 13:01:14 +00:00
remove webapi get group members
This commit is contained in:
parent
afd8c59f83
commit
f32a6320fc
@ -6,12 +6,13 @@ import { ActionName } from '../types';
|
||||
import { NTQQUserApi } from '@/core/apis/user';
|
||||
import { log, logDebug } from '@/common/utils/log';
|
||||
import { isNull } from '../../../common/utils/helper';
|
||||
import { WebApi } from '@/core/apis/webapi';
|
||||
import { WebApi, WebApiGroupMember } from '@/core/apis/webapi';
|
||||
|
||||
|
||||
export interface PayloadType {
|
||||
group_id: number;
|
||||
user_id: number;
|
||||
no_cache?: boolean | string;
|
||||
}
|
||||
|
||||
class GetGroupMemberInfo extends BaseAction<PayloadType, OB11GroupMember> {
|
||||
@ -22,7 +23,10 @@ class GetGroupMemberInfo extends BaseAction<PayloadType, OB11GroupMember> {
|
||||
if (!group) {
|
||||
throw (`群(${payload.group_id})不存在`);
|
||||
}
|
||||
const WebGroupMember = await WebApi.getGroupMembers(payload.group_id.toString());
|
||||
const webGroupMembers: WebApiGroupMember[] = [];
|
||||
if (payload.no_cache === true || payload.no_cache === 'true') {
|
||||
// webGroupMembers = await WebApi.getGroupMembers(payload.group_id.toString());
|
||||
}
|
||||
const member = await getGroupMember(payload.group_id.toString(), payload.user_id.toString());
|
||||
// log(member);
|
||||
if (member) {
|
||||
@ -35,14 +39,13 @@ class GetGroupMemberInfo extends BaseAction<PayloadType, OB11GroupMember> {
|
||||
logDebug('获取群成员详细信息失败, 只能返回基础信息', e);
|
||||
}
|
||||
const retMember = OB11Constructor.groupMember(payload.group_id.toString(), member);
|
||||
for (let i = 0, len = WebGroupMember.length; i < len; i++) {
|
||||
if (WebGroupMember[i]?.uin && WebGroupMember[i].uin === retMember.user_id) {
|
||||
retMember.join_time = WebGroupMember[i]?.join_time;
|
||||
retMember.last_sent_time = WebGroupMember[i]?.last_speak_time;
|
||||
retMember.qage = WebGroupMember[i]?.qage;
|
||||
retMember.level = WebGroupMember[i]?.lv.level;
|
||||
for (let i = 0, len = webGroupMembers.length; i < len; i++) {
|
||||
if (webGroupMembers[i]?.uin && webGroupMembers[i].uin === retMember.user_id) {
|
||||
retMember.join_time = webGroupMembers[i]?.join_time;
|
||||
retMember.last_sent_time = webGroupMembers[i]?.last_speak_time;
|
||||
retMember.qage = webGroupMembers[i]?.qage;
|
||||
retMember.level = webGroupMembers[i]?.lv.level;
|
||||
}
|
||||
|
||||
}
|
||||
return retMember;
|
||||
} else {
|
||||
|
@ -3,7 +3,7 @@ import { OB11GroupMember } from '../../types';
|
||||
import { OB11Constructor } from '../../constructor';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { napCatCore, NTQQGroupApi } from '@/core';
|
||||
import { napCatCore, NTQQGroupApi, WebApiGroupMember } from '@/core';
|
||||
import { WebApi } from '@/core/apis/webapi';
|
||||
import { logDebug } from '@/common/utils/log';
|
||||
|
||||
@ -18,13 +18,14 @@ class GetGroupMemberList extends BaseAction<PayloadType, OB11GroupMember[]> {
|
||||
|
||||
protected async _handle(payload: PayloadType) {
|
||||
const MemberMap: Map<number, OB11GroupMember> = new Map<number, OB11GroupMember>();
|
||||
const WebGroupMember = await WebApi.getGroupMembers(payload.group_id.toString());
|
||||
const webGroupMembers: WebApiGroupMember[] = [];
|
||||
// await NTQQGroupApi.getGroupMembers(payload.group_id.toString());
|
||||
const group = await getGroup(payload.group_id.toString());
|
||||
if (!group) {
|
||||
throw (`群${payload.group_id}不存在`);
|
||||
}
|
||||
if (payload.no_cache || payload.no_cache === 'true') {
|
||||
// webGroupMembers = await WebApi.getGroupMembers(payload.group_id.toString());
|
||||
const _groupMembers = await NTQQGroupApi.getGroupMembers(payload.group_id.toString());
|
||||
groupMembers.set(group.groupCode, _groupMembers);
|
||||
}
|
||||
@ -35,17 +36,17 @@ class GetGroupMemberList extends BaseAction<PayloadType, OB11GroupMember[]> {
|
||||
MemberMap.set(_groupMembers[i].user_id, _groupMembers[i]);
|
||||
}
|
||||
// 合并数据
|
||||
for (let i = 0, len = WebGroupMember.length; i < len; i++) {
|
||||
if (!WebGroupMember[i]?.uin) {
|
||||
for (let i = 0, len = webGroupMembers.length; i < len; i++) {
|
||||
if (!webGroupMembers[i]?.uin) {
|
||||
continue;
|
||||
}
|
||||
const MemberData = MemberMap.get(WebGroupMember[i]?.uin);
|
||||
const MemberData = MemberMap.get(webGroupMembers[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);
|
||||
MemberData.join_time = webGroupMembers[i]?.join_time;
|
||||
MemberData.last_sent_time = webGroupMembers[i]?.last_speak_time;
|
||||
MemberData.qage = webGroupMembers[i]?.qage;
|
||||
MemberData.level = webGroupMembers[i]?.lv.level;
|
||||
MemberMap.set(webGroupMembers[i]?.uin, MemberData);
|
||||
}
|
||||
}
|
||||
// 还原Map到Array
|
||||
|
@ -101,7 +101,9 @@ export class ReverseWebsocket {
|
||||
await this.onmessage(data.toString());
|
||||
});
|
||||
|
||||
this.websocket.on('error', log);
|
||||
this.websocket.on('error', (err) => {
|
||||
logError('websocket error', err.toString());
|
||||
});
|
||||
|
||||
const wsClientInterval = setInterval(() => {
|
||||
postWsEvent(new OB11HeartbeatEvent(!!selfInfo.online, true, heartInterval));
|
||||
|
Loading…
Reference in New Issue
Block a user