Add upload_file option for file upload actions

Introduces an 'upload_file' boolean option to group and private file upload actions, allowing control over whether files are uploaded to group storage or sent directly. Updates the NTQQFileApi and OneBotFileApi to support this option and adjusts file handling logic accordingly.
This commit is contained in:
手瓜一十雪
2026-01-03 16:25:38 +08:00
parent 612a01259d
commit 4f927a8ccd
4 changed files with 34 additions and 21 deletions

View File

@@ -19,16 +19,18 @@ export class OneBotFileApi {
this.core = core;
}
async createValidSendFileElement (context: SendMessageContext, filePath: string, fileName: string = '', folderId: string = ''): Promise<SendFileElement> {
async createValidSendFileElement (context: SendMessageContext, filePath: string, fileName: string = '', folderId: string = '', uploadGroupFile: boolean = false): Promise<SendFileElement> {
const {
fileName: _fileName,
path,
fileSize,
} = await this.core.apis.FileApi.uploadFile(filePath, ElementType.FILE);
} = await this.core.apis.FileApi.uploadFile(filePath, ElementType.FILE, 0, uploadGroupFile);
if (fileSize === 0) {
throw new Error('文件异常大小为0');
}
context.deleteAfterSentFiles.push(path);
if (uploadGroupFile) {
context.deleteAfterSentFiles.push(path);
}
return {
elementType: ElementType.FILE,
elementId: '',