mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
fix: getfile
This commit is contained in:
parent
1aa1f4c212
commit
052d17a46f
@ -16,13 +16,16 @@ export interface GetFileResponse {
|
|||||||
file_name?: string;
|
file_name?: string;
|
||||||
base64?: string;
|
base64?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const GetFileBase_PayloadSchema = {
|
const GetFileBase_PayloadSchema = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
file: { type: 'string' },
|
file: { type: 'string' },
|
||||||
file_id: { type: "string" }
|
file_id: { type: 'string' }
|
||||||
}
|
},
|
||||||
|
oneOf: [
|
||||||
|
{ required: ['file'] },
|
||||||
|
{ required: ['file_id'] }
|
||||||
|
]
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
export type GetFilePayload = FromSchema<typeof GetFileBase_PayloadSchema>;
|
export type GetFilePayload = FromSchema<typeof GetFileBase_PayloadSchema>;
|
||||||
@ -31,13 +34,7 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
|||||||
payloadSchema = GetFileBase_PayloadSchema;
|
payloadSchema = GetFileBase_PayloadSchema;
|
||||||
|
|
||||||
async _handle(payload: GetFilePayload): Promise<GetFileResponse> {
|
async _handle(payload: GetFilePayload): Promise<GetFileResponse> {
|
||||||
if(!payload.file){
|
payload.file ||= payload.file_id || '';
|
||||||
if(payload.file_id){
|
|
||||||
payload.file = payload.file_id;
|
|
||||||
}else{
|
|
||||||
throw new Error('必须传入 file 或 file_id');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//接收消息标记模式
|
//接收消息标记模式
|
||||||
const contextMsgFile = FileNapCatOneBotUUID.decode(payload.file);
|
const contextMsgFile = FileNapCatOneBotUUID.decode(payload.file);
|
||||||
if (contextMsgFile) {
|
if (contextMsgFile) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user