fca-nx 6.8.6 → 7.0.0

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/README.md CHANGED
@@ -132,22 +132,36 @@ api.restoreFromBackup();
132
132
  api.stopAutoSave();
133
133
 
134
134
  ```
135
-
136
- ### Local E2EE helper-store encryption
137
-
138
- The optional local E2EE helper store requires an external secret. Set
139
- `FCA_NX_E2EE_STORE_KEY` to a high-entropy value of at least 32 characters, or
140
- pass `{ encryptionKey }` to `E2EEStore`. The secret is not written to the store
141
- file. Keep it in your deployment's secret manager; without it, loading or
142
- saving the helper store fails closed. Legacy helper-store files are re-encrypted
143
- on load when this key is configured.
144
-
145
135
  # 💬 Messaging
146
136
  ### Send Message
147
137
  ```javascript
148
138
  api.sendMessage("Hello world!", threadID);
149
139
 
150
140
  ```
141
+ ### Message Effects
142
+ ```javascript
143
+ api.sendMessage(
144
+ {
145
+ body: "I love you! ❤️",
146
+ textEffect: "love"
147
+ },
148
+ threadID
149
+ );
150
+ ```
151
+
152
+ Built-in effect names are `heart`, `hearts`, `love`, `gift`, `present`, `fire`,
153
+ `flame`, `confetti`, `confecti`, `party`, `sparkles`, `sparkle`, `star`, and
154
+ `magic`. You can also pass a custom numeric effect ID:
155
+
156
+ ```javascript
157
+ api.sendMessage({ body: "Party time!", effect: "confetti" }, threadID);
158
+ api.sendMessage({ body: "Custom effect", textEffect: 27 }, threadID);
159
+ ```
160
+
161
+ The aliases `textEffect`, `text_effect`, `effect`, `effectName`, and their
162
+ snake/camel-case ID variants are accepted. Effects are applied through both
163
+ the MQTT sender and the legacy fallback sender.
164
+
151
165
  ### Send Attachment
152
166
  ```javascript
153
167
  const fs = require("fs");
