oicq-icalingua-plus-plus 1.26.6 → 1.26.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 CHANGED
@@ -56,6 +56,23 @@ export interface ConfBot {
56
56
 
57
57
  /** 使用NT上线包,部分消息暂未支持 */
58
58
  useNT?: boolean,
59
+
60
+ /** 指定APK信息,覆盖默认的协议参数 */
61
+ apk_info?: {
62
+ id?: string,
63
+ name?: string,
64
+ version?: string,
65
+ ver?: string,
66
+ sign?: Buffer,
67
+ buildtime?: number,
68
+ appid?: number,
69
+ subid?: number,
70
+ bitmap?: number,
71
+ sigmap?: number,
72
+ sdkver?: string,
73
+ ssover?: number,
74
+ qua?: string,
75
+ }
59
76
  }
60
77
 
61
78
  export interface Statistics {
package/lib/client.js CHANGED
@@ -263,11 +263,15 @@ class Client extends EventEmitter {
263
263
  data_dir: path.join(require.main ? require.main.path : process.cwd(), "data"),
264
264
  ffmpeg_path: "ffmpeg",
265
265
  ffprobe_path: "ffprobe",
266
+ apk_info: {},
266
267
  ...config
267
268
  };
268
269
  this.config = config;
269
270
  this.dir = createDataDir(config.data_dir, uin);
270
271
  this.apk = getApkInfo(config.platform);
272
+ if (config.apk_info) {
273
+ Object.assign(this.apk, config.apk_info);
274
+ }
271
275
  if (this.config.useNT && this.apk.ssover < 20) this.apk.ssover = 20;
272
276
  this.logger = log4js.getLogger(`[${platforms[config.platform] ||
273
277
  ((config.platform % 2 === 1 ? "Android_" : "aPad_") + this.apk.ver)
@@ -85,13 +85,12 @@ async function initFL() {
85
85
  this.sync_finished = false;
86
86
  const tmp = this.fl;
87
87
  this.fl = new Map;
88
- let start = 0, limit = 150;
88
+ let start = 0, limit = 100;
89
89
  while (1) {
90
90
  try {
91
91
  const total = await _initFL.call(this, start, limit, tmp);
92
92
  start += limit;
93
- if (start + limit > total) limit = total - start;
94
- if (start >= total) break;
93
+ if (start > total) break;
95
94
  } catch (e) {
96
95
  this.logger.debug(e);
97
96
  this.logger.warn("加载好友列表出现异常,未加载完成。");
@@ -612,28 +612,18 @@ class Parser {
612
612
 
613
613
  data.file = buildImageFileParam(md5, size, width, height, imgType);
614
614
 
615
- if (ntPath && storeId === 1) {
615
+ if (ntPath) {
616
616
  data.url = `https://${elem[1][2][3]}${ntPath}&spec=0`;
617
617
  } else {
618
618
  data.url = `https://gchat.qpic.cn/gchatpic_new/0/0-0-${md5.toUpperCase()}/0`;
619
619
  }
620
- if (timestamp() - time > 60 * 60 || !(await checkImgUrl(data.url))) {
621
- // 图片地址失效,尝试发包获取
622
- let newURL = null;
623
- if (dm) { //私聊
624
- newURL = await getNTPicURL.call(this.c, imgInfo, String(this.uid), true);
625
- } else { //群聊
626
- newURL = await getNTPicURL.call(this.c, imgInfo, this.gid);
627
- }
628
- if (newURL) {
629
- data.url = newURL;
630
- }
620
+ if (storeId === 1 && fileid) {
621
+ data.url = await getNTPicURLbyFileid.call(this.c, fileid);
622
+ } else if (storeId === 0) {
623
+ data.url = `https://gchat.qpic.cn/gchatpic_new/0/0-0-${md5.toUpperCase()}/0`;
631
624
  }
632
625
  // QQNT 图片容错,某些 QQNT 的机器人会发出 appid 异常的图片
633
626
  data.url = data.url.replace("multimedia.nt.qq.com.cn", "gchat.qpic.cn"); //这个host下面似乎不检查rkey有效期
634
- if (!(await checkImgUrl(data.url))) {
635
- data.url = await getNTPicURLbyFileid.call(this.c, fileid);
636
- }
637
627
  this.isNTImg = true;
638
628
  return data;
639
629
  }
@@ -300,8 +300,10 @@ async function _uploadPtt(target, buf) {
300
300
  4: md5,
301
301
  5: md5.toString("hex") + ".amr",
302
302
  6: buf.length,
303
+ 8: 0,
303
304
  11: 1,
304
305
  18: fid,
306
+ 19: seconds,
305
307
  29: codec,
306
308
  30: Buffer.from([8, 0, 40, 0, 56, 0]),
307
309
  });
