mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
fix: 多处修复
1.修复部分Uin转换失败导致的相关API错误 2.继续改进get_group_member_info效率 3.增加fetchUserDetailInfo容错(暂时性/待观察)
This commit is contained in:
parent
698624b4dc
commit
836eb7b708
@ -261,7 +261,7 @@ export class NTQQGroupApi {
|
|||||||
(
|
(
|
||||||
'NodeIKernelGroupListener/onMemberInfoChange',
|
'NodeIKernelGroupListener/onMemberInfoChange',
|
||||||
1,
|
1,
|
||||||
forced ? 5000 : 500,
|
forced ? 5000 : 250,
|
||||||
(params) => {
|
(params) => {
|
||||||
return params === GroupCode;
|
return params === GroupCode;
|
||||||
},
|
},
|
||||||
@ -269,7 +269,7 @@ export class NTQQGroupApi {
|
|||||||
const EventFunc = this.core.eventWrapper.createEventFunction<EventType>('NodeIKernelGroupService/getMemberInfo');
|
const EventFunc = this.core.eventWrapper.createEventFunction<EventType>('NodeIKernelGroupService/getMemberInfo');
|
||||||
const retData = await EventFunc!(GroupCode, [uid], forced);
|
const retData = await EventFunc!(GroupCode, [uid], forced);
|
||||||
if (retData.result !== 0) {
|
if (retData.result !== 0) {
|
||||||
throw new Error(`获取群成员信息失败: ${retData.errMsg}`);
|
throw new Error(`${retData.errMsg}`);
|
||||||
}
|
}
|
||||||
const result = await Listener as unknown;
|
const result = await Listener as unknown;
|
||||||
let member: GroupMember | undefined;
|
let member: GroupMember | undefined;
|
||||||
|
@ -120,7 +120,7 @@ export class NTQQUserApi {
|
|||||||
...profile.simpleInfo.vasInfo,
|
...profile.simpleInfo.vasInfo,
|
||||||
...profile.commonExt,
|
...profile.commonExt,
|
||||||
...profile.simpleInfo.baseInfo,
|
...profile.simpleInfo.baseInfo,
|
||||||
qqLevel: profile.commonExt.qqLevel,
|
qqLevel: profile.commonExt?.qqLevel,
|
||||||
age: profile.simpleInfo.baseInfo.age,
|
age: profile.simpleInfo.baseInfo.age,
|
||||||
pendantId: '',
|
pendantId: '',
|
||||||
};
|
};
|
||||||
@ -130,7 +130,7 @@ export class NTQQUserApi {
|
|||||||
async getUserDetailInfo(uid: string) {
|
async getUserDetailInfo(uid: string) {
|
||||||
const ret = await this.fetchUserDetailInfo(uid, UserDetailSource.KDB);
|
const ret = await this.fetchUserDetailInfo(uid, UserDetailSource.KDB);
|
||||||
if (ret.uin === '0') {
|
if (ret.uin === '0') {
|
||||||
console.log('[NapCat] [Mark] getUserDetailInfo Mode1 Failed.')
|
this.context.logger.logDebug('[NapCat] [Mark] getUserDetailInfo Mode1 Failed.')
|
||||||
return await this.fetchUserDetailInfo(uid, UserDetailSource.KSERVER);
|
return await this.fetchUserDetailInfo(uid, UserDetailSource.KSERVER);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -207,9 +207,9 @@ export class NTQQUserApi {
|
|||||||
|
|
||||||
//后期改成流水线处理
|
//后期改成流水线处理
|
||||||
async getUinByUidV2(Uid: string) {
|
async getUinByUidV2(Uid: string) {
|
||||||
let uin = (await this.context.session.getProfileService().getUinByUid('FriendsServiceImpl', [Uid])).get(Uid);
|
let uin = (await this.context.session.getGroupService().getUinByUids([Uid])).uins.get(Uid);
|
||||||
if (uin) return uin;
|
if (uin) return uin;
|
||||||
uin = (await this.context.session.getGroupService().getUinByUids([Uid])).uins.get(Uid);
|
uin = (await this.context.session.getProfileService().getUinByUid('FriendsServiceImpl', [Uid])).get(Uid);
|
||||||
if (uin) return uin;
|
if (uin) return uin;
|
||||||
uin = (await this.context.session.getUixConvertService().getUin([Uid])).uinInfo.get(Uid);
|
uin = (await this.context.session.getUixConvertService().getUin([Uid])).uinInfo.get(Uid);
|
||||||
if (uin) return uin;
|
if (uin) return uin;
|
||||||
|
@ -3,6 +3,7 @@ import { OB11Constructor } from '../../helper/data';
|
|||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
import { GroupMember } from '@/core';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@ -23,23 +24,25 @@ class GetGroupMemberInfo extends BaseAction<Payload, OB11GroupMember> {
|
|||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||||
const NTQQGroupApi = this.CoreContext.apis.GroupApi;
|
const NTQQGroupApi = this.CoreContext.apis.GroupApi;
|
||||||
const NTQQWebApi = this.CoreContext.apis.WebApi;
|
|
||||||
const isNocache = typeof payload.no_cache === 'string' ? payload.no_cache === 'true' : !!payload.no_cache;
|
const isNocache = typeof payload.no_cache === 'string' ? payload.no_cache === 'true' : !!payload.no_cache;
|
||||||
const uid = await NTQQUserApi.getUidByUinV2(payload.user_id.toString());
|
const uid = await NTQQUserApi.getUidByUinV2(payload.user_id.toString());
|
||||||
if (!uid) throw (`Uin2Uid Error ${payload.user_id}不存在`);
|
if (!uid) throw (`Uin2Uid Error ${payload.user_id}不存在`);
|
||||||
const member = await NTQQGroupApi.getGroupMemberV2(payload.group_id.toString(), uid, isNocache);
|
const [member, info] = await Promise.allSettled([
|
||||||
if (!member) throw (`群(${payload.group_id})成员${payload.user_id}不存在`);
|
NTQQGroupApi.getGroupMemberV2(payload.group_id.toString(), uid, isNocache),
|
||||||
try {
|
NTQQUserApi.getUserDetailInfo(uid),
|
||||||
const info = (await NTQQUserApi.getUserDetailInfo(member.uid));
|
]);
|
||||||
this.CoreContext.context.logger.logDebug('群成员详细信息结果', info);
|
if (member.status !== 'fulfilled') throw (`群(${payload.group_id})成员${payload.user_id}不存在 ${member.reason}`);
|
||||||
Object.assign(member, info);
|
if (info.status === 'fulfilled') {
|
||||||
} catch (e) {
|
this.CoreContext.context.logger.logDebug("群成员详细信息结果", info.value);
|
||||||
this.CoreContext.context.logger.logDebug('获取群成员详细信息失败, 只能返回基础信息', e);
|
Object.assign(member, info.value);
|
||||||
|
} else {
|
||||||
|
this.CoreContext.context.logger.logDebug(`获取群成员详细信息失败, 只能返回基础信息 ${info.reason}`);
|
||||||
}
|
}
|
||||||
const date = Math.round(Date.now() / 1000);
|
const date = Math.round(Date.now() / 1000);
|
||||||
const retMember = OB11Constructor.groupMember(payload.group_id.toString(), member);
|
const retMember = OB11Constructor.groupMember(payload.group_id.toString(), member.value as GroupMember);
|
||||||
retMember.last_sent_time = parseInt((await this.CoreContext.apis.GroupApi.getGroupMember(payload.group_id.toString(), retMember.user_id))?.lastSpeakTime || date.toString());
|
const Member = await this.CoreContext.apis.GroupApi.getGroupMember(payload.group_id.toString(), retMember.user_id);
|
||||||
retMember.join_time = parseInt((await this.CoreContext.apis.GroupApi.getGroupMember(payload.group_id.toString(), retMember.user_id))?.joinTime || date.toString());
|
retMember.last_sent_time = parseInt(Member?.lastSpeakTime || date.toString());
|
||||||
|
retMember.join_time = parseInt(Member?.joinTime || date.toString());
|
||||||
return retMember;
|
return retMember;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user