oicq-icalingua-plus-plus 1.24.4 → 1.24.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/message/image.js +5 -0
- package/lib/message/parser.js +22 -1
- package/lib/message/ptt.js +5 -2
- package/package.json +3 -3
package/lib/message/image.js
CHANGED
|
@@ -603,6 +603,7 @@ async function offNTPicDown(user_id, fileResId) {
|
|
|
603
603
|
*/
|
|
604
604
|
async function checkImgUrl(url) {
|
|
605
605
|
const data = await axios.get(url, {
|
|
606
|
+
timeout: 5000,
|
|
606
607
|
headers: { Range: 'bytes=0-1' }
|
|
607
608
|
}).then(res => res.data).catch(() => null);
|
|
608
609
|
return !!data;
|
|
@@ -711,6 +712,8 @@ async function getGroupNTPicRkey() {
|
|
|
711
712
|
const rsp = await getGroupNTPicURL.call(this, {
|
|
712
713
|
3: 1,
|
|
713
714
|
});
|
|
715
|
+
if (!rsp)
|
|
716
|
+
return "&rkey=CAQSKDOc_jvbthUjZrMxJG2jNZ-rIWue47Q3PGKb_GWljzyvOUZOv0-EVao";
|
|
714
717
|
return '&rkey=' + rsp.match(/&rkey=([^&]+)/)[1];
|
|
715
718
|
}
|
|
716
719
|
|
|
@@ -722,6 +725,8 @@ async function getOffNTPicRkey() {
|
|
|
722
725
|
const rsp = await getOffNTPicURL.call(this, {
|
|
723
726
|
3: 1,
|
|
724
727
|
});
|
|
728
|
+
if (!rsp)
|
|
729
|
+
return "&rkey=CAQSKDOc_jvbthUjZrMxJG2jNZ-rIWue47Q3PGKb_GWljzyvOUZOv0-EVao";
|
|
725
730
|
return '&rkey=' + rsp.match(/&rkey=([^&]+)/)[1];
|
|
726
731
|
}
|
|
727
732
|
|
package/lib/message/parser.js
CHANGED
|
@@ -10,7 +10,7 @@ const pb = require("../algo/pb");
|
|
|
10
10
|
const face = require("./face");
|
|
11
11
|
const { getGroupMsgs } = require("./history");
|
|
12
12
|
const { int32ip2str } = require("../service");
|
|
13
|
-
const { buildImageFileParam, groupNTPicDown, offNTPicDown, checkImgUrl, getOffNTPicURL, getGroupNTPicURL } = require("./image");
|
|
13
|
+
const { buildImageFileParam, groupNTPicDown, offNTPicDown, checkImgUrl, getOffNTPicURL, getGroupNTPicURL, getOffNTPicRkey } = require("./image");
|
|
14
14
|
const { Gfs, getC2CFileUrl } = require("./file");
|
|
15
15
|
const { getVideoUrl, getPttUrl } = require("./ptt");
|
|
16
16
|
const { genC2CMessageId, genGroupMessageId, timestamp, parseFunString, code2uin, genRandom, unzip } = require("../common");
|
|
@@ -531,6 +531,15 @@ class Parser {
|
|
|
531
531
|
data.url = newURL;
|
|
532
532
|
}
|
|
533
533
|
}
|
|
534
|
+
// QQNT 图片容错,某些 QQNT 的机器人会发出 appid 异常的图片
|
|
535
|
+
data.url = data.url.replace("multimedia.nt.qq.com.cn", "gchat.qpic.cn"); //这个host下面似乎不检查rkey有效期以及appid是否对应
|
|
536
|
+
if (!(await checkImgUrl(data.url))) {
|
|
537
|
+
const appidInURL = data.url.match(/appid=(\d+)/);
|
|
538
|
+
if (appidInURL) {
|
|
539
|
+
const newAppid = appidInURL[1] === "1406" ? "1407" : "1406";
|
|
540
|
+
data.url = data.url.replace(appidInURL[0], `appid=${newAppid}`);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
534
543
|
return data;
|
|
535
544
|
}
|
|
536
545
|
|
|
@@ -563,6 +572,7 @@ class Parser {
|
|
|
563
572
|
return data;
|
|
564
573
|
}
|
|
565
574
|
|
|
575
|
+
let ntFileId = null;
|
|
566
576
|
if (dm) { //私图
|
|
567
577
|
if (ntPath && ntPath.startsWith("/download") && ntPath.includes("rkey=")) {
|
|
568
578
|
data.url = "https://gchat.qpic.cn" + ntPath + "&spec=0";
|
|
@@ -572,6 +582,7 @@ class Parser {
|
|
|
572
582
|
data.url = `https://gchat.qpic.cn/gchatpic_new/0/0-0-${md5.toHex().toUpperCase()}/0`
|
|
573
583
|
}
|
|
574
584
|
if (!(await checkImgUrl(data.url))) {
|
|
585
|
+
ntFileId = data.url.match(/&fileid=([^&]+)/);
|
|
575
586
|
// 图片地址失效,尝试发包获取
|
|
576
587
|
if (elem[23]) { //QQNT 私聊合并转发到群聊图
|
|
577
588
|
data.url = await groupNTPicDown.call(this.c, this.gid || 284840486, elem[23], md5);
|
|
@@ -588,6 +599,7 @@ class Parser {
|
|
|
588
599
|
data.url = `https://gchat.qpic.cn/gchatpic_new/0/0-0-${md5.toHex().toUpperCase()}/0`
|
|
589
600
|
}
|
|
590
601
|
if (!(await checkImgUrl(data.url))) {
|
|
602
|
+
ntFileId = data.url.match(/&fileid=([^&]+)/);
|
|
591
603
|
// 图片地址失效,尝试发包获取
|
|
592
604
|
if (fileid) { //纯群聊图片
|
|
593
605
|
data.url = await groupNTPicDown.call(this.c, this.gid || 284840486, fileid, md5);
|
|
@@ -596,6 +608,15 @@ class Parser {
|
|
|
596
608
|
}
|
|
597
609
|
}
|
|
598
610
|
}
|
|
611
|
+
// QQNT 图片容错,某些 QQNT 的机器人会发出 appid 异常的图片
|
|
612
|
+
data.url = data.url.replace("multimedia.nt.qq.com.cn", "gchat.qpic.cn");
|
|
613
|
+
if (ntFileId && !(await checkImgUrl(data.url))) {
|
|
614
|
+
const offNTPicRkey = await getOffNTPicRkey.call(this.c);
|
|
615
|
+
data.url = `https://gchat.qpic.cn/download?appid=1406&fileid=${ntFileId[1]}${offNTPicRkey}}&spec=0`;
|
|
616
|
+
if (!(await checkImgUrl(data.url))) {
|
|
617
|
+
data.url = `https://gchat.qpic.cn/download?appid=1407&fileid=${ntFileId[1]}${offNTPicRkey}}&spec=0`;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
599
620
|
return data;
|
|
600
621
|
}
|
|
601
622
|
|
package/lib/message/ptt.js
CHANGED
|
@@ -260,7 +260,10 @@ async function getVideoUrl(elem) {
|
|
|
260
260
|
});
|
|
261
261
|
const blob = await this.sendUni("PttCenterSvr.ShortVideoDownReq", body);
|
|
262
262
|
const rsp = pb.decode(blob)[4][9];
|
|
263
|
-
|
|
263
|
+
const url = new URL(String(Array.isArray(rsp[10]) ? rsp[10][0] : rsp[10]) + String(rsp[11]));
|
|
264
|
+
url.host = url.pathname === "/download" ? "multimedia.nt.qq.com.cn" : "grouptalk.c2c.qq.com";
|
|
265
|
+
url.protocol = "https";
|
|
266
|
+
return url.toString();
|
|
264
267
|
}
|
|
265
268
|
|
|
266
269
|
// Thanks @5ec1cff
|
|
@@ -314,7 +317,7 @@ async function getVideoUrl(elem) {
|
|
|
314
317
|
});
|
|
315
318
|
const blob = await this.sendUni("PttCenterSvr.pb_pttCenter_CMD_REQ_APPLY_DOWNLOAD-1200", body);
|
|
316
319
|
const url = new URL(pb.decode(blob)[14][30][50].toString());
|
|
317
|
-
url.host = "grouptalk.c2c.qq.com";
|
|
320
|
+
url.host = url.pathname === "/download" ? "multimedia.nt.qq.com.cn" : "grouptalk.c2c.qq.com";
|
|
318
321
|
url.protocol = "https";
|
|
319
322
|
return url.toString();
|
|
320
323
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oicq-icalingua-plus-plus",
|
|
3
3
|
"app_name": "oicq-icalingua-plus-plus",
|
|
4
|
-
"version": "1.24.
|
|
5
|
-
"app_version": "1.24.
|
|
6
|
-
"upday": "2024/
|
|
4
|
+
"version": "1.24.5",
|
|
5
|
+
"app_version": "1.24.5",
|
|
6
|
+
"upday": "2024/05/01",
|
|
7
7
|
"protocol_version": "v11",
|
|
8
8
|
"description": "oicq(https://github.com/takayama-lily/oicq) v1 for Icalingua++",
|
|
9
9
|
"main": "index.js",
|