mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 07:29:38 +00:00
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { ActionName } from '@/onebot/action/router';
|
|
import { FileNapCatOneBotUUID } from '@/common/file-uuid';
|
|
import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
|
|
import { z } from 'zod';
|
|
|
|
const SchemaData = z.object({
|
|
group_id: z.union([z.coerce.number(), z.coerce.string()]),
|
|
file_id: z.coerce.string(),
|
|
});
|
|
|
|
type Payload = z.infer<typeof SchemaData>;
|
|
|
|
interface TransGroupFileResponse {
|
|
ok: boolean;
|
|
}
|
|
|
|
export class TransGroupFile extends GetPacketStatusDepends<Payload, TransGroupFileResponse> {
|
|
override actionName = ActionName.TransGroupFile;
|
|
override payloadSchema = SchemaData;
|
|
|
|
async _handle(payload: Payload) {
|
|
const contextMsgFile = FileNapCatOneBotUUID.decode(payload.file_id) || FileNapCatOneBotUUID.decodeModelId(payload.file_id);
|
|
if (contextMsgFile?.fileUUID) {
|
|
const result = await this.core.apis.GroupApi.transGroupFile(payload.group_id.toString(), contextMsgFile.fileUUID);
|
|
if (result.transGroupFileResult.result.retCode === 0) {
|
|
return {
|
|
ok: true
|
|
};
|
|
}
|
|
throw new Error(result.transGroupFileResult.result.retMsg);
|
|
}
|
|
throw new Error('real fileUUID not found!');
|
|
}
|
|
}
|