From edb31b932ac6152ee269ef1989b1914d1b0e15bc Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Sun, 14 Jul 2024 22:19:08 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20pref:=20=E4=BC=98=E5=8C=96X?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index 2531d04..f7d3124 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -736,6 +736,12 @@ export class tools extends plugin { // 配置参数及解析 const reg = /https?:\/\/x.com\/[0-9-a-zA-Z_]{1,20}\/status\/([0-9]*)/; const twitterUrl = reg.exec(e.msg)[0]; + // 检测 + const isOversea = await this.isOverseasServer(); + if (!isOversea && !(await testProxy(this.proxyAddr, this.proxyPort))) { + e.reply("检测到没有梯子,无法解析小蓝鸟"); + return false; + } // 提取视频 const videoUrl = GENERAL_REQ_LINK.link.replace("{}", twitterUrl); e.reply("识别:小蓝鸟学习版"); @@ -752,7 +758,6 @@ export class tools extends plugin { 'Sec-Fetch-User': '?1', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36', - }, timeout: 10000 // 设置超时时间 } @@ -760,9 +765,17 @@ export class tools extends plugin { axios.get(videoUrl, config).then(resp => { const url = resp.data.data?.url; if (url && (url.endsWith(".jpg") || url.endsWith(".png"))) { - e.reply(segment.image(url)); + if (isOversea) { + // 海外直接下载 + e.reply(segment.image(url)); + } else { + // 非海外使用🪜下载 + this.downloadImg(url, this.getCurDownloadPath(e), "", !isOversea).then(path => { + e.reply(segment.image(fs.readFileSync(path))); + }); + } } else { - this.downloadVideo(url).then(path => { + this.downloadVideo(url, !isOversea).then(path => { e.reply(segment.video(path + "/temp.mp4")); }); }