mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { ActionName } from '@/onebot/action/router';
|
|
import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
|
|
import { AIVoiceChatType } from '@/core/packet/entities/aiChat';
|
|
import { z } from 'zod';
|
|
import { actionType } from '../type';
|
|
const SchemaData = z.object({
|
|
group_id: actionType.string(),
|
|
chat_type: actionType.number().default(1),
|
|
});
|
|
|
|
type Payload = z.infer<typeof SchemaData>;
|
|
|
|
interface GetAiCharactersResponse {
|
|
type: string;
|
|
characters: {
|
|
character_id: string;
|
|
character_name: string;
|
|
preview_url: string;
|
|
}[];
|
|
}
|
|
|
|
export class GetAiCharacters extends GetPacketStatusDepends<Payload, GetAiCharactersResponse[]> {
|
|
override actionName = ActionName.GetAiCharacters;
|
|
override payloadSchema = SchemaData;
|
|
|
|
async _handle(payload: Payload) {
|
|
const rawList = await this.core.apis.PacketApi.pkt.operation.FetchAiVoiceList(+payload.group_id, +payload.chat_type as AIVoiceChatType);
|
|
return rawList?.map((item) => ({
|
|
type: item.category,
|
|
characters: item.voices.map((voice) => ({
|
|
character_id: voice.voiceId,
|
|
character_name: voice.voiceDisplayName,
|
|
preview_url: voice.voiceExampleUrl,
|
|
})),
|
|
})) ?? [];
|
|
}
|
|
}
|