sagor-nx-fca 0.0.1

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.
Files changed (116) hide show
  1. package/README.md +524 -0
  2. package/func/checkUpdate.js +222 -0
  3. package/func/logAdapter.js +33 -0
  4. package/func/logger.js +48 -0
  5. package/index.d.ts +751 -0
  6. package/index.js +8 -0
  7. package/module/config.js +40 -0
  8. package/module/login.js +133 -0
  9. package/module/loginHelper.js +1296 -0
  10. package/module/options.js +44 -0
  11. package/package.json +89 -0
  12. package/src/api/action/addExternalModule.js +25 -0
  13. package/src/api/action/changeAvatar.js +137 -0
  14. package/src/api/action/changeBio.js +75 -0
  15. package/src/api/action/enableAutoSaveAppState.js +73 -0
  16. package/src/api/action/getCurrentUserID.js +7 -0
  17. package/src/api/action/handleFriendRequest.js +57 -0
  18. package/src/api/action/logout.js +76 -0
  19. package/src/api/action/refreshFb_dtsg.js +48 -0
  20. package/src/api/action/setPostReaction.js +106 -0
  21. package/src/api/action/unfriend.js +54 -0
  22. package/src/api/http/httpGet.js +46 -0
  23. package/src/api/http/httpPost.js +52 -0
  24. package/src/api/http/postFormData.js +47 -0
  25. package/src/api/messaging/addUserToGroup.js +68 -0
  26. package/src/api/messaging/changeAdminStatus.js +126 -0
  27. package/src/api/messaging/changeArchivedStatus.js +55 -0
  28. package/src/api/messaging/changeBlockedStatus.js +48 -0
  29. package/src/api/messaging/changeGroupImage.js +91 -0
  30. package/src/api/messaging/changeNickname.js +70 -0
  31. package/src/api/messaging/changeThreadColor.js +79 -0
  32. package/src/api/messaging/changeThreadEmoji.js +111 -0
  33. package/src/api/messaging/createNewGroup.js +88 -0
  34. package/src/api/messaging/createPoll.js +46 -0
  35. package/src/api/messaging/createThemeAI.js +98 -0
  36. package/src/api/messaging/deleteMessage.js +136 -0
  37. package/src/api/messaging/deleteThread.js +56 -0
  38. package/src/api/messaging/editMessage.js +68 -0
  39. package/src/api/messaging/forwardAttachment.js +57 -0
  40. package/src/api/messaging/getEmojiUrl.js +29 -0
  41. package/src/api/messaging/getFriendsList.js +82 -0
  42. package/src/api/messaging/getMessage.js +829 -0
  43. package/src/api/messaging/getThemePictures.js +62 -0
  44. package/src/api/messaging/handleMessageRequest.js +65 -0
  45. package/src/api/messaging/markAsDelivered.js +57 -0
  46. package/src/api/messaging/markAsRead.js +88 -0
  47. package/src/api/messaging/markAsReadAll.js +49 -0
  48. package/src/api/messaging/markAsSeen.js +61 -0
  49. package/src/api/messaging/muteThread.js +50 -0
  50. package/src/api/messaging/removeUserFromGroup.js +62 -0
  51. package/src/api/messaging/resolvePhotoUrl.js +43 -0
  52. package/src/api/messaging/scheduler.js +264 -0
  53. package/src/api/messaging/searchForThread.js +53 -0
  54. package/src/api/messaging/sendMessage.js +270 -0
  55. package/src/api/messaging/sendTypingIndicator.js +74 -0
  56. package/src/api/messaging/setMessageReaction.js +90 -0
  57. package/src/api/messaging/setTitle.js +124 -0
  58. package/src/api/messaging/shareContact.js +49 -0
  59. package/src/api/messaging/threadColors.js +128 -0
  60. package/src/api/messaging/unsendMessage.js +81 -0
  61. package/src/api/messaging/uploadAttachment.js +492 -0
  62. package/src/api/socket/core/connectMqtt.js +258 -0
  63. package/src/api/socket/core/emitAuth.js +103 -0
  64. package/src/api/socket/core/getSeqID.js +320 -0
  65. package/src/api/socket/core/getTaskResponseData.js +25 -0
  66. package/src/api/socket/core/parseDelta.js +377 -0
  67. package/src/api/socket/detail/buildStream.js +215 -0
  68. package/src/api/socket/detail/constants.js +28 -0
  69. package/src/api/socket/listenMqtt.js +377 -0
  70. package/src/api/socket/middleware/index.js +216 -0
  71. package/src/api/threads/getThreadHistory.js +664 -0
  72. package/src/api/threads/getThreadInfo.js +296 -0
  73. package/src/api/threads/getThreadList.js +293 -0
  74. package/src/api/threads/getThreadPictures.js +78 -0
  75. package/src/api/users/getUserID.js +65 -0
  76. package/src/api/users/getUserInfo.js +402 -0
  77. package/src/api/users/getUserInfoV2.js +134 -0
  78. package/src/core/sendReqMqtt.js +96 -0
  79. package/src/database/helpers.js +53 -0
  80. package/src/database/models/index.js +88 -0
  81. package/src/database/models/thread.js +50 -0
  82. package/src/database/models/user.js +46 -0
  83. package/src/database/threadData.js +94 -0
  84. package/src/database/userData.js +98 -0
  85. package/src/remote/remoteClient.js +123 -0
  86. package/src/utils/broadcast.js +51 -0
  87. package/src/utils/client.js +10 -0
  88. package/src/utils/constants.js +23 -0
  89. package/src/utils/cookies.js +68 -0
  90. package/src/utils/format/attachment.js +357 -0
  91. package/src/utils/format/cookie.js +9 -0
  92. package/src/utils/format/date.js +50 -0
  93. package/src/utils/format/decode.js +44 -0
  94. package/src/utils/format/delta.js +194 -0
  95. package/src/utils/format/ids.js +64 -0
  96. package/src/utils/format/index.js +64 -0
  97. package/src/utils/format/message.js +88 -0
  98. package/src/utils/format/presence.js +132 -0
  99. package/src/utils/format/readTyp.js +44 -0
  100. package/src/utils/format/thread.js +42 -0
  101. package/src/utils/format/utils.js +141 -0
  102. package/src/utils/headers.js +115 -0
  103. package/src/utils/loginParser/autoLogin.js +125 -0
  104. package/src/utils/loginParser/helpers.js +43 -0
  105. package/src/utils/loginParser/index.js +10 -0
  106. package/src/utils/loginParser/parseAndCheckLogin.js +220 -0
  107. package/src/utils/loginParser/textUtils.js +28 -0
  108. package/src/utils/request/client.js +26 -0
  109. package/src/utils/request/config.js +23 -0
  110. package/src/utils/request/defaults.js +46 -0
  111. package/src/utils/request/helpers.js +46 -0
  112. package/src/utils/request/index.js +17 -0
  113. package/src/utils/request/methods.js +163 -0
  114. package/src/utils/request/proxy.js +21 -0
  115. package/src/utils/request/retry.js +77 -0
  116. package/src/utils/request/sanitize.js +49 -0