package/lib/service.js CHANGED
@@ -187,9 +187,9 @@ function highwayHttpUpload(readable, obj) {
187
187
  const limit = 524288
188
188
  obj.ticket = this.storage.sig_session
189
189
 
190
+ const MAX_QUEUED = 3 // 队列中最多保留的分块数,控制内存上限(3×512KB≈1.5MB)
190
191
  let seq = 1
191
192
  let offset = 0
192
- let totalChunks = 0
193
193
  let readEnded = false
194
194
 
195
195
  // 顺序队列:每读到一个完整分块就推入,drain 循环逐个串行上传
@@ -230,37 +230,40 @@ function highwayHttpUpload(readable, obj) {
230
230
  return Buffer.concat([header, head, chunk, __])
231
231
  }
232
232
 
233
- // 读取流 → 分块 → 入队
233
+ // 读取流 → 分块 → 入队(带背压:队列满时暂停读取)
234
234
  readable.on("data", data => {
235
235
  if (errFlag || quickDone) return
236
236
  let _offset = 0
237
237
  while (_offset < data.length) {
238
238
  const chunk = data.slice(_offset, limit + _offset)
239
239
  _offset += chunk.length
240
- ++totalChunks
241
240
  const buf = buildBuf(chunk, offset + _offset - chunk.length)
242
- queue.push(buf)
241
+ queue.push({ buf, chunkLen: chunk.length })
243
242
  if (notify) { notify(); notify = null }
244
243
  }
245
244
  offset += data.length
245
+ // 队列积压过多,暂停读取,等上传消化后再恢复
246
+ if (queue.length >= MAX_QUEUED) {
247
+ readable.pause()
248
+ }
246
249
  })
247
250
 
248
251
  readable.on("err", err => { errFlag = err })
249
252
 
250
253
  // 串行 drain 循环:逐个从队列取分块上传
251
254
  const drain = async () => {
252
- let finished = 0
255
+ let uploadedBytes = 0
253
256
  while (true) {
254
257
  while (queue.length === 0) {
255
258
  if (errFlag) return
256
259
  if (readEnded) {
257
260
  // 流已结束且队列为空,检查是否全部完成
258
- if (finished >= totalChunks) return
261
+ if (uploadedBytes >= obj.size) return
259
262
  }
260
263
  // 等待新分块入队
261
264
  await new Promise(r => { notify = r })
262
265
  }
263
- const buf = queue.shift()
266
+ const { buf, chunkLen } = queue.shift()
264
267
  const r = await axios.post(url, buf, {
265
268
  responseType: "arraybuffer",
266
269
  httpAgent: agent,
@@ -280,8 +283,8 @@ function highwayHttpUpload(readable, obj) {
280
283
  if (rsp?.[3] !== 0) {
281
284
  throw new Error(`${rsp[3]}, unknown highway error`)
282
285
  }
283
- ++finished
284
- const percentage = (finished / totalChunks * 100).toFixed(2)
286
+ uploadedBytes += chunkLen
287
+ const percentage = (uploadedBytes / obj.size * 100).toFixed(2)
285
288
  this.logger.debug(`highway(http) chunk uploaded (${percentage}%)`)
286
289
  if (typeof obj.callback === "function")
287
290
  obj.callback(percentage)
@@ -294,6 +297,10 @@ function highwayHttpUpload(readable, obj) {
294
297
  obj.callback("100.00")
295
298
  return
296
299
  }
300
+ // 队列消化后恢复读取
301
+ if (queue.length < MAX_QUEUED && readable.isPaused()) {
302
+ readable.resume()
303
+ }
297
304
  }
298
305
  }
299
306
 
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.26.6",
5
- "app_version": "1.26.6",
4
+ "version": "1.26.7",
5
+ "app_version": "1.26.7",
6
6
  "upday": "2026/07/18",
7
7
  "protocol_version": "v11",
8
8
  "description": "oicq(https://github.com/takayama-lily/oicq) v1 for Icalingua++",