@eryxenx/insta-chat 2.1.2 → 2.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eryxenx/insta-chat",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": " Unofficial Instagram Chat API for Node.js | Build Instagram DM bots on personal accounts — send messages, media, voice notes, reactions, edit & unsend, listen for incoming chats. No browser at runtime",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -243,9 +243,12 @@ class SendPacer extends EventEmitter {
243
243
  const sinceGlobal = now - this.lastSendAt;
244
244
  const sinceThread = now - (this.perThreadLastSendAt.get(key) || 0);
245
245
  const base = Math.max(gap - sinceGlobal, this.perThreadMinGapMs - sinceThread, 0);
246
- const jitter = this.jitterMs > 0 ? this.jitterMs * (0.3 + Math.random() * 0.7) : 0;
246
+ // Jitter only breaks up back-to-back sends. When nothing is queued (the first
247
+ // reply to a message after a quiet spell) base is 0 and the send goes out
248
+ // immediately, instead of always paying 0.3-1.0x jitterMs.
249
+ const jitter = base > 0 && this.jitterMs > 0 ? this.jitterMs * (0.3 + Math.random() * 0.7) : 0;
247
250
 
248
- await this._sleep(base + jitter);
251
+ if (base + jitter > 0) await this._sleep(base + jitter);
249
252
 
250
253
  const stamp = Date.now();
251
254
  this.lastSendAt = stamp;