diff --git a/src/core/apis/user.ts b/src/core/apis/user.ts index ed912396..de985b3e 100644 --- a/src/core/apis/user.ts +++ b/src/core/apis/user.ts @@ -18,7 +18,7 @@ export class NTQQUserApi { async getStatusByUid(uid: string) { return this.context.session.getProfileService().getStatus(uid); } - async getProfileLike(uid: string) { + async getProfileLike(uid: string, start: number, count: number) { return this.context.session.getProfileLikeService().getBuddyProfileLike({ friendUids: [uid], basic: 1, @@ -26,8 +26,8 @@ export class NTQQUserApi { favorite: 0, userProfile: 1, type: 2, - start: 0, - limit: 20, + start: start, + limit: count, }); } async fetchOtherProfileLike(uid: string) { diff --git a/src/onebot/action/extends/GetProfileLike.ts b/src/onebot/action/extends/GetProfileLike.ts index 578bc28e..36910a3c 100644 --- a/src/onebot/action/extends/GetProfileLike.ts +++ b/src/onebot/action/extends/GetProfileLike.ts @@ -1,15 +1,22 @@ import BaseAction from '../BaseAction'; -import { ActionName } from '../types'; +import { ActionName, BaseCheckResult } from '../types'; -export class GetProfileLike extends BaseAction<void, any> { +interface Payload { + start: number, + count: number +} + +export class GetProfileLike extends BaseAction<Payload, any> { actionName = ActionName.GetProfileLike; - async _handle(payload: void) { - const ret = await this.core.apis.UserApi.getProfileLike(this.core.selfInfo.uid); - const listdata: any[] = ret.info.userLikeInfos[0].favoriteInfo.userInfos; + 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 listdata: any[] = ret.info.userLikeInfos[0].voteInfo.userInfos; for (let i = 0; i < listdata.length; i++) { listdata[i].uin = parseInt((await this.core.apis.UserApi.getUinByUidV2(listdata[i].uid)) || ''); } - return listdata; + return ret.info.userLikeInfos[0].voteInfo; } } diff --git a/src/onebot/action/extends/SetInputStatus.ts b/src/onebot/action/extends/SetInputStatus.ts index 35114fdb..9890cb40 100644 --- a/src/onebot/action/extends/SetInputStatus.ts +++ b/src/onebot/action/extends/SetInputStatus.ts @@ -1,16 +1,15 @@ import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import BaseAction from '../BaseAction'; -import { ActionName } from '../types'; +import { ActionName, BaseCheckResult } from '../types'; import { ChatType, Peer } from '@/core'; const SchemaData = { type: 'object', properties: { - eventType: { type: 'string' }, - group_id: { type: 'string' }, - user_id: { type: 'string' }, + event_type: { type: 'number' }, + user_id: { type: ['number', 'string'] }, }, - required: ['eventType'], + required: ['event_type','user_id'], } as const satisfies JSONSchema; type Payload = FromSchema<typeof SchemaData>; @@ -19,23 +18,12 @@ export class SetInputStatus extends BaseAction<Payload, any> { actionName = ActionName.SetInputStatus; async _handle(payload: Payload) { - let peer: Peer; - if (payload.group_id) { - peer = { - chatType: ChatType.KCHATTYPEGROUP, - peerUid: payload.group_id, - }; - } else if (payload.user_id) { - const uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id); - if (!uid) throw new Error('uid is empty'); - peer = { - chatType: ChatType.KCHATTYPEC2C, - peerUid: uid, - }; - } else { - throw new Error('请指定 group_id 或 user_id'); - } - - return await this.core.apis.MsgApi.sendShowInputStatusReq(peer, parseInt(payload.eventType)); + const uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString()); + if (!uid) throw new Error('uid is empty'); + const peer = { + chatType: ChatType.KCHATTYPEC2C, + peerUid: uid, + }; + return await this.core.apis.MsgApi.sendShowInputStatusReq(peer, payload.event_type); } }