diff --git a/apps/tools.js b/apps/tools.js index f656adf..81dff07 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -72,7 +72,7 @@ import { testProxy, truncateString } from "../utils/common.js"; -import { checkAndRemoveFile, deleteFolderRecursive, getMediaFiles, mkdirIfNotExists } from "../utils/file.js"; +import { checkAndRemoveFile, deleteFolderRecursive, getMediaFilesAndOthers, mkdirIfNotExists } from "../utils/file.js"; import GeneralLinkAdapter from "../utils/general-link-adapter.js"; import { LagrangeAdapter } from "../utils/lagrange-adapter.js"; import { contentEstimator } from "../utils/link-share-summary-util.js"; @@ -1791,7 +1791,7 @@ export class tools extends plugin { await deleteFolderRecursive(tgSavePath); await startTDL(url, tgSavePath, isOversea, this.myProxy, this.videoDownloadConcurrency); // 过滤当前文件 - const mediaFiles = await getMediaFiles(tgSavePath); + const mediaFiles = await getMediaFilesAndOthers(tgSavePath); if (mediaFiles.images.length > 0) { const imagesData = mediaFiles.images.map(item => { const fileContent = fs.readFileSync(`${tgSavePath}/${item}`); @@ -1806,6 +1806,10 @@ export class tools extends plugin { for (const item of mediaFiles.videos) { await this.sendVideoToUpload(e, `${tgSavePath}/${item}`); } + } else { + for (let other of mediaFiles.others) { + await this.uploadGroupFile(e, `${ tgSavePath }/${ other }`); + } } return true; } diff --git a/utils/file.js b/utils/file.js index 24bcc79..54d02ac 100644 --- a/utils/file.js +++ b/utils/file.js @@ -161,7 +161,7 @@ function getMimeType(filePath) { * @param {string} folderPath - 要检测的文件夹路径 * @returns {Promise} 包含图片和视频文件名的对象 */ -export async function getMediaFiles(folderPath) { +export async function getMediaFilesAndOthers(folderPath) { return new Promise((resolve, reject) => { // 定义图片和视频的扩展名 const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp']; @@ -170,6 +170,7 @@ export async function getMediaFiles(folderPath) { // 初始化存储图片和视频的数组 const images = []; const videos = []; + const others = []; // 读取文件夹中的所有文件 fs.readdir(folderPath, (err, files) => { @@ -184,11 +185,13 @@ export async function getMediaFiles(folderPath) { images.push(file); } else if (videoExtensions.includes(ext)) { videos.push(file); + } else { + others.push(file); } }); // 返回包含图片和视频的对象 - resolve({ images, videos }); + resolve({ images, videos, others }); }); }); } \ No newline at end of file