oicq-icalingua-plus-plus 1.24.4 → 1.24.6
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 +25 -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, getGroupNTPicRkey } = 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,17 @@ 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有效期
|
|
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
|
+
const newRkey = newAppid === "1406" ? await getOffNTPicRkey.call(this.c) : await getGroupNTPicRkey.call(this.c);
|
|
542
|
+
data.url = data.url.replace(/&rkey=[^&]+/, `${newRkey}`);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
534
545
|
return data;
|
|
535
546
|
}
|
|
536
547
|
|
|
@@ -563,6 +574,7 @@ class Parser {
|
|
|
563
574
|
return data;
|
|
564
575
|
}
|
|
565
576
|
|
|
577
|
+
let ntFileId = null;
|
|
566
578
|
if (dm) { //私图
|
|
567
579
|
if (ntPath && ntPath.startsWith("/download") && ntPath.includes("rkey=")) {
|
|
568
580
|
data.url = "https://gchat.qpic.cn" + ntPath + "&spec=0";
|
|
@@ -572,6 +584,7 @@ class Parser {
|
|
|
572
584
|
data.url = `https://gchat.qpic.cn/gchatpic_new/0/0-0-${md5.toHex().toUpperCase()}/0`
|
|
573
585
|
}
|
|
574
586
|
if (!(await checkImgUrl(data.url))) {
|
|
587
|
+
ntFileId = data.url.match(/&fileid=([^&]+)/);
|
|
575
588
|
// 图片地址失效,尝试发包获取
|
|
576
589
|
if (elem[23]) { //QQNT 私聊合并转发到群聊图
|
|
577
590
|
data.url = await groupNTPicDown.call(this.c, this.gid || 284840486, elem[23], md5);
|
|
@@ -588,6 +601,7 @@ class Parser {
|
|
|
588
601
|
data.url = `https://gchat.qpic.cn/gchatpic_new/0/0-0-${md5.toHex().toUpperCase()}/0`
|
|
589
602
|
}
|
|
590
603
|
if (!(await checkImgUrl(data.url))) {
|
|
604
|
+
ntFileId = data.url.match(/&fileid=([^&]+)/);
|
|
591
605
|
// 图片地址失效,尝试发包获取
|
|
592
606
|
if (fileid) { //纯群聊图片
|
|
593
607
|
data.url = await groupNTPicDown.call(this.c, this.gid || 284840486, fileid, md5);
|
|
@@ -596,6 +610,16 @@ class Parser {
|
|
|
596
610
|
}
|
|
597
611
|
}
|
|
598
612
|
}
|
|
613
|
+
// QQNT 图片容错,某些 QQNT 的机器人会发出 appid 异常的图片
|
|
614
|
+
data.url = data.url.replace("multimedia.nt.qq.com.cn", "gchat.qpic.cn");
|
|
615
|
+
if (ntFileId && !(await checkImgUrl(data.url))) {
|
|
616
|
+
const offNTPicRkey = await getOffNTPicRkey.call(this.c);
|
|
617
|
+
data.url = `https://gchat.qpic.cn/download?appid=1406&fileid=${ntFileId[1]}${offNTPicRkey}}&spec=0`;
|
|
618
|
+
if (!(await checkImgUrl(data.url))) {
|
|
619
|
+
const groupNTPicRkey = await getGroupNTPicRkey.call(this.c);
|
|
620
|
+
data.url = `https://gchat.qpic.cn/download?appid=1407&fileid=${ntFileId[1]}${groupNTPicRkey}}&spec=0`;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
599
623
|
return data;
|
|
600
624
|
}
|
|
601
625
|
|
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.6",
|
|
5
|
+
"app_version": "1.24.6",
|
|
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",
|