mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
🐞 fix: 修复 x
不能解析问题
This commit is contained in:
parent
08ef33eac9
commit
61f6da08f2
@ -910,59 +910,56 @@ export class tools extends plugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 配置参数及解析
|
// 配置参数及解析
|
||||||
const reg = /https?:\/\/x.com\/[0-9-a-zA-Z_]{1,20}\/status\/([0-9]*)/;
|
const reg = /https:\/\/x\.com\/[\w]+\/status\/\d+(\/photo\/\d+)?/;
|
||||||
const twitterUrl = reg.exec(e.msg)[0];
|
const twitterUrl = reg.exec(e.msg)[0];
|
||||||
// 检测
|
// 检测
|
||||||
const isOversea = await this.isOverseasServer();
|
const isOversea = await this.isOverseasServer();
|
||||||
logger.info(!isOversea);
|
|
||||||
logger.info(!(await testProxy(this.proxyAddr, this.proxyPort)));
|
|
||||||
if (!isOversea && !(await testProxy(this.proxyAddr, this.proxyPort))) {
|
if (!isOversea && !(await testProxy(this.proxyAddr, this.proxyPort))) {
|
||||||
e.reply("检测到没有梯子,无法解析小蓝鸟");
|
e.reply("检测到没有梯子,无法解析小蓝鸟");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 提取视频
|
// 提取视频
|
||||||
const videoUrl = GENERAL_REQ_LINK.link.replace("{}", twitterUrl);
|
let videoUrl = GENERAL_REQ_LINK.link.replace("{}", twitterUrl);
|
||||||
e.reply("识别:小蓝鸟学习版");
|
e.reply("识别:小蓝鸟学习版");
|
||||||
const config = {
|
const config = {
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
'Accept': 'ext/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
||||||
|
'Accept-Encoding': 'gzip, deflate',
|
||||||
'Accept-Language': 'zh-CN,zh;q=0.9',
|
'Accept-Language': 'zh-CN,zh;q=0.9',
|
||||||
'Cache-Control': 'no-cache',
|
'Host': '47.99.158.118',
|
||||||
'Connection': 'keep-alive',
|
'Proxy-Connection': 'keep-alive',
|
||||||
'Pragma': 'no-cache',
|
|
||||||
'Sec-Fetch-Dest': 'document',
|
|
||||||
'Sec-Fetch-Mode': 'navigate',
|
|
||||||
'Sec-Fetch-Site': 'none',
|
|
||||||
'Sec-Fetch-User': '?1',
|
|
||||||
'Upgrade-Insecure-Requests': '1',
|
'Upgrade-Insecure-Requests': '1',
|
||||||
'User-Agent': COMMON_USER_AGENT,
|
'User-Agent': COMMON_USER_AGENT,
|
||||||
},
|
},
|
||||||
timeout: 10000 // 设置超时时间
|
timeout: 10000 // 设置超时时间
|
||||||
}
|
}
|
||||||
|
|
||||||
axios.get(videoUrl, config).then(resp => {
|
let resp = await axios.get(videoUrl, config);
|
||||||
const url = resp.data.data?.url;
|
if (resp.data.data == null) {
|
||||||
if (url && (url.endsWith(".jpg") || url.endsWith(".png"))) {
|
videoUrl += '/photo/1';
|
||||||
logger.info(url);
|
logger.info(videoUrl);
|
||||||
if (isOversea) {
|
resp = await axios.get(videoUrl, config);
|
||||||
// 海外直接下载
|
}
|
||||||
e.reply(segment.image(url));
|
const url = resp.data.data?.url;
|
||||||
} else {
|
if (url && (url.endsWith(".jpg") || url.endsWith(".png"))) {
|
||||||
// 非海外使用🪜下载
|
if (isOversea) {
|
||||||
const localPath = this.getCurDownloadPath(e);
|
// 海外直接下载
|
||||||
downloadImg(url, localPath, "", !isOversea, {}, {
|
e.reply(segment.image(url));
|
||||||
proxyAddr: this.proxyAddr,
|
|
||||||
proxyPort: this.proxyPort
|
|
||||||
}).then(async _ => {
|
|
||||||
e.reply(segment.image(fs.readFileSync(localPath + "/" + url.split("/").pop())));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.downloadVideo(url, !isOversea).then(path => {
|
// 非海外使用🪜下载
|
||||||
e.reply(segment.video(path + "/temp.mp4"));
|
const localPath = this.getCurDownloadPath(e);
|
||||||
|
downloadImg(url, localPath, "", !isOversea, {}, {
|
||||||
|
proxyAddr: this.proxyAddr,
|
||||||
|
proxyPort: this.proxyPort
|
||||||
|
}).then(async _ => {
|
||||||
|
e.reply(segment.image(fs.readFileSync(localPath + "/" + url.split("/").pop())));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
|
this.downloadVideo(url, !isOversea).then(path => {
|
||||||
|
e.reply(segment.video(path + "/temp.mp4"));
|
||||||
|
});
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user