@dongdev/fca-unofficial 2.0.19 → 2.0.20

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
@@ -92,3 +92,6 @@ Too lazy to write changelog, sorry! (will write changelog in the next release, t
92
92
 
93
93
  ## v2.0.18 - 2025-10-07
94
94
  - Hotfix / auto bump
95
+
96
+ ## v2.0.19 - 2025-10-07
97
+ - Hotfix / auto bump
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dongdev/fca-unofficial",
3
- "version": "2.0.19",
3
+ "version": "2.0.20",
4
4
  "description": "Unofficial Facebook Chat API for Node.js - Interact with Facebook Messenger programmatically",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,68 @@
1
+ "use_strict";
2
+
3
+ const { generateOfflineThreadingID } = require("../../utils/format.js");
4
+ module.exports = (defaultFuncs, api, ctx) => {
5
+ return (text, messageID, callback) => {
6
+ let reqID = ctx.wsReqNumber + 1;
7
+ var resolveFunc = () => { };
8
+ var rejectFunc = () => { };
9
+ var returnPromise = new Promise((resolve, reject) => {
10
+ resolveFunc = resolve;
11
+ rejectFunc = reject;
12
+ });
13
+ if (!callback) {
14
+ callback = (err, data) => {
15
+ if (err) {
16
+ return rejectFunc(err);
17
+ }
18
+ resolveFunc(data);
19
+ };
20
+ }
21
+ const content = {
22
+ app_id: '2220391788200892',
23
+ payload: JSON.stringify({
24
+ data_trace_id: null,
25
+ epoch_id: parseInt(generateOfflineThreadingID()),
26
+ tasks: [{
27
+ failure_count: null,
28
+ label: '742',
29
+ payload: JSON.stringify({
30
+ message_id: messageID,
31
+ text: text,
32
+ }),
33
+ queue_name: 'edit_message',
34
+ task_id: ++ctx.wsTaskNumber,
35
+ }],
36
+ version_id: '6903494529735864',
37
+ }),
38
+ request_id: ++ctx.wsReqNumber,
39
+ type: 3
40
+ }
41
+ ctx.mqttClient.publish('/ls_req', JSON.stringify(content), {
42
+ qos: 1,
43
+ retain: false
44
+ });
45
+ const handleRes = (topic, message) => {
46
+ if (topic === "/ls_resp") {
47
+ let jsonMsg = JSON.parse(message.toString());
48
+ jsonMsg.payload = JSON.parse(jsonMsg.payload);
49
+ if (jsonMsg.request_id != reqID) return;
50
+ ctx.mqttClient.removeListener('message', handleRes);
51
+ let msgID = jsonMsg.payload.step[1][2][2][1][2];
52
+ let msgReplace = jsonMsg.payload.step[1][2][2][1][4];
53
+ const bodies = {
54
+ body: msgReplace,
55
+ messageID: msgID
56
+ };
57
+ if (msgReplace != text) {
58
+ return callback({
59
+ error: "The message is too old or not from you!"
60
+ }, bodies);
61
+ }
62
+ return callback(undefined, bodies);
63
+ }
64
+ }
65
+ ctx.mqttClient.on('message', handleRes);
66
+ return returnPromise;
67
+ };
68
+ }
@@ -99,10 +99,10 @@ function parseAndCheckLogin(ctx, http, retryCount = 0) {
99
99
  throw e;
100
100
  }
101
101
  ctx.auto_login = true;
102
- logL("Phiên đăng nhập hết hạn", "warn");
102
+ logger("Login session expired", "warn");
103
103
  const ok = await ctx.performAutoLogin();
104
104
  if (ok) {
105
- logL("Auto login successful! Restarting...", "AUTO-LOGIN");
105
+ logger("Auto login successful! Restarting...");
106
106
  ctx.auto_login = false;
107
107
  process.exit(1);
108
108
  } else {