@eryxenx/insta-chat 2.0.4 → 2.0.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/CHANGELOG.md CHANGED
@@ -4,6 +4,31 @@ All notable changes to `@eryxenx/insta-chat` are documented here.
4
4
  The format follows [Keep a Changelog](https://keepachangelog.com/) and uses
5
5
  [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [2.0.6] - 2026-10-10
8
+
9
+ ### Added
10
+
11
+ - **Configurable poll floor.** `new InstaAPI(cookie, { minPollIntervalMs })` (and
12
+ the same option on `InstaClient`) sets the lowest interval `listen()` will
13
+ honour, defaulting to 15000 ms as before with a hard 2000 ms minimum.
14
+ Instagram has no DM push, so reply latency is one poll cycle; operators on a
15
+ residential/mobile proxy can lower it (e.g. 2000) for snappier replies.
16
+ `api.listen(cb, interval)` still cannot go below this floor, so the bot can no
17
+ longer pass an interval the package silently raises.
18
+
19
+ ## [2.0.5] - 2026-10-10
20
+
21
+ ### Fixed
22
+
23
+ - **Empty text send logged the account out.** `MessageMethods.send()` now drops
24
+ an empty (or whitespace-only) body instead of firing an
25
+ `IGDirectTextSendMutation` with an empty `sensitive_string_value`. Instagram
26
+ answers that with a 302 to the login page, which the HTTP layer classifies as
27
+ `IG_SESSION_INVALID`, so a command that built an empty reply (for example
28
+ `adduser` handed a username it could not resolve) made the poller stop and
29
+ report the session as dead. The dropped send returns
30
+ `{ messageID: null, dropped: "empty" }`.
31
+
7
32
  ## [2.0.4] - 2026-10-10
8
33
 
9
34
  ### Fixed
package/DOCS.md CHANGED
@@ -48,6 +48,7 @@ commands call). Pass `{ native: true }` to get the bare `InstaAPI` instead.
48
48
  | `sessionParamsFile` | `./session-params.json` | Load params from disk. |
49
49
  | `deviceFile` | `./device.json` | Persisted device identity. |
50
50
  | `pollInterval` | `15000` | `listen()` poll interval (ms). |
51
+ | `minPollIntervalMs` | `15000` | Lowest interval `listen()` will honour (floor, min 2000). |
51
52
 
52
53
  ## `InstaClient` (FCA surface)
53
54
 
@@ -140,7 +141,9 @@ All take `(threadID, source, options)` where `options = { filename, text }`.
140
141
 
141
142
  `getInbox()` returns `{ threads }`. `listen(callback, intervalMs)` polls and
142
143
  emits normalized `message` events; it returns a `stop()` function.
143
- `stopListening()` also stops polling.
144
+ `stopListening()` also stops polling. The interval is raised to the client's
145
+ `minPollIntervalMs` floor (set via the constructor options; default 15000 ms,
146
+ minimum 2000 ms), so pass that option if you want a shorter cycle than 15 s.
144
147
 
145
148
  ### Event shape
146
149
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eryxenx/insta-chat",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": " Unofficial Instagram Chat API for Node.js | Build Instagram DM bots on personal accounts \u2014 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",
@@ -23,7 +23,7 @@
23
23
  "CHANGELOG.md"
24
24
  ],
25
25
  "scripts": {
26
- "test": "node test/smoke.js && node test/antiSuspension.test.js && node test/replyContent.test.js && node test/edit.test.js && node test/sendReply.test.js && node test/client.test.js && node test/relayError.test.js && node test/safetyWiring.test.js && node test/mediaOrder.test.js && node test/sessionSafety.test.js",
26
+ "test": "node test/smoke.js && node test/antiSuspension.test.js && node test/replyContent.test.js && node test/edit.test.js && node test/sendReply.test.js && node test/client.test.js && node test/relayError.test.js && node test/safetyWiring.test.js && node test/mediaOrder.test.js && node test/sessionSafety.test.js && node test/emptySend.test.js && node test/pollFloor.test.js",
27
27
  "build": "node scripts/build.js"
28
28
  },
29
29
  "keywords": [
package/src/api.js CHANGED
@@ -48,7 +48,9 @@ class InstaAPI {
48
48
  this.typing = new TypingMethods(this.http);
49
49
  this.thread = new ThreadMethods(this.http);
50
50
  this.user = new UserMethods(this.http);
51
- this.inbox = new InboxMethods(this.http, () => this.userID);
51
+ this.inbox = new InboxMethods(this.http, () => this.userID, {
52
+ minPollIntervalMs: options.minPollIntervalMs
53
+ });
52
54
  this.media = new MediaMethods(this.http, this.identity);
53
55
  }
54
56
 
@@ -24,9 +24,14 @@ const INBOX_VARIABLES = {
24
24
  const SKIP_TYPES = new Set(["like", "action_log", "video_call_event", "reaction_log"]);
25
25
 
26
26
  class InboxMethods {
27
- constructor(http, getUserID) {
27
+ constructor(http, getUserID, options = {}) {
28
28
  this.http = http;
29
29
  this.getUserID = getUserID;
30
+ // Lowest poll interval listen() will honour, in ms. Instagram has no DM
31
+ // push, so reply latency is bounded by one poll cycle. The 15000 default is
32
+ // the conservative safe floor for a personal account; operators on a
33
+ // residential/mobile proxy can lower it (e.g. 2000) for snappier replies.
34
+ this.minPollIntervalMs = Math.max(2000, Number(options.minPollIntervalMs) || 15000);
30
35
  this._seen = new Map();
31
36
  this._pollTimer = null;
32
37
  this._selfFbid = null;
@@ -309,7 +314,7 @@ class InboxMethods {
309
314
  }
310
315
 
311
316
  listen(callback, intervalMs = 20000) {
312
- const MIN_INTERVAL_MS = 15000;
317
+ const MIN_INTERVAL_MS = this.minPollIntervalMs;
313
318
  const BASE_INTERVAL_MS = Math.max(Number(intervalMs) || 20000, MIN_INTERVAL_MS);
314
319
  const BACKOFF_START_MS = 30000;
315
320
  const BACKOFF_MAX_MS = 10 * 60 * 1000;
@@ -27,6 +27,15 @@ class MessageMethods {
27
27
  // (doc_id 26911679871773184). Passing it anywhere else sets a pointer without
28
28
  // rendering the quote bubble.
29
29
  async send(text, threadID, replyToItemId = null) {
30
+ // Instagram rejects an empty text send (IGDirectTextSendMutation with an
31
+ // empty `sensitive_string_value`) with a 302 to the login page. The HTTP
32
+ // layer classifies any 3xx as an auth failure, so emitting one was enough to
33
+ // make the poller declare the session dead. Commands that build a reply from
34
+ // resolvable input (e.g. adduser given an unresolvable username) can end up
35
+ // with an empty string; drop it rather than send it.
36
+ if (text === undefined || text === null || String(text).trim() === "") {
37
+ return { messageID: null, threadID: String(threadID), dropped: "empty" };
38
+ }
30
39
  // Pace outbound traffic so a personal account does not look scripted.
31
40
  await globalAntiSuspension.waitForTurn(threadID);
32
41
  const replyId =