fix: GetProfileLike

This commit is contained in:
手瓜一十雪
2024-11-22 15:58:40 +08:00
parent 515c1af676
commit e7e8763f1c
2 changed files with 22 additions and 20 deletions

View File

@@ -18,30 +18,19 @@ export class NTQQUserApi {
async getStatusByUid(uid: string) { async getStatusByUid(uid: string) {
return this.context.session.getProfileService().getStatus(uid); 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({ return this.context.session.getProfileLikeService().getBuddyProfileLike({
friendUids: [uid], friendUids: [uid],
basic: 1, basic: 1,
vote: 1, vote: 1,
favorite: 0, favorite: 0,
userProfile: 1, userProfile: 1,
type: 2, type: type,
start: start, start: start,
limit: count, 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) { async setLongNick(longNick: string) {
return this.context.session.getProfileService().setLongNick(longNick); return this.context.session.getProfileService().setLongNick(longNick);
} }

View File

@@ -1,18 +1,31 @@
import { OneBotAction } from '@/onebot/action/OneBotAction'; import { OneBotAction } from '@/onebot/action/OneBotAction';
import { ActionName } from '@/onebot/action/router'; import { ActionName } from '@/onebot/action/router';
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
interface Payload { const SchemaData = {
start: number, type: 'object',
count: number 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<typeof SchemaData>;
export class GetProfileLike extends OneBotAction<Payload, any> { export class GetProfileLike extends OneBotAction<Payload, any> {
actionName = ActionName.GetProfileLike; actionName = ActionName.GetProfileLike;
payloadSchema = SchemaData;
async _handle(payload: Payload) { async _handle(payload: Payload) {
const start = payload.start ? Number(payload.start) : 0; const start = payload.start ? Number(payload.start) : 0;
const count = payload.count ? Number(payload.count) : 10; 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; const listdata = ret.info.userLikeInfos[0].voteInfo.userInfos;
for (const item of listdata) { for (const item of listdata) {
item.uin = parseInt((await this.core.apis.UserApi.getUinByUidV2(item.uid)) || ''); item.uin = parseInt((await this.core.apis.UserApi.getUinByUidV2(item.uid)) || '');