mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-26 02:31:20 +08:00
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { ActionName } from '@/onebot/action/router';
|
|
import { FileNapCatOneBotUUID } from '@/common/file-uuid';
|
|
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
|
|
import { Static, Type } from '@sinclair/typebox';
|
|
|
|
const SchemaData = Type.Object({
|
|
group_id: Type.Union([Type.Number(), Type.String()]),
|
|
file_id: Type.String(),
|
|
});
|
|
|
|
type Payload = Static<typeof SchemaData>;
|
|
|
|
interface GetGroupFileUrlResponse {
|
|
url?: string;
|
|
}
|
|
|
|
export class GetGroupFileUrl extends GetPacketStatusDepends<Payload, GetGroupFileUrlResponse> {
|
|
actionName = ActionName.GOCQHTTP_GetGroupFileUrl;
|
|
payloadSchema = SchemaData;
|
|
|
|
async _handle(payload: Payload) {
|
|
const contextMsgFile = FileNapCatOneBotUUID.decode(payload.file_id) || FileNapCatOneBotUUID.decodeModelId(payload.file_id);
|
|
if (contextMsgFile?.fileUUID) {
|
|
return {
|
|
url: await this.core.apis.PacketApi.pkt.operation.GetGroupFileUrl(+payload.group_id, contextMsgFile.fileUUID)
|
|
};
|
|
}
|
|
throw new Error('real fileUUID not found!');
|
|
}
|
|
}
|