diff --git a/src/onebot11/action/GetFile.ts b/src/onebot11/action/GetFile.ts index 703e383..dd33878 100644 --- a/src/onebot11/action/GetFile.ts +++ b/src/onebot11/action/GetFile.ts @@ -19,6 +19,7 @@ export interface GetFileResponse{ export class GetFileBase extends BaseAction{ protected async _handle(payload: GetFilePayload): Promise { const cache = fileCache.get(payload.file) + const {autoDeleteFile, enableLocalFile2Url, autoDeleteFileSecond} = getConfigUtil().getConfig() if (!cache) { throw new Error('file not found') } @@ -31,11 +32,16 @@ export class GetFileBase extends BaseAction{ file_size: cache.fileSize, file_name: cache.fileName } - if (getConfigUtil().getConfig().enableLocalFile2Url) { + if (enableLocalFile2Url) { if (!cache.url) { res.base64 = await fs.readFile(cache.filePath, 'base64') } } + if (autoDeleteFile) { + setTimeout(() => { + fs.unlink(cache.filePath) + }, autoDeleteFileSecond * 1000) + } return res } } \ No newline at end of file