@dongdev/fca-unofficial 2.0.17 → 2.0.19

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
@@ -86,3 +86,9 @@ Too lazy to write changelog, sorry! (will write changelog in the next release, t
86
86
 
87
87
  ## v2.0.16 - 2025-10-07
88
88
  - Hotfix / auto bump
89
+
90
+ ## v2.0.17 - 2025-10-07
91
+ - Hotfix / auto bump
92
+
93
+ ## v2.0.18 - 2025-10-07
94
+ - Hotfix / auto bump
@@ -5,12 +5,6 @@ const logger = require("../func/logger");
5
5
  const { get, post, jar, makeDefaults } = require("../src/utils/request");
6
6
  const { saveCookies, getAppState } = require("../src/utils/client");
7
7
  const { getFrom } = require("../src/utils/constants");
8
- const path = require("path");
9
- const models = require("../src/database/models");
10
- const logger = require("../func/logger");
11
- const { get, post, jar, makeDefaults } = require("../src/utils/request");
12
- const { saveCookies, getAppState } = require("../src/utils/client");
13
- const { getFrom } = require("../src/utils/constants");
14
8
  const { loadConfig } = require("./config");
15
9
  const { config } = loadConfig();
16
10
  const { v4: uuidv4 } = require("uuid");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dongdev/fca-unofficial",
3
- "version": "2.0.17",
3
+ "version": "2.0.19",
4
4
  "description": "Unofficial Facebook Chat API for Node.js - Interact with Facebook Messenger programmatically",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -178,10 +178,24 @@ module.exports = function (defaultFuncs, api, ctx) {
178
178
  });
179
179
  }
180
180
 
181
+ function sendOnce(baseForm, threadID, isSingleUser) {
182
+ const otid = generateOfflineThreadingID();
183
+ const form = { ...baseForm, offline_threading_id: otid, message_id: otid };
184
+ return new Promise((resolve, reject) => {
185
+ sendContent(form, threadID, isSingleUser, otid, (err, info) => (err ? reject(err) : resolve(info)));
186
+ });
187
+ }
188
+
181
189
  function send(form, threadID, messageAndOTID, callback, isGroup) {
182
190
  if (getType(threadID) === "Array") return sendContent(form, threadID, false, messageAndOTID, callback);
183
- if (getType(isGroup) !== "Boolean") return sendContent(form, threadID, String(threadID).length === 15, messageAndOTID, callback);
184
- return sendContent(form, threadID, !isGroup, messageAndOTID, callback);
191
+ if (getType(isGroup) === "Boolean") return sendContent(form, threadID, !isGroup, messageAndOTID, callback);
192
+ sendOnce(form, threadID, false)
193
+ .then(info => callback(null, info))
194
+ .catch(() => {
195
+ sendOnce(form, threadID, true)
196
+ .then(info => callback(null, info))
197
+ .catch(err => callback(err));
198
+ });
185
199
  }
186
200
 
187
201
  function handleUrl(msg, form, callback, cb) {
@@ -362,5 +376,4 @@ module.exports = function (defaultFuncs, api, ctx) {
362
376
  );
363
377
  return returnPromise;
364
378
  };
365
-
366
379
  };