diff --git a/apps/tools.js b/apps/tools.js index 6077f04..fae300c 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -770,7 +770,12 @@ export class tools extends plugin { e.reply(segment.image(url)); } else { // 非海外使用🪜下载 - downloadImg(url, this.getCurDownloadPath(e), "", !isOversea).then(path => { + const proxy = this.myProxy; + const port = this.proxyPort; + downloadImg(url, this.getCurDownloadPath(e), "", !isOversea, {}, { + proxyAddr: proxy, + proxyPort: port + }).then(path => { e.reply(segment.image(fs.readFileSync(path))); }); } diff --git a/utils/common.js b/utils/common.js index 2877167..0168a0c 100644 --- a/utils/common.js +++ b/utils/common.js @@ -185,14 +185,15 @@ export async function downloadAudio(mp3Url, path, title = "temp", redirect = "ma /** * 下载一张网络图片(自动以url的最后一个为名字) - * @param img - * @param dir - * @param fileName - * @param isProxy - * @param headersExt + * @param {string} img + * @param {string} dir + * @param {string} fileName + * @param {boolean} isProxy + * @param {Object} headersExt + * @param {Object} proxyInfo 参数:proxyAddr=地址,proxyPort=端口 * @returns {Promise} */ -export async function downloadImg(img, dir, fileName = "", isProxy = false, headersExt = {}) { +export async function downloadImg(img, dir, fileName = "", isProxy = false, headersExt = {}, proxyInfo = {}) { if (fileName === "") { fileName = img.split("/").pop(); } @@ -210,10 +211,10 @@ export async function downloadImg(img, dir, fileName = "", isProxy = false, head if (isProxy) { axiosConfig.httpAgent = tunnel.httpOverHttp({ - proxy: { host: this.proxyAddr, port: this.proxyPort }, + proxy: { host: proxyInfo.proxyAddr, port: proxyInfo.proxyPort }, }); axiosConfig.httpsAgent = tunnel.httpOverHttp({ - proxy: { host: this.proxyAddr, port: this.proxyPort }, + proxy: { host: proxyInfo.proxyAddr, port: proxyInfo.proxyPort }, }); } try {