NapCatQQ/src/onebot/action/user/GetFriendList.ts
手瓜一十雪 4fac6d5aa3 chore: 解耦
2024-08-22 14:05:01 +08:00

26 lines
917 B
TypeScript

import { OB11User } from '../../types';
import { OB11Constructor } from '@/onebot/helper/converter';
import BaseAction from '../BaseAction';
import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
// no_cache get时传字符串
const SchemaData = {
type: 'object',
properties: {
no_cache: { type: ['boolean', 'string'] },
},
} as const satisfies JSONSchema;
type Payload = FromSchema<typeof SchemaData>;
export default class GetFriendList extends BaseAction<Payload, OB11User[]> {
actionName = ActionName.GetFriendList;
PayloadSchema = SchemaData;
async _handle(payload: Payload) {
//全新逻辑
const NTQQFriendApi = this.CoreContext.apis.FriendApi;
return OB11Constructor.friendsV2(await NTQQFriendApi.getBuddyV2(typeof payload.no_cache === 'string' ? payload.no_cache === 'true' : !!payload.no_cache));
}
}