package/module/config.js CHANGED
@@ -13,9 +13,6 @@ const defaultConfig = {
13
13
  apiServer: "",
14
14
  apiKey: "",
15
15
  credentials: { email: "", password: "", twofactor: "" },
16
- // Off unless the bot turns it on. Device registration for secret chats
17
- // is a separate login-like call and is left off by default.
18
- e2ee: false,
19
16
  antiGetInfo: {
20
17
  AntiGetThreadInfo: false,
21
18
  AntiGetUserInfo: false
package/module/login.js CHANGED
@@ -175,9 +175,6 @@ function login(loginData, options, callback) {
175
175
  callback(error, api);
176
176
  };
177
177
 
178
- if (loginData && (loginData.twofactor || loginData.twoFactor)) {
179
- globalOptions.twofactor = String(loginData.twofactor || loginData.twoFactor);
180
- }
181
178
  const proceed = () => loginHelper(loginData.appState, loginData.Cookie, loginData.email, loginData.password, globalOptions, wrappedCallback, prCallback);
182
179
  if (config && config.autoUpdate) {
183
180
  const p = checkAndUpdateVersion();
@@ -12,22 +12,6 @@ const { getFrom } = require("../src/utils/constants");
12
12
  const { loadConfig } = require("./config");
13
13
  const { createRemoteClient } = require("../src/remote/remoteClient");
14
14
  const { config } = loadConfig();
15
-
16
- function e2eeEnabled() {
17
- const on = (v) => v === true || v === "true";
18
- const off = (v) => v === false || v === "false";
19
- try {
20
- const botPath = path.join(process.cwd(), "config.json");
21
- if (fs.existsSync(botPath)) {
22
- const bot = JSON.parse(fs.readFileSync(botPath, "utf8"));
23
- if (bot && Object.prototype.hasOwnProperty.call(bot, "e2ee")) {
24
- return on(bot.e2ee);
25
- }
26
- }
27
- } catch (_) {}
28
- if (off(config.e2ee)) return false;
29
- return on(config.e2ee);
30
- }
31
15
  const axiosBase = require("axios");
32
16
  const regions = [
33
17
  { code: "PRN", name: "Pacific Northwest Region", location: "Khu vực Tây Bắc Thái Bình Dương" },
@@ -45,6 +29,24 @@ const regions = [
45
29
 
46
30
  const REGION_MAP = new Map(regions.map(r => [r.code, r]));
47
31
 
32
+ // E2EE on/off switch. Reads "e2ee" from the bot's config.json (process.cwd()),
33
+ // then from the fca-nx config. Default is OFF so E2EE only starts when asked for.
34
+ function e2eeEnabled() {
35
+ const on = (v) => v === true || v === "true";
36
+ const off = (v) => v === false || v === "false";
37
+ try {
38
+ const botPath = path.join(process.cwd(), "config.json");
39
+ if (fs.existsSync(botPath)) {
40
+ const bot = JSON.parse(fs.readFileSync(botPath, "utf8"));
41
+ if (bot && Object.prototype.hasOwnProperty.call(bot, "e2ee")) {
42
+ return on(bot.e2ee);
43
+ }
44
+ }
45
+ } catch (_) {}
46
+ if (off(config.e2ee)) return false;
47
+ return on(config.e2ee);
48
+ }
49
+
48
50
  function parseRegion(html) {
49
51
  try {
50
52
  const m1 = html.match(/"endpoint":"([^"]+)"/);
@@ -607,7 +609,7 @@ async function tryAutoLoginIfNeeded(currentHtml, currentCookies, globalOptions,
607
609
  // Try API login
608
610
  const u = config.credentials?.email || config.email;
609
611
  const p = config.credentials?.password || config.password;
610
- const tf = (globalOptions && globalOptions.twofactor) || config.credentials?.twofactor || config.twofactor || null;
612
+ const tf = config.credentials?.twofactor || config.twofactor || null;
611
613
 
612
614
  if (!u || !p) {
613
615
  logger("tryAutoLoginIfNeeded: No credentials configured for auto-login!", "error");
@@ -754,7 +756,7 @@ function makeLogin(j, email, password, globalOptions) {
754
756
  return async function () {
755
757
  const u = email || config.credentials?.email;
756
758
  const p = password || config.credentials?.password;
757
- const tf = (globalOptions && globalOptions.twofactor) || config.credentials?.twofactor || null;
759
+ const tf = config.credentials?.twofactor || null;
758
760
  if (!u || !p) return;
759
761
  const r = await tokens(u, p, tf);
760
762
  if (r && r.status && Array.isArray(r.cookies)) {
@@ -801,20 +803,6 @@ function loginHelper(appState, Cookie, email, password, globalOptions, callback)
801
803
  let userIDFromAppState = extractUIDFromAppState(appState);
802
804
  (async () => {
803
805
  try {
804
- // [Hardened4] one live process per account (overlapping deploys / double start = "multiple sessions")
805
- try {
806
- const lk = require("../src/utils/instanceLock").acquire(userIDFromAppState);
807
- if (!lk.ok) {
808
- return callback(new Error("Another bot process is already running this account (pid " + lk.pid + "). Refusing to start a second session. Set FCA_NX_INSTANCE_LOCK=off to disable."));
809
- }
810
- } catch (_) {}
811
- // Same-IP/location guard (warn by default, FCA_NX_IP_GUARD=block to refuse).
812
- try {
813
- const ipRes = await require("../src/utils/ipGuard").checkLoginIP(require("../src/utils/request").client, userIDFromAppState);
814
- if (!ipRes.ok) {
815
- return callback(new Error("Login refused: public IP changed (" + ipRes.previous + " -> " + ipRes.ip + ") and FCA_NX_IP_GUARD=block"));
816
- }
817
- } catch (_) { /* never let the guard break login */ }
818
806
  if (appState) {
819
807
  // Check and convert cookie to appState format
820
808
  if (Array.isArray(appState) && appState.some(c => c.name)) {
@@ -1152,7 +1140,7 @@ function loginHelper(appState, Cookie, email, password, globalOptions, callback)
1152
1140
  const tokenMatch = html.match(/DTSGInitialData.*?token":"(.*?)"/);
1153
1141
  if (tokenMatch) fb_dtsg = tokenMatch[1];
1154
1142
  try {
1155
- if (userID) backupAppStateSQL(jar, userID).catch(() => {});
1143
+ if (userID) await backupAppStateSQL(jar, userID);
1156
1144
  } catch { }
1157
1145
  Promise.resolve()
1158
1146
  .then(function () {
@@ -1190,8 +1178,7 @@ function loginHelper(appState, Cookie, email, password, globalOptions, callback)
1190
1178
  firstListen: true,
1191
1179
  fb_dtsg,
1192
1180
  clientID: ((Math.random() * 2147483648) | 0).toString(16),
1193
- // [Hardened5] never leave mqtt device id empty - empty rotates badly across reconnects
1194
- clientId: getFrom(html, '["MqttWebDeviceID",[],{"clientID":"', '"}') || ((""+Math.random()).slice(2)+Date.now().toString(16)).slice(0, 16),
1181
+ clientId: getFrom(html, '["MqttWebDeviceID",[],{"clientID":"', '"}') || "",
1195
1182
  wsReqNumber: 0,
1196
1183
  wsTaskNumber: 0,
1197
1184
  tasks: new Map(),
@@ -1241,19 +1228,8 @@ function loginHelper(appState, Cookie, email, password, globalOptions, callback)
1241
1228
 
1242
1229
  const u = config.credentials?.email || email;
1243
1230
  const p = config.credentials?.password || password;
1244
- const tf = globalOptions.twofactor || config.credentials?.twofactor || null;
1231
+ const tf = config.credentials?.twofactor || null;
1245
1232
  if (!u || !p) return false;
1246
- // [Hardened4] Repeated credential logins are a classic trigger for "automated
1247
- // behaviour"/"multiple sessions" restrictions. At most one per cooldown window
1248
- // (FCA_NX_RELOGIN_COOLDOWN_MIN, default 30), and never while Facebook is showing
1249
- // its scraping warning - re-logging in then only makes it worse.
1250
- const cdMs = (Number(process.env.FCA_NX_RELOGIN_COOLDOWN_MIN) || 30) * 60 * 1000;
1251
- const sinceLast = Date.now() - (global.__fcaLastCredLogin || 0);
1252
- if (sinceLast < cdMs) {
1253
- logger("performAutoLogin: credential login skipped (cooldown " + Math.ceil((cdMs - sinceLast) / 60000) + " min left) to avoid repeated-login restrictions", "warn");
1254
- return false;
1255
- }
1256
- global.__fcaLastCredLogin = Date.now();
1257
1233
  const r = await tokens(u, p, tf);
1258
1234
  if (!(r && r.status && Array.isArray(r.cookies))) return false;
1259
1235
  const pairs = r.cookies.map(c => `${c.key || c.name}=${c.value}`);
@@ -1266,7 +1242,6 @@ function loginHelper(appState, Cookie, email, password, globalOptions, callback)
1266
1242
  };
1267
1243
  const api = {
1268
1244
  setOptions: require("./options").setOptions.bind(null, globalOptions),
1269
- setSendDelay: require("../src/utils/sendThrottle").setSendDelay,
1270
1245
  getCookies: function () {
1271
1246
  return cookieHeaderFromJar(jar);
1272
1247
  },
@@ -1375,44 +1350,59 @@ function loginHelper(appState, Cookie, email, password, globalOptions, callback)
1375
1350
  api.listen = api.listenMqtt;
1376
1351
  }
1377
1352
  if (api.refreshFb_dtsg) {
1378
- // [Hardened] refresh fb_dtsg every 6h (was 24h) to prevent token-expiry logouts
1379
1353
  setInterval(function () {
1380
1354
  api.refreshFb_dtsg().then(function () {
1381
1355
  logger("Successfully refreshed fb_dtsg");
1382
- }).catch(function (e) {
1383
- logger("An error occurred while refreshing fb_dtsg: " + (e && e.message ? e.message : e), "error");
1356
+ }).catch(function () {
1357
+ logger("An error occurred while refreshing fb_dtsg", "error");
1384
1358
  });
1385
- }, 6 * 60 * 60 * 1000);
1359
+ }, 86400000);
1386
1360
  }
1387
1361
  // ✅ fca-nx core features register
1388
- try {
1389
- if (!e2eeEnabled()) {
1390
- logger("E2EE off. Set \"e2ee\": true in config.json or fca-config.json to connect secret chats.", "info");
1391
- } else {
1362
+ if (!e2eeEnabled()) {
1363
+ logger("E2EE off. Set \"e2ee\": true in config.json to enable it.", "info");
1364
+ } else try {
1392
1365
  const e2eeModule = require("../src/api/socket/e2ee");
1393
1366
  api.e2ee = new e2eeModule.E2EEBridge(ctxMain, api, defaultFuncs);
1394
1367
  ctxMain.e2ee = api.e2ee;
1395
1368
  api.connectE2EE = (deviceStorePath) => api.e2ee.connect(deviceStorePath, ctxMain.userID);
1396
1369
  api.listenE2EE = require("../src/api/socket/listenE2EE")(defaultFuncs, api, ctxMain);
1370
+
1371
+ // Auto-connect E2EE and make it the default listener so existing
1372
+ // bots calling api.listen() OR api.listenMqtt() directly also
1373
+ // receive E2EE (Secret Conversation) messages without any extra
1374
+ // setup or changes on the bot side.
1375
+ //
1376
+ // [Fixed by xalman] IMPORTANT: assign api.listen/api.listenMqtt to the combined
1377
+ // listener SYNCHRONOUSLY, before connectE2EE() resolves. Bots
1378
+ // commonly call api.listenMqtt(callback) immediately in the login
1379
+ // callback - if we waited for the async connectE2EE() promise to
1380
+ // swap these over, that call would already have captured the old
1381
+ // plain-MQTT-only function, permanently missing E2EE (inbox)
1382
+ // messages even after E2EE finished connecting moments later.
1397
1383
  api.listen = api.listenE2EE;
1398
1384
  api.listenMqtt = api.listenE2EE;
1385
+
1386
+ // [Fixed by xalman] Retry E2EE auto-connect with backoff instead of
1387
+ // giving up forever after one failed attempt - a transient network
1388
+ // blip or momentary FB rate-limit on device registration used to
1389
+ // leave the bot stuck in group-only mode until a full restart.
1399
1390
  const connectE2EEWithRetry = async (attempt = 0) => {
1400
1391
  try {
1401
1392
  await api.connectE2EE();
1402
1393
  logger("E2EE auto-connected and merged into api.listen()/api.listenMqtt()");
1403
1394
  } catch (e) {
1404
1395
  const msg = e && e.message ? e.message : String(e);
1405
- if (attempt >= 2) {
1406
- logger(`E2EE auto-connect stopped after ${attempt + 1} tries: ${msg}`, "warn");
1407
- return;
1396
+ if (attempt < 3) {
1397
+ const delayMs = 5000 * Math.pow(3, attempt); // 5s, 15s, 45s
1398
+ logger(`E2EE auto-connect failed (attempt ${attempt + 1}/4): ${msg} - retrying in ${Math.round(delayMs / 1000)}s`, "warn");
1399
+ setTimeout(() => connectE2EEWithRetry(attempt + 1), delayMs);
1400
+ } else {
1401
+ logger(`E2EE auto-connect failed after 4 attempts (non-fatal, continuing without E2EE): ${msg}`, "warn");
1408
1402
  }
1409
- const delayMs = 15000 * (attempt + 1);
1410
- logger(`E2EE auto-connect failed (attempt ${attempt + 1}): ${msg} - retrying in ${Math.round(delayMs / 1000)}s`, "warn");
1411
- setTimeout(() => connectE2EEWithRetry(attempt + 1), delayMs);
1412
1403
  }
1413
1404
  };
1414
1405
  connectE2EEWithRetry();
1415
- }
1416
1406
  } catch (e) {
1417
1407
  logger(`E2EE init failed (non-fatal): ${e && e.message ? e.message : String(e)}`, "warn");
1418
1408
  }
@@ -1448,7 +1438,7 @@ function loginHelper(appState, Cookie, email, password, globalOptions, callback)
1448
1438
  // used to silently discard it, so only group messages arriving over
1449
1439
  // plain MQTT reached bot handlers.
1450
1440
  api._listenMqttRaw = stableListenMqtt;
1451
- if (e2eeEnabled() && typeof api.listenE2EE === "function") {
1441
+ if (typeof api.listenE2EE === "function") {
1452
1442
  api.listenMqtt = api.listen = api.listenE2EE;
1453
1443
  } else {
1454
1444
  api.listenMqtt = api.listen = stableListenMqtt;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fca-nx",
3
- "version": "6.8.6",
4
- "description": "Facebook Messenger API",
3
+ "version": "7.0.0",
4
+ "description": "Facebook Messenger API for Node.js — Fast, Secure, and Feature-Rich",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "exports": {
@@ -14,7 +14,7 @@ const logger = require("../../../func/logger");
14
14
  module.exports = function (defaultFuncs, api, ctx) {
15
15
  return function enableAutoSaveAppState(options = {}) {
16
16
  const filePath = options.filePath || path.join(process.cwd(), "appstate.json");
17
- const interval = options.interval || 5 * 60 * 1000; // [Hardened] 5 minutes default - keep session cookies fresh on disk
17
+ const interval = options.interval || 10 * 60 * 1000; // 10 minutes default
18
18
  const saveOnLogin = options.saveOnLogin !== false; // default true
19
19
 
20
20
  // Save function
@@ -1,35 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  const { getFrom } = require("../../utils/constants");
4
- const { get } = require("../../utils/request");
4
+ const { get } = require("../../utils/request")
5
5
  const { getType } = require("../../utils/format");
6
- const logger = require("../../../func/logger");
7
-
8
- function extractTokens(html) {
9
- if (!html || typeof html !== "string") return null;
10
- const fb_dtsg =
11
- getFrom(html, '["DTSGInitData",[],{"token":"', '","') ||
12
- getFrom(html, '"DTSGInitialData",[],{"token":"', '"') ||
13
- getFrom(html, 'name="fb_dtsg" value="', '"') ||
14
- getFrom(html, '"fb_dtsg":{"token":"', '"') ||
15
- getFrom(html, "fb_dtsg\":{\"token\":\"", "\"") ||
16
- null;
17
- const jazoest =
18
- getFrom(html, "jazoest=", '",') ||
19
- getFrom(html, 'name="jazoest" value="', '"') ||
20
- getFrom(html, '"jazoest":"', '"') ||
21
- null;
22
- if (!fb_dtsg) return null;
23
- return { fb_dtsg, jazoest: jazoest || (ctxJazoestFallback(fb_dtsg)) };
24
- }
25
-
26
- function ctxJazoestFallback(token) {
27
- // Classic jazoest = 2 + sum of char codes of fb_dtsg
28
- let sum = 0;
29
- for (let i = 0; i < token.length; i++) sum += token.charCodeAt(i);
30
- return "2" + sum;
31
- }
32
-
33
6
  module.exports = function (defaultFuncs, api, ctx) {
34
7
  return function refreshFb_dtsg(obj, callback) {
35
8
  if (typeof obj === "function") {
@@ -46,60 +19,29 @@ module.exports = function (defaultFuncs, api, ctx) {
46
19
  rejectFunc = reject;
47
20
  });
48
21
  if (!callback) {
49
- callback = (err, data) => (err ? rejectFunc(err) : resolveFunc(data));
22
+ callback = (err, data) => err ? rejectFunc(err) : resolveFunc(data);
50
23
  }
51
-
52
- if (Object.keys(obj).length > 0) {
24
+ if (Object.keys(obj).length === 0) {
25
+ get("https://www.facebook.com/", ctx.jar, null, ctx.globalOptions, { noRef: true }).then(({ data }) => {
26
+ const fb_dtsg = getFrom(data, '["DTSGInitData",[],{"token":"', '","');
27
+ const jazoest = getFrom(data, "jazoest=", '",');
28
+ if (!fb_dtsg) throw new Error("Could not find fb_dtsg in HTML after requesting Facebook.");
29
+ Object.assign(ctx, { fb_dtsg, jazoest });
30
+ callback(null, {
31
+ data: { fb_dtsg, jazoest },
32
+ message: "Refreshed fb_dtsg and jazoest",
33
+ });
34
+ }).catch(err => {
35
+ console.error("refreshFb_dtsg", err);
36
+ callback(err);
37
+ });
38
+ } else {
53
39
  Object.assign(ctx, obj);
54
40
  callback(null, {
55
41
  data: obj,
56
- message: `Refreshed ${Object.keys(obj).join(", ")}`
42
+ message: `Refreshed ${Object.keys(obj).join(", ")}`,
57
43
  });
58
- return returnPromise;
59
44
  }
60
-
61
- const urls = [
62
- "https://www.facebook.com/",
63
- "https://www.facebook.com/messages/",
64
- "https://www.messenger.com/"
65
- ];
66
-
67
- (async () => {
68
- let lastErr = null;
69
- for (let attempt = 0; attempt < 3; attempt++) {
70
- for (const url of urls) {
71
- try {
72
- const res = await get(url, ctx.jar, null, ctx.globalOptions, { noRef: true });
73
- const html = typeof res === "string" ? res : res && res.data;
74
- const tokens = extractTokens(html);
75
- if (tokens && tokens.fb_dtsg) {
76
- Object.assign(ctx, { fb_dtsg: tokens.fb_dtsg, jazoest: tokens.jazoest });
77
- // Persist cookies from the HTML response if available
78
- try {
79
- const { saveCookies } = require("../../utils/client");
80
- if (res && res.headers) saveCookies(ctx.jar)(res);
81
- } catch (_) {}
82
- callback(null, {
83
- data: { fb_dtsg: tokens.fb_dtsg, jazoest: tokens.jazoest },
84
- message: "Refreshed fb_dtsg and jazoest"
85
- });
86
- return;
87
- }
88
- } catch (e) {
89
- lastErr = e;
90
- logger(
91
- `refreshFb_dtsg attempt ${attempt + 1} ${url}: ${e && e.message ? e.message : e}`,
92
- "warn"
93
- );
94
- }
95
- }
96
- await new Promise((r) => setTimeout(r, 1000 * (attempt + 1)));
97
- }
98
- const err = lastErr || new Error("Could not find fb_dtsg in HTML after multiple attempts.");
99
- logger(`refreshFb_dtsg failed: ${err.message || err}`, "error");
100
- callback(err);
101
- })();
102
-
103
45
  return returnPromise;
104
46
  };
105
47
  };
@@ -171,6 +171,19 @@ module.exports = function (defaultFuncs, api, ctx) {
171
171
  metadata_dataclass: JSON.stringify({ media_accessibility_metadata: { alt_text: null } })
172
172
  };
173
173
 
174
+ // --- TEXT EFFECTS SUPPORT FOR MQTT ---
175
+ if (m.text_effect_ids) {
176
+ let effectArray = [];
177
+ if (Array.isArray(m.text_effect_ids)) {
178
+ effectArray = m.text_effect_ids;
179
+ } else if (typeof m.text_effect_ids === "string" || typeof m.text_effect_ids === "number") {
180
+ effectArray = [m.text_effect_ids];
181
+ }
182
+ if (effectArray.length > 0) {
183
+ payload0.text_effect_ids = effectArray.map(id => String(id));
184
+ }
185
+ }
186
+
174
187
  const mentionData = buildMentionData(m, baseBody);
175
188
  if (mentionData) payload0.mention_data = mentionData;
176
189
 
@@ -8,7 +8,6 @@ module.exports = function (defaultFuncs, api, ctx) {
8
8
  resolveFunc = resolve;
9
9
  rejectFunc = reject;
10
10
  });
11
- returnPromise.catch(function () { }); // [Fixed by xalman] unawaited callers caused unhandledRejection
12
11
  if (getType(options) == "Function" || getType(options) == "AsyncFunction") {
13
12
  callback = options;
14
13
  options = {};
@@ -23,20 +22,6 @@ module.exports = function (defaultFuncs, api, ctx) {
23
22
  if (!threadID) {
24
23
  return callback(new Error("threadID is required"));
25
24
  }
26
- // [Fixed by xalman] E2EE DM: show typing through the E2EE bridge instead of (useless) MQTT.
27
- if (typeof threadID === "string" || typeof threadID === "number") {
28
- var _tid = String(threadID);
29
- if (ctx.threadTypes && ctx.threadTypes[_tid] === "dm" && ctx.e2ee &&
30
- typeof ctx.e2ee.isConnected === "function" && ctx.e2ee.isConnected()) {
31
- ctx.e2ee.sendTyping(_tid, !!isTyping).catch(function () { });
32
- if (isTyping && options.autoStop !== false) {
33
- var _t = setTimeout(function () { ctx.e2ee.sendTyping(_tid, false).catch(function () { }); }, options.duration || 10000);
34
- if (_t.unref) _t.unref();
35
- }
36
- callback(null, true);
37
- return returnPromise;
38
- }
39
- }
40
25
  if (!ctx.mqttClient) {
41
26
  const err = new Error("Not connected to MQTT");
42
27
  callback(err);
@@ -3,10 +3,14 @@
3
3
  var utils = require("../../utils/utils");
4
4
  var logger = require("../../utils/logger");
5
5
  var bluebird = require("bluebird");
6
+ var { getTextEffectId } = require("../../utils/textEffects");
6
7
 
7
8
  var allowedProperties = {
8
9
  attachment: true, url: true, sticker: true, emoji: true,
9
- emojiSize: true, body: true, mentions: true, location: true
10
+ emojiSize: true, body: true, mentions: true, location: true, text_effect_ids: true,
11
+ textEffect: true, text_effect: true, text_effect_id: true, textEffectId: true,
12
+ textEffectID: true, effect: true, effect_id: true, effectID: true,
13
+ text_effect_name: true, effectName: true, effect_name: true,
10
14
  };
11
15
 
12
16
  module.exports = function (defaultFuncs, api, ctx) {
@@ -114,7 +118,6 @@ module.exports = function (defaultFuncs, api, ctx) {
114
118
 
115
119
  return function OldMessage(msg, threadID, callback, replyToMessage, isSingleUser) {
116
120
  if (typeof msg === "string") msg = { body: msg };
117
- ["text_effect_ids", "textEffect", "text_effect", "text_effect_id", "textEffectId", "textEffectID", "effect", "effect_id", "effectID", "text_effect_name", "effectName", "effect_name"].forEach(function (k) { delete msg[k]; });
118
121
 
119
122
  if (msg.body && /(https?:\/\/|www\.|t\.me\/|fb\.me\/|youtu\.be\/|facebook\.com\/|youtube\.com\/)/i.test(msg.body)) {
120
123
  return require('./sendMessage')(defaultFuncs, api, ctx)(msg, threadID, callback, replyToMessage, false);
@@ -135,6 +138,8 @@ module.exports = function (defaultFuncs, api, ctx) {
135
138
 
136
139
  var form = {};
137
140
  if (msg.body) form.body = msg.body;
141
+ var textEffectId = getTextEffectId(msg);
142
+ if (textEffectId) form.text_effect_id = textEffectId;
138
143
 
139
144
  if (msg.mentions && Array.isArray(msg.mentions)) {
140
145
  form.body = msg.body || "";