🌟 feat: 小飞机增加保存能力

This commit is contained in:
zhiyu1998 2024-08-13 23:53:38 +08:00
parent 823e9ddbb5
commit 6f3e27acdc
2 changed files with 25 additions and 1 deletions

View File

@ -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`;
// 如果没有文件夹则创建

View File

@ -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);
})
})
}