From 83e73d984231f0f6555dbab0b4e71814ae4a8740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Thu, 27 Mar 2025 12:15:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/apis/user.ts | 52 ++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/src/core/apis/user.ts b/src/core/apis/user.ts index 64c1f799..93e81c5e 100644 --- a/src/core/apis/user.ts +++ b/src/core/apis/user.ts @@ -90,7 +90,30 @@ export class NTQQUserApi { () => true, (profile) => profile.uid === uid, ); - const RetUser: User = { + return profile; + } + + async getUserDetailInfo(uid: string): Promise { + let profile = await solveAsyncProblem(async (uid) => this.fetchUserDetailInfo(uid, UserDetailSource.KDB), uid); + if (profile && profile.uin !== '0' && profile.commonExt) { + return { + ...profile.simpleInfo.status, + ...profile.simpleInfo.vasInfo, + ...profile.commonExt, + ...profile.simpleInfo.baseInfo, + ...profile.simpleInfo.coreInfo, + qqLevel: profile.commonExt?.qqLevel, + age: profile.simpleInfo.baseInfo.age, + pendantId: '', + nick: profile.simpleInfo.coreInfo.nick || '', + }; + } + this.context.logger.logDebug('[NapCat] [Mark] getUserDetailInfo Mode1 Failed.'); + profile = await this.fetchUserDetailInfo(uid, UserDetailSource.KSERVER); + if (profile && profile.uin === '0') { + profile.uin = await this.core.apis.UserApi.getUidByUinV2(uid) ?? '0'; + } + return { ...profile.simpleInfo.status, ...profile.simpleInfo.vasInfo, ...profile.commonExt, @@ -101,33 +124,6 @@ export class NTQQUserApi { pendantId: '', nick: profile.simpleInfo.coreInfo.nick || '', }; - return RetUser; - } - - async getUserDetailInfo(uid: string): Promise { - let retUser = await solveAsyncProblem(async (uid) => this.fetchUserDetailInfo(uid, UserDetailSource.KDB), uid); - if (retUser && retUser.uin !== '0') { - return retUser; - } - this.context.logger.logDebug('[NapCat] [Mark] getUserDetailInfo Mode1 Failed.'); - retUser = await this.fetchUserDetailInfo(uid, UserDetailSource.KSERVER); - if (retUser && retUser.uin === '0') { - retUser.uin = await this.core.apis.UserApi.getUidByUinV2(uid) ?? '0'; - } - return retUser; - } - - async getUserDetailInfoV2(uid: string): Promise { - const fallback = new Fallback((user) => FallbackUtil.boolchecker(user, user !== undefined && user.uin !== '0')) - .add(() => this.fetchUserDetailInfo(uid, UserDetailSource.KDB)) - .add(() => this.fetchUserDetailInfo(uid, UserDetailSource.KSERVER)); - const retUser = await fallback.run().then(async (user) => { - if (user && user.uin === '0') { - user.uin = await this.core.apis.UserApi.getUidByUinV2(uid) ?? '0'; - } - return user; - }); - return retUser; } async modifySelfProfile(param: ModifyProfileParams) {