mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 13:01:14 +00:00
build-1.2.1-beta1,fix: webapi群成员列表加入缓存,表情回应兼容int类型emoji_id
This commit is contained in:
parent
720fd94b7f
commit
a41cd42e8d
@ -1,5 +1,5 @@
|
|||||||
import { OB11GroupMember } from '../../types';
|
import { OB11GroupMember } from '../../types';
|
||||||
import { getGroup, getGroupMember } from '@/core/data';
|
import { getGroup, getGroupMember, groupMembers } from '@/core/data';
|
||||||
import { OB11Constructor } from '../../constructor';
|
import { OB11Constructor } from '../../constructor';
|
||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
@ -7,11 +7,13 @@ import { NTQQUserApi } from '@/core/apis/user';
|
|||||||
import { log, logDebug } from '@/common/utils/log';
|
import { log, logDebug } from '@/common/utils/log';
|
||||||
import { isNull } from '../../../common/utils/helper';
|
import { isNull } from '../../../common/utils/helper';
|
||||||
import { WebApi } from '@/core/apis/webapi';
|
import { WebApi } from '@/core/apis/webapi';
|
||||||
|
import { NTQQGroupApi } from '@/core';
|
||||||
|
|
||||||
|
|
||||||
export interface PayloadType {
|
export interface PayloadType {
|
||||||
group_id: number;
|
group_id: number;
|
||||||
user_id: number;
|
user_id: number;
|
||||||
|
no_cache?: boolean | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
class GetGroupMemberInfo extends BaseAction<PayloadType, OB11GroupMember> {
|
class GetGroupMemberInfo extends BaseAction<PayloadType, OB11GroupMember> {
|
||||||
@ -22,7 +24,10 @@ class GetGroupMemberInfo extends BaseAction<PayloadType, OB11GroupMember> {
|
|||||||
if (!group) {
|
if (!group) {
|
||||||
throw (`群(${payload.group_id})不存在`);
|
throw (`群(${payload.group_id})不存在`);
|
||||||
}
|
}
|
||||||
const WebGroupMember = await WebApi.getGroupMembers(payload.group_id.toString());
|
const webGroupMembers = await WebApi.getGroupMembers(payload.group_id.toString());
|
||||||
|
if (payload.no_cache == true || payload.no_cache === 'true') {
|
||||||
|
groupMembers.set(group.groupCode, await NTQQGroupApi.getGroupMembers(payload.group_id.toString()));
|
||||||
|
}
|
||||||
const member = await getGroupMember(payload.group_id.toString(), payload.user_id.toString());
|
const member = await getGroupMember(payload.group_id.toString(), payload.user_id.toString());
|
||||||
// log(member);
|
// log(member);
|
||||||
if (member) {
|
if (member) {
|
||||||
@ -35,12 +40,12 @@ class GetGroupMemberInfo extends BaseAction<PayloadType, OB11GroupMember> {
|
|||||||
logDebug('获取群成员详细信息失败, 只能返回基础信息', e);
|
logDebug('获取群成员详细信息失败, 只能返回基础信息', e);
|
||||||
}
|
}
|
||||||
const retMember = OB11Constructor.groupMember(payload.group_id.toString(), member);
|
const retMember = OB11Constructor.groupMember(payload.group_id.toString(), member);
|
||||||
for (let i = 0, len = WebGroupMember.length; i < len; i++) {
|
for (let i = 0, len = webGroupMembers.length; i < len; i++) {
|
||||||
if (WebGroupMember[i]?.uin && WebGroupMember[i].uin === retMember.user_id) {
|
if (webGroupMembers[i]?.uin && webGroupMembers[i].uin === retMember.user_id) {
|
||||||
retMember.join_time = WebGroupMember[i]?.join_time;
|
retMember.join_time = webGroupMembers[i]?.join_time;
|
||||||
retMember.last_sent_time = WebGroupMember[i]?.last_speak_time;
|
retMember.last_sent_time = webGroupMembers[i]?.last_speak_time;
|
||||||
retMember.qage = WebGroupMember[i]?.qage;
|
retMember.qage = webGroupMembers[i]?.qage;
|
||||||
retMember.level = WebGroupMember[i]?.lv.level;
|
retMember.level = webGroupMembers[i]?.lv.level;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,12 @@ class GetGroupMemberList extends BaseAction<PayloadType, OB11GroupMember[]> {
|
|||||||
|
|
||||||
protected async _handle(payload: PayloadType) {
|
protected async _handle(payload: PayloadType) {
|
||||||
const MemberMap: Map<number, OB11GroupMember> = new Map<number, OB11GroupMember>();
|
const MemberMap: Map<number, OB11GroupMember> = new Map<number, OB11GroupMember>();
|
||||||
const WebGroupMember = await WebApi.getGroupMembers(payload.group_id.toString());
|
const webGroupMembers = await WebApi.getGroupMembers(payload.group_id.toString());
|
||||||
const group = await getGroup(payload.group_id.toString());
|
const group = await getGroup(payload.group_id.toString());
|
||||||
if (!group) {
|
if (!group) {
|
||||||
throw (`群${payload.group_id}不存在`);
|
throw (`群${payload.group_id}不存在`);
|
||||||
}
|
}
|
||||||
if (payload.no_cache || payload.no_cache === 'true') {
|
if (payload.no_cache == true || payload.no_cache === 'true') {
|
||||||
// webGroupMembers = await WebApi.getGroupMembers(payload.group_id.toString());
|
// webGroupMembers = await WebApi.getGroupMembers(payload.group_id.toString());
|
||||||
const _groupMembers = await NTQQGroupApi.getGroupMembers(payload.group_id.toString());
|
const _groupMembers = await NTQQGroupApi.getGroupMembers(payload.group_id.toString());
|
||||||
groupMembers.set(group.groupCode, _groupMembers);
|
groupMembers.set(group.groupCode, _groupMembers);
|
||||||
@ -35,17 +35,17 @@ class GetGroupMemberList extends BaseAction<PayloadType, OB11GroupMember[]> {
|
|||||||
MemberMap.set(_groupMembers[i].user_id, _groupMembers[i]);
|
MemberMap.set(_groupMembers[i].user_id, _groupMembers[i]);
|
||||||
}
|
}
|
||||||
// 合并数据
|
// 合并数据
|
||||||
for (let i = 0, len = WebGroupMember.length; i < len; i++) {
|
for (let i = 0, len = webGroupMembers.length; i < len; i++) {
|
||||||
if (!WebGroupMember[i]?.uin) {
|
if (!webGroupMembers[i]?.uin) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const MemberData = MemberMap.get(WebGroupMember[i]?.uin);
|
const MemberData = MemberMap.get(webGroupMembers[i]?.uin);
|
||||||
if (MemberData) {
|
if (MemberData) {
|
||||||
MemberData.join_time = WebGroupMember[i]?.join_time;
|
MemberData.join_time = webGroupMembers[i]?.join_time;
|
||||||
MemberData.last_sent_time = WebGroupMember[i]?.last_speak_time;
|
MemberData.last_sent_time = webGroupMembers[i]?.last_speak_time;
|
||||||
MemberData.qage = WebGroupMember[i]?.qage;
|
MemberData.qage = webGroupMembers[i]?.qage;
|
||||||
MemberData.level = WebGroupMember[i]?.lv.level;
|
MemberData.level = webGroupMembers[i]?.lv.level;
|
||||||
MemberMap.set(WebGroupMember[i]?.uin, MemberData);
|
MemberMap.set(webGroupMembers[i]?.uin, MemberData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 还原Map到Array
|
// 还原Map到Array
|
||||||
|
Loading…
Reference in New Issue
Block a user