package/README.md ADDED
@@ -0,0 +1,524 @@
1
+ <div align="center">
2
+
3
+ # sagor-nx-fca
4
+
5
+ **Unofficial Facebook Chat API for Node.js** - Interact with Facebook Messenger programmatically
6
+
7
+ [Features](#-features) • [Installation](#-installation) • [Quick Start](#-quick-start) • [Documentation](#-documentation) • [Support](#-author--support)
8
+
9
+ </div>
10
+
11
+ ---
12
+
13
+ ## 📋 Table of Contents
14
+
15
+ - [⚠️ Disclaimer & Support Policy](#️-disclaimer--support-policy)
16
+ - [⚡ Why this fork?](#-why-this-fork)
17
+ - [✨ Features](#-features)
18
+ - [🔍 Introduction](#-introduction)
19
+ - [📦 Installation](#-installation)
20
+ - [🚀 Quick Start](#-quick-start)
21
+ - [📝 Message Types](#-message-types)
22
+ - [💾 AppState Management](#-appstate-management)
23
+ - [🔄 Auto Login](#-auto-login)
24
+ - [👂 Listening for Messages](#-listening-for-messages)
25
+ - [🎯 API Quick Reference](#-api-quick-reference)
26
+ - [📚 Documentation](#-documentation)
27
+ - [🛠️ Projects Using This API](#️-projects-using-this-api)
28
+ - [🤝 Contributing](#-contributing)
29
+ - [📄 License](#-license)
30
+ - [👨‍💻 Author & Support](#-author--support)
31
+
32
+ ---
33
+
34
+ ## ⚠️ Disclaimer & Support Policy
35
+
36
+ <div align="center">
37
+
38
+ **READ THIS BEFORE USING OR OPENING AN ISSUE.**
39
+
40
+ </div>
41
+
42
+ This repository is provided **"AS IS"** and is entirely open-source. By using this project, you explicitly agree to the following terms:
43
+
44
+ 1. **Use at your own risk:** We are NOT responsible if your account gets banned for spammy activities (sending messages too fast, unsolicited mass messaging, suspicious URLs, or rapid login/logout).
45
+ 2. **No Spoon-Feeding:** This is a tool for developers. If you cannot read source code, navigate directories, or use basic search tools (`Ctrl + Shift + F`), you should not be using this library.
46
+ 3. **No Free Programming Lessons:** I maintain the core updates and security patches for the community for free. I do **not** provide free JavaScript/TypeScript tutorials, nor will I tell you exactly which line of code to edit for your specific bot.
47
+ 4. **Custom Features = Paid Service:** Brainpower and time are not free. If you need me to write custom logic, reverse-engineer specific endpoints, or provide 1-on-1 support for your personal project, **that is a paid service**.
48
+
49
+ If you don't like this policy, feel free to fork the repository and maintain it yourself.
50
+
51
+ **Recommendations to avoid bans:**
52
+
53
+ - Use **Firefox** or the [fca.dongdev.id.vn](https://fca.dongdev.id.vn) flow to reduce logout issues (especially on iOS).
54
+ - Prefer **AppState** over email/password when possible.
55
+ - Use strict **rate limiting** in your bots.
56
+
57
+ ---
58
+
59
+ ## ⚡ Why this fork?
60
+
61
+ Unlike other outdated forks, `@sagor/fca-unofficial` is built with a focus on **real-world practicality and performance**:
62
+
63
+ - **Performance First:** Stripped out legacy, redundant code that causes technical debt.
64
+ - **Modernized Architecture:** Adapted to the latest Facebook backend structure.
65
+ - **Clean Logic:** No messy wrappers. The codebase is straightforward and easy to navigate if you actually open the files.
66
+
67
+ ---
68
+
69
+ ## ✨ Features
70
+
71
+ - ✅ **Full Messenger API** - Send messages, files, stickers, and more
72
+ - ✅ **Real-time Events** - Listen to messages, reactions, and thread events
73
+ - ✅ **User Account Support** - Works with personal Facebook accounts (not just Pages)
74
+ - ✅ **AppState Support** - Save login state to avoid re-authentication
75
+ - ✅ **MQTT Protocol** - Real-time messaging via MQTT
76
+ - ✅ **TypeScript Support** - Includes TypeScript definitions
77
+ - ✅ **Active Development** - Regularly updated and maintained
78
+
79
+ ---
80
+
81
+ ## 🔍 Introduction
82
+
83
+ Facebook provides an [official API for chat bots](https://developers.facebook.com/docs/messenger-platform), but it's **only available for Facebook Pages**.
84
+
85
+ `@sagor/fca-unofficial` is the API that allows you to automate chat functionalities on a **user account** by emulating the browser. This means:
86
+
87
+ - 🔄 Making the exact same GET/POST requests as a browser
88
+ - 🔐 Does not work with auth tokens
89
+ - 📝 Requires Facebook account credentials (email/password) or AppState
90
+
91
+ **Perfect for:**
92
+
93
+ - 🤖 Building chatbots
94
+ - 📱 Automating message responses
95
+ - 🔔 Creating notification systems
96
+ - 🎮 Building interactive games
97
+ - 📊 Analytics and monitoring
98
+
99
+ ---
100
+
101
+ ## 📦 Installation
102
+
103
+ ```bash
104
+ npm install @sagor/fca-unofficial@latest
105
+ ```
106
+
107
+ **Requirements:**
108
+
109
+ - Node.js >= 12.0.0
110
+ - Active Facebook account
111
+
112
+ ---
113
+
114
+ ## 🚀 Quick Start
115
+
116
+ ### 1️⃣ Login and Simple Echo Bot
117
+
118
+ ```javascript
119
+ const login = require("@sagor/fca-unofficial");
120
+
121
+ login({ appState: [] }, (err, api) => {
122
+ if (err) return console.error(err);
123
+
124
+ api.listenMqtt((err, event) => {
125
+ if (err) return console.error(err);
126
+
127
+ // Echo back the received message
128
+ if (event.type === "message") {
129
+ api.sendMessage(event.body, event.threadID);
130
+ }
131
+ });
132
+ });
133
+ ```
134
+
135
+ ### 2️⃣ Send Text Message
136
+
137
+ ```javascript
138
+ const login = require("@sagor/fca-unofficial");
139
+
140
+ login({ appState: [] }, (err, api) => {
141
+ if (err) {
142
+ console.error("Login Error:", err);
143
+ return;
144
+ }
145
+
146
+ const yourID = "000000000000000"; // Replace with actual Facebook ID
147
+ const msg = "Hey! 👋";
148
+
149
+ api.sendMessage(msg, yourID, (err) => {
150
+ if (err) console.error("Message Sending Error:", err);
151
+ else console.log("✅ Message sent successfully!");
152
+ });
153
+ });
154
+ ```
155
+
156
+ > **💡 Tip:** To find your Facebook ID, look inside the cookies under the name `c_user`
157
+
158
+ ### 3️⃣ Send File/Image
159
+
160
+ ```javascript
161
+ const login = require("@sagor/fca-unofficial");
162
+ const fs = require("fs");
163
+
164
+ login({ appState: [] }, (err, api) => {
165
+ if (err) {
166
+ console.error("Login Error:", err);
167
+ return;
168
+ }
169
+
170
+ const yourID = "000000000000000";
171
+ const imagePath = __dirname + "/image.jpg";
172
+
173
+ // Check if file exists
174
+ if (!fs.existsSync(imagePath)) {
175
+ console.error("❌ Error: Image file not found!");
176
+ return;
177
+ }
178
+
179
+ const msg = {
180
+ body: "Check out this image! 📷",
181
+ attachment: fs.createReadStream(imagePath),
182
+ };
183
+
184
+ api.sendMessage(msg, yourID, (err) => {
185
+ if (err) console.error("Message Sending Error:", err);
186
+ else console.log("✅ Image sent successfully!");
187
+ });
188
+ });
189
+ ```
190
+
191
+ ---
192
+
193
+ ## 📝 Message Types
194
+
195
+ | Type | Usage | Example |
196
+ | ---------------- | ------------------------------------------- | -------------------------------------------------- |
197
+ | **Regular text** | `{ body: "message text" }` | `{ body: "Hello!" }` |
198
+ | **Sticker** | `{ sticker: "sticker_id" }` | `{ sticker: "369239263222822" }` |
199
+ | **File/Image** | `{ attachment: fs.createReadStream(path) }` | `{ attachment: fs.createReadStream("image.jpg") }` |
200
+ | **URL** | `{ url: "https://example.com" }` | `{ url: "https://github.com" }` |
201
+ | **Large emoji** | `{ emoji: "👍", emojiSize: "large" }` | `{ emoji: "👍", emojiSize: "large" }` |
202
+
203
+ > **📌 Note:** A message can only be a regular message (which can be empty) and optionally **one of the following**: a sticker, an attachment, or a URL.
204
+
205
+ **Emoji sizes:** `small` | `medium` | `large`
206
+
207
+ ---
208
+
209
+ ## 💾 AppState Management
210
+
211
+ ### Save AppState
212
+
213
+ Save your login session to avoid re-authentication:
214
+
215
+ ```javascript
216
+ const fs = require("fs");
217
+ const login = require("@sagor/fca-unofficial");
218
+
219
+ const credentials = { email: "YOUR_EMAIL", password: "YOUR_PASSWORD" }; // Or use existing appState
220
+
221
+ login(credentials, (err, api) => {
222
+ if (err) {
223
+ console.error("Login Error:", err);
224
+ return;
225
+ }
226
+
227
+ try {
228
+ const appState = JSON.stringify(api.getAppState(), null, 2);
229
+ fs.writeFileSync("appstate.json", appState);
230
+ console.log("✅ AppState saved successfully!");
231
+ } catch (error) {
232
+ console.error("❌ Error saving AppState:", error);
233
+ }
234
+ });
235
+ ```
236
+
237
+ ### Use Saved AppState
238
+
239
+ Load your saved AppState for faster login:
240
+
241
+ ```javascript
242
+ const fs = require("fs");
243
+ const login = require("@sagor/fca-unofficial");
244
+
245
+ login(
246
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
247
+ (err, api) => {
248
+ if (err) {
249
+ console.error("Login Error:", err);
250
+ return;
251
+ }
252
+
253
+ console.log("✅ Logged in successfully!");
254
+ // Your code here
255
+ },
256
+ );
257
+ ```
258
+
259
+ ---
260
+
261
+ ## 🔄 Auto Login
262
+
263
+ When your session (AppState) expires, the library can **automatically re-login** using credentials from a config file, so your bot can keep running without manual intervention.
264
+
265
+ 1. Create **`fca-config.json`** in your project root (same folder as where you run `node`):
266
+
267
+ ```json
268
+ {
269
+ "autoLogin": true,
270
+ "apiServer": "https://minhdong.site",
271
+ "apiKey": "",
272
+ "credentials": {
273
+ "email": "YOUR_EMAIL_OR_PHONE",
274
+ "password": "YOUR_PASSWORD",
275
+ "twofactor": ""
276
+ }
277
+ }
278
+ ```
279
+
280
+ 2. **Log in with AppState** as usual. If the session later expires (e.g. Facebook invalidates cookies), the library will use `credentials` (and optionally the external `apiServer`) to log in again and retry the request.
281
+
282
+ - Set **`autoLogin`** to `false` to disable automatic re-login.
283
+ - **`twofactor`**: Base32 secret for 2FA (not the 6-digit code). Leave empty if you do not use 2FA.
284
+ - **`apiServer`** / **`apiKey`**: Optional; used for external iOS-style login. Default server is `https://minhdong.site`.
285
+
286
+ Keep **`fca-config.json`** out of version control (add it to `.gitignore`) since it contains credentials.
287
+
288
+ ---
289
+
290
+ ## 🔐 Security, Trust & Supply Chain
291
+
292
+ - Published via **GitHub Actions** using `npm publish --provenance`, so the tarball on npm can be cryptographically tied back to this repo.
293
+ - Core runtime code in `module/` and `src/` is **readable JavaScript** with no obfuscated logic.
294
+ - Legacy forks (such as Horizon) are kept only for reference and are **not** shipped in the npm package.
295
+ - No telemetry or hidden network calls:
296
+ - All HTTP traffic is implemented in `src/utils/request.js` and `module/loginHelper.js`.
297
+ - External URLs (such as `apiServer` or proxies) are fully user‑configurable.
298
+ - The npm publish account uses **2FA** and dedicated automation tokens.
299
+
300
+ See `SECURITY.md` for more details.
301
+
302
+ ---
303
+
304
+ ## 👂 Listening for Messages
305
+
306
+ ### Echo Bot with Stop Command
307
+
308
+ ```javascript
309
+ const fs = require("fs");
310
+ const login = require("@sagor/fca-unofficial");
311
+
312
+ login(
313
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
314
+ (err, api) => {
315
+ if (err) return console.error("Login Error:", err);
316
+
317
+ // Enable listening to events (join/leave, title change, etc.)
318
+ api.setOptions({ listenEvents: true });
319
+
320
+ const stopListening = api.listenMqtt((err, event) => {
321
+ if (err) return console.error("Listen Error:", err);
322
+
323
+ // Mark as read
324
+ api.markAsRead(event.threadID, (err) => {
325
+ if (err) console.error("Mark as read error:", err);
326
+ });
327
+
328
+ // Handle different event types
329
+ switch (event.type) {
330
+ case "message":
331
+ if (event.body && event.body.trim().toLowerCase() === "/stop") {
332
+ api.sendMessage("Goodbye… 👋", event.threadID);
333
+ stopListening();
334
+ return;
335
+ }
336
+ api.sendMessage(`🤖 BOT: ${event.body}`, event.threadID);
337
+ break;
338
+
339
+ case "event":
340
+ console.log("📢 Event Received:", event);
341
+ break;
342
+ }
343
+ });
344
+ },
345
+ );
346
+ ```
347
+
348
+ ### Listen Options
349
+
350
+ Configure listening behavior:
351
+
352
+ ```javascript
353
+ api.setOptions({
354
+ listenEvents: true, // Receive events (join/leave, rename, etc.)
355
+ selfListen: true, // Receive messages from yourself
356
+ logLevel: "silent", // Disable logs (silent/error/warn/info/verbose)
357
+ });
358
+ ```
359
+
360
+ ---
361
+
362
+ ## 🎯 API Quick Reference
363
+
364
+ _(For full details, please read the source code or `DOCS.md`)_
365
+
366
+ ### 📨 Messaging
367
+
368
+ `sendMessage`, `sendTypingIndicator`, `getMessage`, `editMessage`, `deleteMessage`, `unsendMessage`, `setMessageReaction`, `forwardAttachment`, `uploadAttachment`, `createPoll`
369
+
370
+ ### 📬 Read Receipt & Delivery
371
+
372
+ `markAsRead`, `markAsReadAll`, `markAsDelivered`, `markAsSeen`
373
+
374
+ ### 👥 Thread Management
375
+
376
+ `getThreadInfo`, `getThreadList`, `getThreadHistory`, `deleteThread`, `changeThreadColor`, `changeThreadEmoji`, `changeGroupImage`, `setTitle`, `changeNickname`
377
+
378
+ ### 👤 User & Group Management
379
+
380
+ `getUserInfo`, `getFriendsList`, `getCurrentUserID`, `createNewGroup`, `addUserToGroup`, `removeUserFromGroup`, `changeAdminStatus`
381
+
382
+ ### ⚙️ Thread Settings & Actions
383
+
384
+ `muteThread`, `changeArchivedStatus`, `changeBlockedStatus`, `handleMessageRequest`, `changeAvatar`, `changeBio`, `handleFriendRequest`, `unfriend`
385
+
386
+ ### 🔐 Auth & Listening
387
+
388
+ `logout`, `getAppState`, `setOptions`, `listenMqtt`
389
+
390
+ ---
391
+ ## 🎛 Event Hooks & Remote Control (Advanced)
392
+
393
+ Starting from `3.x`, the API instance also behaves like an **EventEmitter** for lifecycle and remote‑control events:
394
+
395
+ - **Lifecycle events**:
396
+ - `sessionExpired` — login session is no longer valid, auto‑login will be attempted (if configured).
397
+ - `autoLoginSuccess` — auto‑login succeeded and the failed request will be retried.
398
+ - `autoLoginFailed` — auto‑login could not recover the session.
399
+ - `checkpoint` — generic checkpoint, with subtype in `{ type: "282" | "956" | "scraping_warning" }`.
400
+ - `checkpoint_282`, `checkpoint_956` — more specific checkpoint events.
401
+ - `loginBlocked` — Facebook actively blocked the login (error `1357001`).
402
+ - `rateLimit` — HTTP 429 detected on Facebook endpoints.
403
+ - `networkError` — network‑level failure (timeouts, DNS, connection reset, etc.).
404
+
405
+ Usage:
406
+
407
+ ```javascript
408
+ api.on("checkpoint_956", ({ res }) => {
409
+ console.error("Checkpoint 956 detected, manual action required.");
410
+ });
411
+
412
+ api.on("rateLimit", ({ url, method }) => {
413
+ console.warn("Rate limit hit on", method, url);
414
+ });
415
+ ```
416
+
417
+ - **Remote control events** (when `remoteControl.enabled` is `true` in `fca-config.json`):
418
+ - `remoteConnected` / `remoteDisconnected`
419
+ - `remoteStop`
420
+ - `remoteBroadcast`
421
+ - `remoteMessage` (raw messages from your WS backend)
422
+
423
+ See `examples/remote-control.js` for a concrete integration example.
424
+
425
+ ---
426
+
427
+ ## 🌐 Proxy Configuration & Broadcast Helper
428
+
429
+ - **Proxy support**:
430
+ - You can pass a proxy per‑login:
431
+
432
+ ```javascript
433
+ login({ appState }, (err, api) => {
434
+ if (err) return console.error(err);
435
+ api.setOptions({ proxy: "http://user:pass@host:port" });
436
+ });
437
+ ```
438
+
439
+ - Or define a default in `fca-config.json`:
440
+
441
+ ```json
442
+ {
443
+ "proxy": "http://user:pass@host:port"
444
+ }
445
+ ```
446
+
447
+ - All HTTP calls go through this proxy using `https-proxy-agent`.
448
+
449
+ - **Broadcast helper** (optional util):
450
+ - Not part of the public API surface on purpose (to avoid encouraging spam).
451
+ - You can use it manually:
452
+
453
+ ```javascript
454
+ const broadcast = require("@sagor/fca-unofficial/src/utils/broadcast");
455
+
456
+ const threads = ["1000...", "2000..."];
457
+ await broadcast(api, threads, { body: "Hello!" }, {
458
+ delayMs: 1200,
459
+ skipBlocked: true
460
+ });
461
+ ```
462
+
463
+ ---
464
+
465
+ ## 📚 Documentation
466
+
467
+ - **[DOCS.md](./DOCS.md)** — Full API reference, examples, and best practices.
468
+ - **[docs/ARCHITECTURE.md](./docs/ARCHITECTURE.md)** — Codebase structure and modules (for contributors).
469
+ - For implementation details, the `src/` folder is the authoritative reference.
470
+
471
+ ---
472
+
473
+ ## 🛠️ Projects Using This API
474
+
475
+ Here are some awesome projects built with `@sagor/fca-unofficial`:
476
+ _(See [GitHub Repository](https://github.com/SAGOR-KINGx/fca-unofficial) for the full list)._
477
+
478
+ ---
479
+
480
+ ## 🤝 Contributing
481
+
482
+ Contributions are welcome! If you want to optimize something or fix a bug:
483
+
484
+ 1. 🍴 Fork the repository
485
+ 2. 🌿 Create a new branch
486
+ 3. 💾 Commit your changes
487
+ 4. 📤 Push to the branch
488
+ 5. 🔄 Open a Pull Request
489
+
490
+ **Rule:** Keep it clean, minimal, and performant. No bloated dependencies.
491
+
492
+ ---
493
+
494
+ ## 📄 License
495
+
496
+ This project is licensed under the **MIT License** - see the [LICENSE-MIT](./LICENSE-MIT) file for details.
497
+
498
+ ---
499
+
500
+ ## 👨‍💻 Author & Support
501
+
502
+ <div align="center">
503
+
504
+ **Maintained by SaGor**
505
+
506
+ </div>
507
+
508
+ ### 🛠️ Need Custom Work?
509
+
510
+ If you have the budget and need specialized features, API reverse-engineering, or private bot development, reach out to me directly via Facebook. **Do not contact me for free coding lessons.**
511
+
512
+ ### 🔗 Links
513
+
514
+ - 📦 [NPM Package](https://www.npmjs.com/package/@sagor/fca-unofficial)
515
+ - 🐙 [GitHub Repository](https://github.com/SAGOR- KINGx/fca-unofficial)
516
+ - 🐛 [Issue Tracker](https://github.com/SAGOR-KINGx/fca-unofficial/issues)
517
+
518
+ ---
519
+
520
+ <div align="center">
521
+
522
+ Made with ❤️ (and a lot of caffeine) for the developer community.
523
+
524
+ </div>