oicq-icalingua-plus-plus 1.24.6 → 1.24.7
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 +24 -0
- package/lib/message/parser.js +10 -19
- package/package.json +2 -2
package/lib/message/image.js
CHANGED
|
@@ -730,9 +730,33 @@ async function getOffNTPicRkey() {
|
|
|
730
730
|
return '&rkey=' + rsp.match(/&rkey=([^&]+)/)[1];
|
|
731
731
|
}
|
|
732
732
|
|
|
733
|
+
/**
|
|
734
|
+
* 通过fileid获取QQNT图片URL
|
|
735
|
+
* @this {import("../ref").Client}
|
|
736
|
+
* @param {string} fileid
|
|
737
|
+
*/
|
|
738
|
+
async function getNTPicURLbyFileid(fileid) {
|
|
739
|
+
const appidInFileId = pb.decode(Buffer.from(fileid, "base64"))[4];
|
|
740
|
+
let url = "";
|
|
741
|
+
if ([1406, 1407].includes(appidInFileId)) {
|
|
742
|
+
const newRkey = appidInFileId === 1406 ? await getOffNTPicRkey.call(this) : await getGroupNTPicRkey.call(this);
|
|
743
|
+
url = `https://gchat.qpic.cn/download?appid=${appidInFileId}&fileid=${fileid}${newRkey}}&spec=0`;
|
|
744
|
+
} else {
|
|
745
|
+
// 异常 fileid,只能挨个尝试
|
|
746
|
+
const groupNTPicRkey = await getGroupNTPicRkey.call(this);
|
|
747
|
+
url = `https://gchat.qpic.cn/download?appid=1407&fileid=${fileid}${groupNTPicRkey}}&spec=0`;
|
|
748
|
+
if (!(await checkImgUrl(data.url))) {
|
|
749
|
+
const offNTPicRkey = await getOffNTPicRkey.call(this);
|
|
750
|
+
url = `https://gchat.qpic.cn/download?appid=1406&fileid=${fileid}${offNTPicRkey}}&spec=0`;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
return url;
|
|
754
|
+
}
|
|
755
|
+
|
|
733
756
|
module.exports = {
|
|
734
757
|
ImageBuilder, uploadImages, buildImageFileParam,
|
|
735
758
|
groupNTPicDown, offNTPicDown, checkImgUrl,
|
|
736
759
|
getGroupNTPicURL, getOffNTPicURL,
|
|
737
760
|
getGroupNTPicRkey, getOffNTPicRkey,
|
|
761
|
+
getNTPicURLbyFileid,
|
|
738
762
|
};
|
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, getOffNTPicRkey, getGroupNTPicRkey } = require("./image");
|
|
13
|
+
const { buildImageFileParam, groupNTPicDown, offNTPicDown, checkImgUrl, getOffNTPicURL, getGroupNTPicURL, getOffNTPicRkey, getGroupNTPicRkey, getNTPicURLbyFileid } = 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");
|
|
@@ -534,13 +534,7 @@ class Parser {
|
|
|
534
534
|
// QQNT 图片容错,某些 QQNT 的机器人会发出 appid 异常的图片
|
|
535
535
|
data.url = data.url.replace("multimedia.nt.qq.com.cn", "gchat.qpic.cn"); //这个host下面似乎不检查rkey有效期
|
|
536
536
|
if (!(await checkImgUrl(data.url))) {
|
|
537
|
-
|
|
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
|
-
}
|
|
537
|
+
data.url = await getNTPicURLbyFileid.call(this.c, fileid);
|
|
544
538
|
}
|
|
545
539
|
return data;
|
|
546
540
|
}
|
|
@@ -567,16 +561,18 @@ class Parser {
|
|
|
567
561
|
const imgType = dm ? elem[5] : elem[20];
|
|
568
562
|
data.file = buildImageFileParam(md5.toHex(), size, width, height, imgType);
|
|
569
563
|
|
|
564
|
+
let ntFileId = null;
|
|
565
|
+
|
|
570
566
|
if (this.imgprefix && ntPath && ntPath.startsWith("&rkey=")) {
|
|
571
567
|
data.url = this.imgprefix + String(ntPath) + "&spec=0";
|
|
568
|
+
ntFileId = data.url.match(/&fileid=([^&]+)/) || ntFileId;
|
|
572
569
|
this.imgprefix = null;
|
|
573
570
|
if (await checkImgUrl(data.url))
|
|
574
571
|
return data;
|
|
575
572
|
}
|
|
576
573
|
|
|
577
|
-
let ntFileId = null;
|
|
578
574
|
if (dm) { //私图
|
|
579
|
-
if (ntPath && ntPath.startsWith("/download")
|
|
575
|
+
if (ntPath && ntPath.startsWith("/download")) {
|
|
580
576
|
data.url = "https://gchat.qpic.cn" + ntPath + "&spec=0";
|
|
581
577
|
} else if (elem[15]) {
|
|
582
578
|
data.url = "https://gchat.qpic.cn" + elem[15];
|
|
@@ -584,7 +580,7 @@ class Parser {
|
|
|
584
580
|
data.url = `https://gchat.qpic.cn/gchatpic_new/0/0-0-${md5.toHex().toUpperCase()}/0`
|
|
585
581
|
}
|
|
586
582
|
if (!(await checkImgUrl(data.url))) {
|
|
587
|
-
ntFileId = data.url.match(/&fileid=([^&]+)/);
|
|
583
|
+
ntFileId = data.url.match(/&fileid=([^&]+)/) || ntFileId;
|
|
588
584
|
// 图片地址失效,尝试发包获取
|
|
589
585
|
if (elem[23]) { //QQNT 私聊合并转发到群聊图
|
|
590
586
|
data.url = await groupNTPicDown.call(this.c, this.gid || 284840486, elem[23], md5);
|
|
@@ -593,7 +589,7 @@ class Parser {
|
|
|
593
589
|
}
|
|
594
590
|
}
|
|
595
591
|
} else { //群图
|
|
596
|
-
if (ntPath && ntPath.startsWith("/download")
|
|
592
|
+
if (ntPath && ntPath.startsWith("/download")) {
|
|
597
593
|
data.url = "https://gchat.qpic.cn" + ntPath + "&spec=0";
|
|
598
594
|
} else if (elem[16]) {
|
|
599
595
|
data.url = "https://gchat.qpic.cn" + elem[16];
|
|
@@ -601,7 +597,7 @@ class Parser {
|
|
|
601
597
|
data.url = `https://gchat.qpic.cn/gchatpic_new/0/0-0-${md5.toHex().toUpperCase()}/0`
|
|
602
598
|
}
|
|
603
599
|
if (!(await checkImgUrl(data.url))) {
|
|
604
|
-
ntFileId = data.url.match(/&fileid=([^&]+)/);
|
|
600
|
+
ntFileId = data.url.match(/&fileid=([^&]+)/) || ntFileId;
|
|
605
601
|
// 图片地址失效,尝试发包获取
|
|
606
602
|
if (fileid) { //纯群聊图片
|
|
607
603
|
data.url = await groupNTPicDown.call(this.c, this.gid || 284840486, fileid, md5);
|
|
@@ -613,12 +609,7 @@ class Parser {
|
|
|
613
609
|
// QQNT 图片容错,某些 QQNT 的机器人会发出 appid 异常的图片
|
|
614
610
|
data.url = data.url.replace("multimedia.nt.qq.com.cn", "gchat.qpic.cn");
|
|
615
611
|
if (ntFileId && !(await checkImgUrl(data.url))) {
|
|
616
|
-
|
|
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
|
-
}
|
|
612
|
+
data.url = await getNTPicURLbyFileid.call(this.c, ntFileId[1]);
|
|
622
613
|
}
|
|
623
614
|
return data;
|
|
624
615
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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.
|
|
4
|
+
"version": "1.24.7",
|
|
5
|
+
"app_version": "1.24.7",
|
|
6
6
|
"upday": "2024/05/01",
|
|
7
7
|
"protocol_version": "v11",
|
|
8
8
|
"description": "oicq(https://github.com/takayama-lily/oicq) v1 for Icalingua++",
|