mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
fix
This commit is contained in:
@@ -44,13 +44,22 @@ export class NTQQGroupApi {
|
||||
}
|
||||
|
||||
async initApi() {
|
||||
this.initCache().then().catch(e => this.context.logger.logError(e));
|
||||
await this.initCache().then().catch(e => this.context.logger.logError(e));
|
||||
}
|
||||
|
||||
async initCache() {
|
||||
let promises: Promise<void>[] = [];
|
||||
for (const group of await this.getGroups(true)) {
|
||||
this.refreshGroupMemberCache(group.groupCode, false).then().catch(e => this.context.logger.logError(e));
|
||||
let user = await this.refreshGroupMemberCache(group.groupCode, false).then().catch(e => this.context.logger.logError(e));
|
||||
if (user) {
|
||||
for (const member of user) {
|
||||
let promise = this.core.apis.UserApi.fetchUserDetailInfoV3(member[1].uid).then(_ => void 0).catch(e => this.context.logger.logError(e));
|
||||
promises.push(promise);
|
||||
}
|
||||
}
|
||||
}
|
||||
await Promise.all(promises);
|
||||
this.context.logger.logDebug('[NapCat] [Mark] 群成员缓存初始化完成');
|
||||
}
|
||||
|
||||
async fetchGroupEssenceList(groupCode: string) {
|
||||
|
@@ -93,6 +93,15 @@ export class NTQQUserApi {
|
||||
return profile;
|
||||
}
|
||||
|
||||
async fetchUserDetailInfoV3(uid: string) {
|
||||
let cache = await this.fetchUserDetailInfoV2(uid, UserDetailSource.KDB);
|
||||
if (!cache.commonExt) {
|
||||
cache = await this.fetchUserDetailInfoV2(uid, UserDetailSource.KSERVER);
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
||||
|
||||
async getUserDetailInfoV2(uid: string) {
|
||||
let retUser = await solveAsyncProblem(async (uid) => this.fetchUserDetailInfoV2(uid, UserDetailSource.KDB), uid);
|
||||
if (retUser && retUser.uin !== '0') {
|
||||
@@ -192,7 +201,7 @@ export class NTQQUserApi {
|
||||
.add(() => this.context.session.getUixConvertService().getUin([uid]).then((data) => data.uinInfo.get(uid)))
|
||||
.add(() => this.context.session.getProfileService().getUinByUid('FriendsServiceImpl', [uid]).get(uid))
|
||||
.add(() => this.context.session.getGroupService().getUinByUids([uid]).then((data) => data.uins.get(uid)))
|
||||
.add(() => this.getUserDetailInfoV2(uid).then((data) => data.uin));
|
||||
.add(() => this.fetchUserDetailInfoV2(uid).then((data) => data.uin));
|
||||
|
||||
const uin = await fallback.run().catch(() => '0');
|
||||
return uin ?? '0';
|
||||
|
@@ -19,7 +19,7 @@ export default class GoCQHTTPGetStrangerInfo extends OneBotAction<Payload, OB11U
|
||||
const extendData = await this.core.apis.UserApi.getUserDetailInfoByUin(user_id);
|
||||
let uid = (await this.core.apis.UserApi.getUidByUinV2(user_id));
|
||||
if (!uid) uid = extendData.detail.uid;
|
||||
const info = (await this.core.apis.UserApi.getUserDetailInfoV2(uid));
|
||||
const info = (await this.core.apis.UserApi.fetchUserDetailInfoV2(uid));
|
||||
return {
|
||||
...extendData.detail.simpleInfo.coreInfo,
|
||||
...extendData.detail.commonExt ?? {},
|
||||
|
@@ -16,7 +16,7 @@ export class SetQQProfile extends OneBotAction<Payload, Awaited<ReturnType<NTQQU
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const self = this.core.selfInfo;
|
||||
const OldProfile = await this.core.apis.UserApi.getUserDetailInfoV2(self.uid);
|
||||
const OldProfile = await this.core.apis.UserApi.fetchUserDetailInfoV2(self.uid);
|
||||
return await this.core.apis.UserApi.modifySelfProfile({
|
||||
nick: payload.nickname,
|
||||
longNick: (payload?.personal_note ?? OldProfile?.simpleInfo!.baseInfo.longNick) || '',
|
||||
|
@@ -32,7 +32,7 @@ class GetGroupMemberInfo extends OneBotAction<Payload, OB11GroupMember> {
|
||||
|
||||
const [member, info] = await Promise.all([
|
||||
this.core.apis.GroupApi.getGroupMemberEx(payload.group_id.toString(), uid, isNocache),
|
||||
this.core.apis.UserApi.getUserDetailInfoV2(uid),
|
||||
this.core.apis.UserApi.fetchUserDetailInfoV2(uid),
|
||||
]);
|
||||
|
||||
if (!member || !groupMember) throw new Error(`群(${payload.group_id})成员${payload.user_id}不存在`);
|
||||
|
@@ -29,7 +29,7 @@ export class GetGroupMemberList extends OneBotAction<Payload, OB11GroupMember[]>
|
||||
|
||||
// 批量并行获取用户详情
|
||||
const userDetailsPromises = memberArray.map(member =>
|
||||
this.core.apis.UserApi.getUserDetailInfoV2(member.uin)
|
||||
this.core.apis.UserApi.fetchUserDetailInfoV2(member.uid)
|
||||
.catch(_ => {
|
||||
return { uin: member.uin, uid: member.uid };
|
||||
})
|
||||
|
@@ -21,7 +21,7 @@ export default class GetFriendList extends OneBotAction<Payload, OB11User[]> {
|
||||
|
||||
// 批量并行获取用户详情
|
||||
const userDetailsPromises = buddyArray.map(member =>
|
||||
this.core.apis.UserApi.getUserDetailInfoV2(member.uin ?? '')
|
||||
this.core.apis.UserApi.fetchUserDetailInfoV2(member.uid)
|
||||
.catch(_ => {
|
||||
return { uin: member.uin, uid: member.uid };
|
||||
})
|
||||
|
@@ -444,7 +444,7 @@ export class OneBotMsgApi {
|
||||
}
|
||||
const uid = await this.core.apis.UserApi.getUidByUinV2(`${atQQ}`);
|
||||
if (!uid) throw new Error('Get Uid Error');
|
||||
const info = await this.core.apis.UserApi.getUserDetailInfoV2(uid);
|
||||
const info = await this.core.apis.UserApi.fetchUserDetailInfoV2(uid);
|
||||
return at(atQQ, uid, NTMsgAtType.ATTYPEONE, info.simpleInfo?.coreInfo.nick || '');
|
||||
},
|
||||
|
||||
@@ -845,7 +845,7 @@ export class OneBotMsgApi {
|
||||
return;
|
||||
}
|
||||
}
|
||||
resMsg.sender.nickname = (await this.core.apis.UserApi.getUserDetailInfoV2(msg.senderUid)).simpleInfo?.coreInfo.nick || '';
|
||||
resMsg.sender.nickname = (await this.core.apis.UserApi.fetchUserDetailInfoV2(msg.senderUid)).simpleInfo?.coreInfo.nick || '';
|
||||
}
|
||||
|
||||
private async handleTempGroupMessage(resMsg: OB11Message, msg: RawMessage) {
|
||||
|
@@ -100,7 +100,7 @@ export class NapCatOneBot11Adapter {
|
||||
|
||||
const ob11Config = this.configLoader.configData;
|
||||
|
||||
this.core.apis.UserApi.getUserDetailInfoV2(this.core.selfInfo.uid)
|
||||
this.core.apis.UserApi.fetchUserDetailInfoV2(this.core.selfInfo.uid)
|
||||
.then((user) => {
|
||||
this.core.selfInfo = { ...user, online: this.core.selfInfo.online };
|
||||
this.context.logger.setLogSelfInfo({ nick: this.core.selfInfo.simpleInfo?.coreInfo.nick ?? '', uid: this.core.selfInfo.uid });
|
||||
|
Reference in New Issue
Block a user