mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 08:09:19 +00:00
🐞 fix: 修复 x
国内无法发出问题
1. 修复 `x` 国内无法发出问题 2. 清理tunnel
This commit is contained in:
parent
6eb3689d99
commit
f2d11794c5
@ -888,6 +888,8 @@ export class tools extends plugin {
|
||||
const twitterUrl = reg.exec(e.msg)[0];
|
||||
// 检测
|
||||
const isOversea = await this.isOverseasServer();
|
||||
logger.info(!isOversea);
|
||||
logger.info(!(await testProxy(this.proxyAddr, this.proxyPort)));
|
||||
if (!isOversea && !(await testProxy(this.proxyAddr, this.proxyPort))) {
|
||||
e.reply("检测到没有梯子,无法解析小蓝鸟");
|
||||
return false;
|
||||
@ -915,18 +917,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"))) {
|
||||
logger.info(url);
|
||||
if (isOversea) {
|
||||
// 海外直接下载
|
||||
e.reply(segment.image(url));
|
||||
} else {
|
||||
// 非海外使用🪜下载
|
||||
const proxy = this.proxyAddr;
|
||||
const port = this.proxyPort;
|
||||
const localPath = this.getCurDownloadPath(e);
|
||||
downloadImg(url, localPath, "", isOversea, {}, {
|
||||
proxyAddr: proxy,
|
||||
proxyPort: port
|
||||
}).then(_ => {
|
||||
downloadImg(url, localPath, "", !isOversea, {}, {
|
||||
proxyAddr: this.proxyAddr,
|
||||
proxyPort: this.proxyPort
|
||||
}).then(async _ => {
|
||||
e.reply(segment.image(fs.readFileSync(localPath + "/" + url.split("/").pop())));
|
||||
});
|
||||
}
|
||||
@ -1868,12 +1869,7 @@ export class tools extends plugin {
|
||||
// 构造代理参数
|
||||
const proxyOption = {
|
||||
...(isProxy && {
|
||||
httpAgent: tunnel.httpOverHttp({
|
||||
proxy: { host: this.proxyAddr, port: this.proxyPort },
|
||||
}),
|
||||
httpsAgent: tunnel.httpsOverHttp({
|
||||
proxy: { host: this.proxyAddr, port: this.proxyPort },
|
||||
}),
|
||||
httpAgent: new HttpsProxyAgent(`http://${ this.proxyAddr }:${ this.proxyPort }`),
|
||||
}),
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"axios": "^1.3.4",
|
||||
"tunnel": "^0.0.6",
|
||||
"qrcode": "^1.5.3",
|
||||
"p-queue": "^8.0.1",
|
||||
"ws": "^8.17.0",
|
||||
|
@ -326,23 +326,13 @@ export function truncateString(inputString, maxLength = 50) {
|
||||
* @returns {Promise<Boolean>}
|
||||
*/
|
||||
export async function testProxy(host='127.0.0.1', port=7890) {
|
||||
// 配置代理服务器
|
||||
const proxyOptions = {
|
||||
host: host,
|
||||
port: port,
|
||||
// 如果你的代理服务器需要认证
|
||||
// auth: 'username:password', // 取消注释并提供实际的用户名和密码
|
||||
};
|
||||
|
||||
// 创建一个代理隧道
|
||||
const httpsAgent = tunnel.httpsOverHttp({
|
||||
proxy: proxyOptions
|
||||
});
|
||||
const httpsAgent = new HttpsProxyAgent(`http://${host}:${port}`);
|
||||
|
||||
try {
|
||||
// 通过代理服务器发起请求
|
||||
await axios.get('https://www.google.com', { httpsAgent });
|
||||
logger.mark('[R插件][梯子测试模块] 检测到梯子');
|
||||
logger.mark(logger.yellow('[R插件][梯子测试模块] 检测到梯子'));
|
||||
return true;
|
||||
} catch (error) {
|
||||
logger.error('[R插件][梯子测试模块] 检测不到梯子');
|
||||
|
Loading…
x
Reference in New Issue
Block a user