oicq-icalingua-plus-plus 1.23.6 → 1.23.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/index.d.ts +5 -1
- package/lib/core/nessy.js +16 -6
- package/lib/message/multi.js +130 -23
- package/lib/message/parser.js +9 -1
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -456,6 +456,7 @@ interface CommonMessageEventData extends CommonEventData {
|
|
|
456
456
|
post_type: "message",
|
|
457
457
|
message: MessageElem[], //消息链
|
|
458
458
|
raw_message: string, //字符串格式的消息
|
|
459
|
+
bubble_id: number,
|
|
459
460
|
message_id: string,
|
|
460
461
|
user_id: number,
|
|
461
462
|
font: string,
|
|
@@ -974,6 +975,7 @@ export class Client extends EventEmitter {
|
|
|
974
975
|
time: number,
|
|
975
976
|
message: MessageElem[],
|
|
976
977
|
raw_message: string,
|
|
978
|
+
bubble_id: number,
|
|
977
979
|
}>>>;
|
|
978
980
|
|
|
979
981
|
/**
|
|
@@ -1022,7 +1024,7 @@ export class Client extends EventEmitter {
|
|
|
1022
1024
|
deleteFriend(user_id: number, block?: boolean): Promise<Ret>;
|
|
1023
1025
|
/** 邀请好友入群(不支持陌生人和批量) */
|
|
1024
1026
|
inviteFriend(group_id: number, user_id: number): Promise<Ret>;
|
|
1025
|
-
/** 点赞(times默认1
|
|
1027
|
+
/** 点赞(times默认1,支持陌生人) */
|
|
1026
1028
|
sendLike(user_id: number, times?: number): Promise<Ret>;
|
|
1027
1029
|
|
|
1028
1030
|
/** 设置昵称 */
|
|
@@ -1217,4 +1219,6 @@ export interface FakeMessage {
|
|
|
1217
1219
|
nickname?: string,
|
|
1218
1220
|
time?: number, //时间戳(秒),默认:当前时间
|
|
1219
1221
|
id?: string, //消息id,用于获取消息气泡,默认不使用气泡
|
|
1222
|
+
consistent?: boolean, //是否让消息seq和random与id保持一致,如果id为空则无视,默认:false
|
|
1223
|
+
bubble_id?: number, //用于插入消息气泡,可覆盖id获取的气泡,如果id不存在且不指定则不使用气泡
|
|
1220
1224
|
}
|
package/lib/core/nessy.js
CHANGED
|
@@ -15,12 +15,22 @@ async function sendLike(user_id, times = 1) {
|
|
|
15
15
|
times = parseInt(times);
|
|
16
16
|
if (!(times > 0 && times <= 20))
|
|
17
17
|
times = 1;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
let ReqFavorite;
|
|
19
|
+
if (this.fl.get(user_id)) {
|
|
20
|
+
ReqFavorite = jce.encodeStruct([
|
|
21
|
+
jce.encodeNested([
|
|
22
|
+
this.uin, 1, this.seq_id + 1, 1, 0, Buffer.from("0C180001060131160131", "hex")
|
|
23
|
+
]),
|
|
24
|
+
user_id, 0, 1, times
|
|
25
|
+
]);
|
|
26
|
+
} else {
|
|
27
|
+
ReqFavorite = jce.encodeStruct([
|
|
28
|
+
jce.encodeNested([
|
|
29
|
+
this.uin, 1, this.seq_id + 1, 1, 0, Buffer.from("0C180001060131160135", "hex")
|
|
30
|
+
]),
|
|
31
|
+
user_id, 0, 5, times
|
|
32
|
+
]);
|
|
33
|
+
}
|
|
24
34
|
const extra = {
|
|
25
35
|
req_id: this.seq_id + 1,
|
|
26
36
|
service: "VisitorSvc",
|
package/lib/message/multi.js
CHANGED
|
@@ -5,12 +5,15 @@ const util = require("util");
|
|
|
5
5
|
const { randomBytes } = require("crypto");
|
|
6
6
|
const face = require("./face");
|
|
7
7
|
const { ImageBuilder, uploadImages } = require("./image");
|
|
8
|
+
const tea = require("../algo/tea");
|
|
8
9
|
const pb = require("../algo/pb");
|
|
9
10
|
const common = require("../common");
|
|
10
|
-
const { highwayUploadStream } = require("../service");
|
|
11
|
+
const { highwayUploadStream, int32ip2str } = require("../service");
|
|
11
12
|
const gzip = util.promisify(zlib.gzip);
|
|
12
13
|
const deflate = util.promisify(zlib.deflate);
|
|
13
14
|
const { getC2CMsgs, getGroupMsgs } = require("./history");
|
|
15
|
+
const http = require("http");
|
|
16
|
+
const https = require("https");
|
|
14
17
|
const BUF1 = Buffer.from([1]);
|
|
15
18
|
|
|
16
19
|
function buildTextElem(str) {
|
|
@@ -90,6 +93,61 @@ async function getMsg(id) {
|
|
|
90
93
|
throw new Error();
|
|
91
94
|
}
|
|
92
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* @this {import("../ref").Client}
|
|
98
|
+
* @param {Buffer} resid
|
|
99
|
+
* @param {Number} bu
|
|
100
|
+
* @returns {Promise<Buffer>}
|
|
101
|
+
*/
|
|
102
|
+
async function _downloadMultiMsg(resid, bu) {
|
|
103
|
+
const body = pb.encode({
|
|
104
|
+
1: 2,
|
|
105
|
+
2: 5,
|
|
106
|
+
3: 9,
|
|
107
|
+
4: 3,
|
|
108
|
+
5: this.apk.version,
|
|
109
|
+
7: [{
|
|
110
|
+
1: resid,
|
|
111
|
+
2: 3,
|
|
112
|
+
}],
|
|
113
|
+
8: bu,
|
|
114
|
+
9: 2,
|
|
115
|
+
});
|
|
116
|
+
const blob = await this.sendUni("MultiMsg.ApplyDown", body);
|
|
117
|
+
const rsp = pb.decode(blob)[3];
|
|
118
|
+
const ip = int32ip2str(Array.isArray(rsp[4]) ? rsp[4][0] : rsp[4]),
|
|
119
|
+
port = Array.isArray(rsp[5]) ? rsp[5][0] : rsp[5];
|
|
120
|
+
let url = port == 443 ? "https://ssl.htdata.qq.com" : `http://${ip}:${port}`;
|
|
121
|
+
url += rsp[2];
|
|
122
|
+
const headers = {
|
|
123
|
+
"User-Agent": `QQ/${this.apk.version} CFNetwork/1126`,
|
|
124
|
+
"Net-Type": "Wifi"
|
|
125
|
+
};
|
|
126
|
+
return new Promise((resolve, reject) => {
|
|
127
|
+
const protocol = port == 443 ? https : http;
|
|
128
|
+
protocol.get(url, { headers }, (res) => {
|
|
129
|
+
const data = [];
|
|
130
|
+
res.on("data", (chunk) => data.push(chunk));
|
|
131
|
+
res.on("end", async () => {
|
|
132
|
+
try {
|
|
133
|
+
let buf = Buffer.concat(data);
|
|
134
|
+
if (res.headers["accept-encoding"] && res.headers["accept-encoding"].includes("gzip"))
|
|
135
|
+
buf = await common.unzip(buf);
|
|
136
|
+
const head_len = buf.readUInt32BE(1);
|
|
137
|
+
const body_len = buf.readUInt32BE(5);
|
|
138
|
+
buf = tea.decrypt(buf.slice(head_len + 9, head_len + 9 + body_len), rsp[3].toBuffer());
|
|
139
|
+
buf = pb.decode(buf)[3];
|
|
140
|
+
// if (Array.isArray(buf)) buf = buf[0];
|
|
141
|
+
buf = await common.unzip(buf[3].toBuffer());
|
|
142
|
+
resolve(buf);
|
|
143
|
+
} catch (e) {
|
|
144
|
+
e.message = "wrong resid";
|
|
145
|
+
reject(e);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}).on("error", reject);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
93
151
|
|
|
94
152
|
/**
|
|
95
153
|
* @this {import("../ref").Client}
|
|
@@ -109,6 +167,8 @@ async function makeForwardMsg(iterable, dm = false, target = 0) {
|
|
|
109
167
|
let preview = "";
|
|
110
168
|
let cnt = 0;
|
|
111
169
|
|
|
170
|
+
let Multi = [];
|
|
171
|
+
|
|
112
172
|
for (const fake of iterable) {
|
|
113
173
|
if (!fake.message || !common.checkUin(fake.user_id)) {
|
|
114
174
|
console.log(fake)
|
|
@@ -187,7 +247,31 @@ async function makeForwardMsg(iterable, dm = false, target = 0) {
|
|
|
187
247
|
break;
|
|
188
248
|
case "xml":
|
|
189
249
|
elements.push(await buildXmlElem(elem.data.xml, elem.data.svcid));
|
|
190
|
-
|
|
250
|
+
const resIdRegex = /m_resid="([\w+=/]+)"/
|
|
251
|
+
const fileNameRegex = /m_fileName="([\w+-=/]+)"/
|
|
252
|
+
if (resIdRegex.test(elem.data.xml) && fileNameRegex.test(elem.data.xml)) {
|
|
253
|
+
const resId = resIdRegex.exec(elem.data.xml)[1];
|
|
254
|
+
const fileName = fileNameRegex.exec(elem.data.xml)[1];
|
|
255
|
+
const buf = await _downloadMultiMsg.call(this, resId, 2);
|
|
256
|
+
let msgs = pb.decode(buf)[2];
|
|
257
|
+
if (!Array.isArray(msgs)) {
|
|
258
|
+
msgs = [msgs];
|
|
259
|
+
}
|
|
260
|
+
for (let msg of msgs) {
|
|
261
|
+
const m_fileName = msg[1].toString();
|
|
262
|
+
if (m_fileName === 'MultiMsg') {
|
|
263
|
+
Multi.push({
|
|
264
|
+
1: fileName,
|
|
265
|
+
2: msg[2]
|
|
266
|
+
});
|
|
267
|
+
} else {
|
|
268
|
+
Multi.push(msg);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
brief += "[聊天记录]";
|
|
272
|
+
} else {
|
|
273
|
+
brief += "[XML]";
|
|
274
|
+
}
|
|
191
275
|
break;
|
|
192
276
|
case "json":
|
|
193
277
|
elements.push(await buildJsonElem(elem.data.json));
|
|
@@ -199,9 +283,43 @@ async function makeForwardMsg(iterable, dm = false, target = 0) {
|
|
|
199
283
|
|
|
200
284
|
if (!elements.length)
|
|
201
285
|
continue;
|
|
202
|
-
|
|
203
|
-
|
|
286
|
+
let seq = randomBytes(2).readInt16BE();
|
|
287
|
+
let random = randomBytes(4).readInt32BE();
|
|
204
288
|
fake.nickname = String(fake.nickname || fake.user_id);
|
|
289
|
+
if (fake.id) {
|
|
290
|
+
try {
|
|
291
|
+
const parsed = Buffer.from(fake.id, "base64");
|
|
292
|
+
if (fake.consistent) {
|
|
293
|
+
if (fake.id.length > 24) {
|
|
294
|
+
// Group
|
|
295
|
+
seq = parsed.readUInt32BE(8);
|
|
296
|
+
random = parsed.readUInt32BE(12);
|
|
297
|
+
} else {
|
|
298
|
+
// C2C
|
|
299
|
+
seq = parsed.readUInt32BE(4);
|
|
300
|
+
random = parsed.readUInt32BE(8);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (!fake.bubble_id) {
|
|
304
|
+
const { msg } = await getMsg.call(this, fake.id);
|
|
305
|
+
for (let i of msg[3][1][2]) {
|
|
306
|
+
if (i[9]) {
|
|
307
|
+
elements.push(i);
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
} catch {
|
|
313
|
+
this.logger.warn("invalid message id: " + fake.id);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (fake.bubble_id) {
|
|
317
|
+
elements.push({
|
|
318
|
+
9: {
|
|
319
|
+
1: fake.bubble_id
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
}
|
|
205
323
|
nodes.push({
|
|
206
324
|
1: {
|
|
207
325
|
1: fake.user_id,
|
|
@@ -227,19 +345,6 @@ async function makeForwardMsg(iterable, dm = false, target = 0) {
|
|
|
227
345
|
}
|
|
228
346
|
}
|
|
229
347
|
});
|
|
230
|
-
if (fake.id) {
|
|
231
|
-
try {
|
|
232
|
-
const { msg } = await getMsg.call(this, fake.id);
|
|
233
|
-
for (let i of msg[3][1][2]) {
|
|
234
|
-
if (i[9]) {
|
|
235
|
-
nodes[nodes.length - 1][3][1][2].push(i)
|
|
236
|
-
break
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
} catch {
|
|
240
|
-
this.logger.warn("invalid message id: " + fake.id);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
348
|
if (cnt < 4) {
|
|
244
349
|
++cnt
|
|
245
350
|
preview += `<title color="#777777" size="26">${common.escapeXml(fake.nickname)}: ${common.escapeXml(brief.slice(0, 50))}</title>`;
|
|
@@ -248,17 +353,19 @@ async function makeForwardMsg(iterable, dm = false, target = 0) {
|
|
|
248
353
|
if (!nodes.length)
|
|
249
354
|
throw new Error("empty message");
|
|
250
355
|
|
|
356
|
+
Multi.unshift({
|
|
357
|
+
1: "MultiMsg",
|
|
358
|
+
2: {
|
|
359
|
+
1: nodes
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
|
|
251
363
|
await Promise.all(tasks);
|
|
252
364
|
await uploadImages.call(this, this.uin, imgs, dm);
|
|
253
365
|
|
|
254
366
|
const compressed = await gzip(pb.encode({
|
|
255
367
|
1: nodes,
|
|
256
|
-
2:
|
|
257
|
-
1: "MultiMsg",
|
|
258
|
-
2: {
|
|
259
|
-
1: nodes
|
|
260
|
-
}
|
|
261
|
-
}
|
|
368
|
+
2: Multi
|
|
262
369
|
}));
|
|
263
370
|
try {
|
|
264
371
|
var resid = await uploadMultiMsg.call(this, this.uin, compressed);
|
package/lib/message/parser.js
CHANGED
|
@@ -93,6 +93,7 @@ class Parser {
|
|
|
93
93
|
*/
|
|
94
94
|
message = [];
|
|
95
95
|
raw_message = "";
|
|
96
|
+
bubble_id = 0;
|
|
96
97
|
|
|
97
98
|
/**
|
|
98
99
|
* @type {import("../ref").Anonymous}
|
|
@@ -430,6 +431,9 @@ class Parser {
|
|
|
430
431
|
case 45: //reply
|
|
431
432
|
await this.parseReplyElem(elem);
|
|
432
433
|
break;
|
|
434
|
+
case 9: //bubble
|
|
435
|
+
this.bubble_id = elem[1];
|
|
436
|
+
break;
|
|
433
437
|
default:
|
|
434
438
|
break;
|
|
435
439
|
}
|
|
@@ -617,6 +621,7 @@ async function parseC2CMsg(msg, realtime = false) {
|
|
|
617
621
|
sub_type, message_id, user_id: from_uin,
|
|
618
622
|
message: parser.message,
|
|
619
623
|
raw_message: parser.raw_message,
|
|
624
|
+
bubble_id: parser.bubble_id,
|
|
620
625
|
font, sender, time,
|
|
621
626
|
auto_reply: !!(content && content[4])
|
|
622
627
|
};
|
|
@@ -695,6 +700,7 @@ async function parseGroupMsg(msg, realtime = false) {
|
|
|
695
700
|
anonymous: parser.anonymous,
|
|
696
701
|
message: parser.message,
|
|
697
702
|
raw_message: parser.raw_message,
|
|
703
|
+
bubble_id: parser.bubble_id,
|
|
698
704
|
atme: parser.atme,
|
|
699
705
|
block: group[2] === 127,
|
|
700
706
|
seqid: seq,
|
|
@@ -732,6 +738,7 @@ async function parseDiscussMsg(msg) {
|
|
|
732
738
|
discuss_id, discuss_name, user_id,
|
|
733
739
|
message: parser.message,
|
|
734
740
|
raw_message: parser.raw_message,
|
|
741
|
+
bubble_id: parser.bubble_id,
|
|
735
742
|
atme: parser.atme,
|
|
736
743
|
font, sender, time
|
|
737
744
|
};
|
|
@@ -784,7 +791,8 @@ async function parseForwardMsg(resid, fileName) {
|
|
|
784
791
|
data.push({
|
|
785
792
|
group_id, user_id, nickname, time,
|
|
786
793
|
message: parser.message,
|
|
787
|
-
raw_message: parser.raw_message
|
|
794
|
+
raw_message: parser.raw_message,
|
|
795
|
+
bubble_id: parser.bubble_id
|
|
788
796
|
});
|
|
789
797
|
} catch { }
|
|
790
798
|
}
|
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.23.
|
|
5
|
-
"app_version": "1.23.
|
|
6
|
-
"upday": "2023/01/
|
|
4
|
+
"version": "1.23.7",
|
|
5
|
+
"app_version": "1.23.7",
|
|
6
|
+
"upday": "2023/01/11",
|
|
7
7
|
"protocol_version": "v11",
|
|
8
8
|
"description": "oicq(https://github.com/takayama-lily/oicq) v1 for Icalingua++",
|
|
9
9
|
"main": "index.js",
|