diff --git a/src/common/fall-back.ts b/src/common/fall-back.ts index dc47919c..52021b3a 100644 --- a/src/common/fall-back.ts +++ b/src/common/fall-back.ts @@ -20,19 +20,19 @@ export class Fallback { for (const handler of this.handlers) { try { const result = await handler(); - try { - return await this.checker(result); - } catch (checkerError) { - errors.push(checkerError instanceof Error ? checkerError : new Error(String(checkerError))); + let data = await this.checker(result); + if (data) { + return data; } } catch (error) { + console.log(error); errors.push(error instanceof Error ? error : new Error(String(error))); } } throw new AggregateError(errors, 'All handlers failed'); } } -export class FallbackUtil{ +export class FallbackUtil { static boolchecker(value: T, condition: boolean): T { if (condition) { return value; diff --git a/src/core/apis/user.ts b/src/core/apis/user.ts index 6d1d3a09..28476942 100644 --- a/src/core/apis/user.ts +++ b/src/core/apis/user.ts @@ -193,7 +193,7 @@ export class NTQQUserApi { .add(() => this.context.session.getGroupService().getUidByUins([uin]).then((data) => data.uids.get(uin))) .add(() => this.getUserDetailInfoByUin(uin).then((data) => data.detail.uid)); - const uid = await fallback.run().catch(() => '0'); + const uid = await fallback.run().catch(() => ''); return uid ?? ''; } diff --git a/src/onebot/action/go-cqhttp/GetStrangerInfo.ts b/src/onebot/action/go-cqhttp/GetStrangerInfo.ts index 6cb1b63b..8acf0a5f 100644 --- a/src/onebot/action/go-cqhttp/GetStrangerInfo.ts +++ b/src/onebot/action/go-cqhttp/GetStrangerInfo.ts @@ -13,12 +13,13 @@ type Payload = Static; export default class GoCQHTTPGetStrangerInfo extends OneBotAction { actionName = ActionName.GoCQHTTP_GetStrangerInfo; - + payloadSchema = SchemaData; async _handle(payload: Payload): Promise { const user_id = payload.user_id.toString(); 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; + console.log(uid); const info = (await this.core.apis.UserApi.getUserDetailInfo(uid)); return { ...extendData.detail.simpleInfo.coreInfo,