diff --git a/src/onebot/action/file/GetFile.ts b/src/onebot/action/file/GetFile.ts index 40f705ca..521d82a4 100644 --- a/src/onebot/action/file/GetFile.ts +++ b/src/onebot/action/file/GetFile.ts @@ -5,9 +5,9 @@ import { ActionName } from '../types'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { OB11MessageImage, OB11MessageVideo } from '@/onebot/types'; -export interface GetFilePayload { - file: string; // 文件名或者fileUuid -} +// interface GetFilePayload { +// file: string; // 文件名或者fileUuid +// } export interface GetFileResponse { file?: string; // path @@ -16,19 +16,25 @@ export interface GetFileResponse { file_name?: string; base64?: string; } - const GetFileBase_PayloadSchema = { type: 'object', properties: { file: { type: 'string' }, + file_id: { type: 'string' } }, - required: ['file'], + oneOf: [ + { required: ['file'] }, + { required: ['file_id'] } + ] } as const satisfies JSONSchema; +export type GetFilePayload = FromSchema; + export class GetFileBase extends BaseAction { - payloadSchema: any = GetFileBase_PayloadSchema; + payloadSchema = GetFileBase_PayloadSchema; async _handle(payload: GetFilePayload): Promise { + payload.file ||= payload.file_id || ''; //接收消息标记模式 const contextMsgFile = FileNapCatOneBotUUID.decode(payload.file); if (contextMsgFile) { @@ -115,27 +121,6 @@ export class GetFileBase extends BaseAction { } } -const GetFile_PayloadSchema = { - type: 'object', - properties: { - file_id: { type: 'string' }, - file: { type: 'string' }, - }, - required: ['file_id'], -} as const satisfies JSONSchema; - -type GetFile_Payload_Internal = FromSchema; - -interface GetFile_Payload extends GetFile_Payload_Internal { - file: string; -} - export default class GetFile extends GetFileBase { actionName = ActionName.GetFile; - payloadSchema = GetFile_PayloadSchema; - - async _handle(payload: GetFile_Payload): Promise { - payload.file = payload.file_id; - return super._handle(payload); - } } diff --git a/src/onebot/action/msg/MarkMsgAsRead.ts b/src/onebot/action/msg/MarkMsgAsRead.ts index bfbc0e7a..279f4966 100644 --- a/src/onebot/action/msg/MarkMsgAsRead.ts +++ b/src/onebot/action/msg/MarkMsgAsRead.ts @@ -1,7 +1,7 @@ import { ChatType, Peer } from '@/core/entities'; +import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import BaseAction from '../BaseAction'; import { ActionName } from '../types'; -import { FromSchema, JSONSchema } from 'json-schema-to-ts'; const SchemaData = { type: 'object', @@ -49,23 +49,14 @@ export class MarkGroupMsgAsRead extends MarkMsgAsRead { actionName = ActionName.MarkGroupMsgAsRead; } - -interface Payload { - message_id: number; -} - -export class GoCQHTTPMarkMsgAsRead extends BaseAction { +export class GoCQHTTPMarkMsgAsRead extends MarkMsgAsRead { actionName = ActionName.GoCQHTTP_MarkMsgAsRead; - - async _handle(payload: Payload): Promise { - return null; - } } -export class MarkAllMsgAsRead extends BaseAction { +export class MarkAllMsgAsRead extends BaseAction { actionName = ActionName._MarkAllMsgAsRead; - async _handle(payload: Payload): Promise { + async _handle(): Promise { await this.core.apis.MsgApi.markAllMsgAsRead(); return null; }