From 6f3e27acdc8e2b06faa6bd902a52ea5ef4cd622e Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Tue, 13 Aug 2024 23:53:38 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=9F=20feat:=20=E5=B0=8F=E9=A3=9E?= =?UTF-8?q?=E6=9C=BA=E5=A2=9E=E5=8A=A0=E4=BF=9D=E5=AD=98=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 8 +++++++- utils/tdl-util.js | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/apps/tools.js b/apps/tools.js index 24033b1..d483f1c 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -79,7 +79,7 @@ import { contentEstimator } from "../utils/link-share-summary-util.js"; import { getDS } from "../utils/mihoyo.js"; import { OpenaiBuilder } from "../utils/openai-builder.js"; import { redisExistKey, redisGetKey, redisSetKey } from "../utils/redis-util.js"; -import { startTDL } from "../utils/tdl-util.js"; +import { saveTDL, startTDL } from "../utils/tdl-util.js"; import Translate from "../utils/trans-strategy.js"; import { mid2id } from "../utils/weibo.js"; import { dy2b } from "../utils/yt-dlp-util.js"; @@ -1780,6 +1780,12 @@ export class tools extends plugin { return; } const url = urlRex.exec(e.msg)[0]; + if (e.msg.startsWith("保存")) { + // 发送文件到 SaveMessages + await saveTDL(url, isOversea, this.myProxy); + e.reply("文件已保存到 Save Messages!"); + return true; + } e.reply(`识别:小飞机(学习版)`); const tgSavePath = `${this.getCurDownloadPath(e)}/tg`; // 如果没有文件夹则创建 diff --git a/utils/tdl-util.js b/utils/tdl-util.js index 15d2b36..aa02b7d 100644 --- a/utils/tdl-util.js +++ b/utils/tdl-util.js @@ -29,4 +29,22 @@ export async function startTDL(url, curPath, isOversea, proxyAddr, videoDownload resolve(stdout); }) }) +} + +export async function saveTDL(urk, isOversea, proxyAddr) { + return new Promise((resolve, reject) => { + const proxyStr = isOversea ? `` : `--proxy ${ proxyAddr }`; + const command = `tdl forward --from ${urk} ${proxyStr}` + exec(command, (error, stdout, stderr) => { + if (error) { + reject(`[R插件][TDL]执行出错: ${error.message}`); + return; + } + if (stderr) { + reject(`[R插件][TDL]错误信息: ${stderr}`); + return; + } + resolve(stdout); + }) + }) } \ No newline at end of file