diff --git a/src/core/apis/user.ts b/src/core/apis/user.ts index 48ad0cfd..2e4a96cd 100644 --- a/src/core/apis/user.ts +++ b/src/core/apis/user.ts @@ -18,30 +18,19 @@ export class NTQQUserApi { async getStatusByUid(uid: string) { return this.context.session.getProfileService().getStatus(uid); } - async getProfileLike(uid: string, start: number, count: number) { + // 默认获取自己的 type = 2 获取别人 type = 1 + async getProfileLike(uid: string, start: number, count: number, type: number = 2) { return this.context.session.getProfileLikeService().getBuddyProfileLike({ friendUids: [uid], basic: 1, vote: 1, favorite: 0, userProfile: 1, - type: 2, + type: type, start: start, limit: count, }); } - async fetchOtherProfileLike(uid: string) { - return this.context.session.getProfileLikeService().getBuddyProfileLike({ - friendUids: [uid], - basic: 1, - vote: 1, - favorite: 0, - userProfile: 0, - type: 1, - start: 0, - limit: 20, - }); - } async setLongNick(longNick: string) { return this.context.session.getProfileService().setLongNick(longNick); } diff --git a/src/onebot/action/extends/GetProfileLike.ts b/src/onebot/action/extends/GetProfileLike.ts index 78112a9a..f77a4060 100644 --- a/src/onebot/action/extends/GetProfileLike.ts +++ b/src/onebot/action/extends/GetProfileLike.ts @@ -1,18 +1,31 @@ import { OneBotAction } from '@/onebot/action/OneBotAction'; import { ActionName } from '@/onebot/action/router'; +import { FromSchema, JSONSchema } from 'json-schema-to-ts'; -interface Payload { - start: number, - count: number -} +const SchemaData = { + type: 'object', + properties: { + user_id: { type: ['number', 'string'] }, + start: { type: ['number', 'string'] }, + count: { type: ['number', 'string'] }, + type: { type: ['number', 'string'] }, + }, +} as const satisfies JSONSchema; + +type Payload = FromSchema; export class GetProfileLike extends OneBotAction { actionName = ActionName.GetProfileLike; - + payloadSchema = SchemaData; async _handle(payload: Payload) { const start = payload.start ? Number(payload.start) : 0; const count = payload.count ? Number(payload.count) : 10; - const ret = await this.core.apis.UserApi.getProfileLike(this.core.selfInfo.uid, start, count); + const type = payload.count ? Number(payload.count) : 2; + const user_uid = + this.core.selfInfo.uin === payload.user_id || !payload.user_id ? + this.core.selfInfo.uid : + await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString()); + const ret = await this.core.apis.UserApi.getProfileLike(user_uid ?? this.core.selfInfo.uid, start, count, type); const listdata = ret.info.userLikeInfos[0].voteInfo.userInfos; for (const item of listdata) { item.uin = parseInt((await this.core.apis.UserApi.getUinByUidV2(item.uid)) || '');