@dongdev/fca-unofficial 2.0.7 → 2.0.10

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 (80) hide show
  1. package/DOCS.md +1699 -1434
  2. package/README.md +250 -168
  3. package/package.json +54 -28
  4. package/src/api/action/addExternalModule.js +5 -5
  5. package/src/api/action/changeAvatar.js +11 -10
  6. package/src/api/action/changeBio.js +7 -8
  7. package/src/api/action/getCurrentUserID.js +1 -1
  8. package/src/api/action/handleFriendRequest.js +5 -5
  9. package/src/api/action/logout.js +9 -8
  10. package/src/api/action/refreshFb_dtsg.js +17 -12
  11. package/src/api/action/setPostReaction.js +10 -11
  12. package/src/api/action/unfriend.js +3 -4
  13. package/src/api/http/httpGet.js +7 -8
  14. package/src/api/http/httpPost.js +7 -8
  15. package/src/api/http/postFormData.js +6 -5
  16. package/src/api/messaging/addUserToGroup.js +0 -1
  17. package/src/api/messaging/changeAdminStatus.js +108 -89
  18. package/src/api/messaging/changeArchivedStatus.js +6 -6
  19. package/src/api/messaging/changeBlockedStatus.js +3 -4
  20. package/src/api/messaging/changeGroupImage.js +72 -117
  21. package/src/api/messaging/changeNickname.js +59 -48
  22. package/src/api/messaging/changeThreadColor.js +61 -47
  23. package/src/api/messaging/changeThreadEmoji.js +106 -0
  24. package/src/api/messaging/createNewGroup.js +5 -5
  25. package/src/api/messaging/createPoll.js +36 -63
  26. package/src/api/messaging/deleteMessage.js +4 -4
  27. package/src/api/messaging/deleteThread.js +4 -4
  28. package/src/api/messaging/forwardAttachment.js +38 -47
  29. package/src/api/messaging/getFriendsList.js +5 -6
  30. package/src/api/messaging/getMessage.js +4 -9
  31. package/src/api/messaging/handleMessageRequest.js +5 -5
  32. package/src/api/messaging/markAsDelivered.js +5 -5
  33. package/src/api/messaging/markAsRead.js +7 -7
  34. package/src/api/messaging/markAsReadAll.js +3 -4
  35. package/src/api/messaging/markAsSeen.js +7 -7
  36. package/src/api/messaging/muteThread.js +3 -4
  37. package/src/api/messaging/removeUserFromGroup.js +82 -56
  38. package/src/api/messaging/resolvePhotoUrl.js +2 -3
  39. package/src/api/messaging/searchForThread.js +2 -3
  40. package/src/api/messaging/sendMessage.js +171 -101
  41. package/src/api/messaging/sendMessageMqtt.js +14 -12
  42. package/src/api/messaging/sendTypingIndicator.js +11 -11
  43. package/src/api/messaging/setMessageReaction.js +68 -82
  44. package/src/api/messaging/setTitle.js +77 -48
  45. package/src/api/messaging/shareContact.js +2 -4
  46. package/src/api/messaging/threadColors.js +0 -3
  47. package/src/api/messaging/unsendMessage.js +74 -37
  48. package/src/api/messaging/uploadAttachment.js +11 -9
  49. package/src/api/socket/core/connectMqtt.js +180 -0
  50. package/src/api/socket/core/getSeqID.js +25 -0
  51. package/src/api/socket/core/getTaskResponseData.js +22 -0
  52. package/src/api/socket/core/markDelivery.js +12 -0
  53. package/src/api/socket/core/parseDelta.js +351 -0
  54. package/src/api/socket/detail/buildStream.js +176 -68
  55. package/src/api/socket/detail/constants.js +24 -0
  56. package/src/api/socket/listenMqtt.js +80 -1005
  57. package/src/api/{messaging → threads}/getThreadHistory.js +5 -22
  58. package/src/api/threads/getThreadInfo.js +35 -248
  59. package/src/api/threads/getThreadList.js +20 -20
  60. package/src/api/threads/getThreadPictures.js +3 -4
  61. package/src/api/users/getUserID.js +5 -6
  62. package/src/api/users/getUserInfo.js +305 -73
  63. package/src/api/users/getUserInfoV2.js +134 -0
  64. package/src/database/models/user.js +32 -0
  65. package/src/database/userData.js +89 -0
  66. package/src/utils/constants.js +12 -2
  67. package/src/utils/format.js +1051 -0
  68. package/src/utils/request.js +75 -7
  69. package/CHANGELOG.md +0 -52
  70. package/LICENSE-MIT +0 -21
  71. package/func/checkUpdate.js +0 -58
  72. package/func/logger.js +0 -112
  73. package/func/login.js +0 -0
  74. package/index.d.ts +0 -618
  75. package/module/config.js +0 -34
  76. package/module/login.js +0 -47
  77. package/module/loginHelper.js +0 -635
  78. package/module/options.js +0 -49
  79. package/src/api/threads/changeThreadEmoji.js +0 -55
  80. package/src/utils/index.js +0 -1497
package/README.md CHANGED
@@ -1,238 +1,320 @@
1
- <div align="center">
1
+ # @dongdev/fca-unofficial
2
2
 
3
- ![20241210_183831](https://files.catbox.moe/4rl0za.webp)
3
+ [![npm version](https://img.shields.io/npm/v/@dongdev/fca-unofficial.svg)](https://www.npmjs.com/package/@dongdev/fca-unofficial)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@dongdev/fca-unofficial.svg)](https://www.npmjs.com/package/@dongdev/fca-unofficial)
4
5
 
5
- <h2 align="center"><b>Unoffcial Facebook Chat API</b></h2><br>This package is created by <b>DongDev</b>
6
+ > **Unofficial Facebook Chat API for Node.js** - Interact with Facebook Messenger programmatically
6
7
 
7
- ![Image](https://files.catbox.moe/8urnyq.png)
8
+ ## ⚠️ Important Disclaimer
8
9
 
9
- _Disclaimer_: We are not responsible if your account gets banned for spammy activities such as sending lots of messages to people you don't know, sending messages very quickly, sending spammy looking URLs, logging in and out very quickly... Be responsible Facebook citizens.
10
+ **We are not responsible if your account gets banned for spammy activities such as:**
11
+ - Sending lots of messages to people you don't know
12
+ - Sending messages very quickly
13
+ - Sending spammy looking URLs
14
+ - Logging in and out very quickly
10
15
 
11
- > We the @dongdev/fca-unofficiala team/contributors are recommending you to use the Firefox app for less logout, or use this website if you have no access on these browsers specially iOS user.
16
+ **Recommendation:** Use Firefox browser or [this website](https://fca.dongdev.id.vn) to reduce logout issues, especially for iOS users.
12
17
 
13
- If you encounter errors on fca, you can contact me [here](https://www.facebook.com/minhdong.dev)
18
+ **Support:** If you encounter errors, contact us [here](https://www.facebook.com/minhdong.dev)
14
19
 
15
- Facebook now has an official API for chat bots [here](https://developers.facebook.com/docs/messenger-platform).
20
+ ## 🔍 Introduction
16
21
 
17
- This API is the only way to automate chat functionalities on a user account. We do this by emulating the browser. This means doing the exact same GET/POST requests and tricking Facebook into thinking we're accessing the website normally. Because we're doing it this way, this API won't work with an auth token but requires the credentials of a Facebook account.
22
+ Facebook now has an [official API for chat bots](https://developers.facebook.com/docs/messenger-platform), however it's only available for Facebook Pages.
18
23
 
19
- ## Install
24
+ `@dongdev/fca-unofficial` is the only API that allows you to automate chat functionalities on a **user account** by emulating the browser. This means:
25
+ - Making the exact same GET/POST requests as a browser
26
+ - Does not work with auth tokens
27
+ - Requires Facebook account credentials (email/password) or AppState
20
28
 
21
- If you just want to use @dongdev/fca-unofficial, you should use this command:
29
+ ## 📦 Installation
22
30
 
23
31
  ```bash
24
32
  npm install @dongdev/fca-unofficial@latest
25
33
  ```
26
34
 
27
- It will download @dongdev/fca-unofficial from NPM repositories
35
+ ## 🚀 Basic Usage
28
36
 
29
- ## Example Usage
37
+ ### 1. Login and Simple Echo Bot
30
38
 
31
39
  ```javascript
32
40
  const login = require("@dongdev/fca-unofficial");
33
41
 
34
42
  login({ appState: [] }, (err, api) => {
35
- if (err) return console.error(err);
36
-
37
- api.listenMqtt((err, event) => {
38
43
  if (err) return console.error(err);
39
44
 
40
- api.sendMessage(event.body, event.threadID);
41
- });
45
+ api.listenMqtt((err, event) => {
46
+ if (err) return console.error(err);
47
+
48
+ // Echo back the received message
49
+ api.sendMessage(event.body, event.threadID);
50
+ });
42
51
  });
43
52
  ```
44
53
 
45
- Result:
46
-
47
- <img width="517" alt="screen shot 2016-11-04 at 14 36 00" src="https://cloud.githubusercontent.com/assets/4534692/20023545/f8c24130-a29d-11e6-9ef7-47568bdbc1f2.png">
48
-
49
- ## Main Functionality
50
-
51
- ### Sending a message
54
+ ### 2. Send Text Message
52
55
 
53
- #### api.sendMessage(message, threadID[, callback][, messageid])
56
+ ```javascript
57
+ const login = require("@dongdev/fca-unofficial");
54
58
 
55
- Various types of message can be sent:
59
+ login({ appState: [] }, (err, api) => {
60
+ if (err) {
61
+ console.error("Login Error:", err);
62
+ return;
63
+ }
56
64
 
57
- - _Regular:_ set field `body` to the desired message as a string.
58
- - _Sticker:_ set a field `sticker` to the desired sticker ID.
59
- - _File or image:_ Set field `attachment` to a readable stream or an array of readable streams.
60
- - _URL:_ set a field `url` to the desired URL.
61
- - _Emoji:_ set field `emoji` to the desired emoji as a string and set field `emojiSize` with size of the emoji (`small`, `medium`, `large`)
65
+ let yourID = "000000000000000"; // Replace with actual Facebook ID
66
+ let msg = "Hey!";
62
67
 
63
- Note that 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.
68
+ api.sendMessage(msg, yourID, err => {
69
+ if (err) console.error("Message Sending Error:", err);
70
+ else console.log("Message sent successfully!");
71
+ });
72
+ });
73
+ ```
64
74
 
65
- **Tip**: to find your own ID, you can look inside the cookies. The `userID` is under the name `c_user`.
75
+ **Tip:** To find your Facebook ID, look inside the cookies under the name `c_user`
66
76
 
67
- **Example (Basic Message)**
77
+ ### 3. Send File/Image
68
78
 
69
- ```js
79
+ ```javascript
70
80
  const login = require("@dongdev/fca-unofficial");
81
+ const fs = require("fs");
71
82
 
72
83
  login({ appState: [] }, (err, api) => {
73
- if (err) {
74
- console.error("Login Error:", err);
75
- return;
76
- }
77
-
78
- let yourID = "000000000000000"; // Replace with actual Facebook ID
79
- let msg = "Hey!";
80
-
81
- api.sendMessage(msg, yourID, err => {
82
- if (err) console.error("Message Sending Error:", err);
83
- else console.log("Message sent successfully!");
84
- });
85
- });
86
- ```
84
+ if (err) {
85
+ console.error("Login Error:", err);
86
+ return;
87
+ }
87
88
 
88
- **Example (File upload)**
89
+ let yourID = "000000000000000";
90
+ let imagePath = __dirname + "/image.jpg";
89
91
 
90
- ```js
91
- const login = require("@dongdev/fca-unofficial");
92
- const fs = require("fs"); // ✅ Required the fs module
92
+ // Check if file exists
93
+ if (!fs.existsSync(imagePath)) {
94
+ console.error("Error: Image file not found!");
95
+ return;
96
+ }
93
97
 
94
- login({ appState: [] }, (err, api) => {
95
- if (err) {
96
- console.error("Login Error:", err);
97
- return;
98
- }
99
-
100
- let yourID = "000000000000000"; // Replace with actual Facebook ID
101
- let imagePath = __dirname + "/image.jpg";
102
-
103
- // Check if the file exists before sending
104
- if (!fs.existsSync(imagePath)) {
105
- console.error("Error: Image file not found!");
106
- return;
107
- }
108
-
109
- let msg = {
110
- body: "Hey!",
111
- attachment: fs.createReadStream(imagePath)
112
- };
113
-
114
- api.sendMessage(msg, yourID, err => {
115
- if (err) console.error("Message Sending Error:", err);
116
- else console.log("Message sent successfully!");
117
- });
98
+ let msg = {
99
+ body: "Hey!",
100
+ attachment: fs.createReadStream(imagePath)
101
+ };
102
+
103
+ api.sendMessage(msg, yourID, err => {
104
+ if (err) console.error("Message Sending Error:", err);
105
+ else console.log("Message sent successfully!");
106
+ });
118
107
  });
119
108
  ```
120
109
 
121
- ---
110
+ ## 📝 Message Types
111
+
112
+ | Type | Usage |
113
+ | ---------------- | --------------------------------------------------------------- |
114
+ | **Regular text** | `{ body: "message text" }` |
115
+ | **Sticker** | `{ sticker: "sticker_id" }` |
116
+ | **File/Image** | `{ attachment: fs.createReadStream(path) }` or array of streams |
117
+ | **URL** | `{ url: "https://example.com" }` |
118
+ | **Large emoji** | `{ emoji: "👍", emojiSize: "large" }` (small/medium/large) |
122
119
 
123
- ### Saving session.
120
+ **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.
124
121
 
125
- To avoid logging in every time you should save AppState (cookies etc.) to a file, then you can use it without having password in your scripts.
122
+ ## 💾 Saving AppState to Avoid Re-login
126
123
 
127
- **Example**
124
+ ### Save AppState
128
125
 
129
- ```js
126
+ ```javascript
130
127
  const fs = require("fs");
131
128
  const login = require("@dongdev/fca-unofficial");
132
129
 
133
130
  const credentials = { appState: [] };
134
131
 
135
132
  login(credentials, (err, api) => {
136
- if (err) {
137
- console.error("Login Error:", err);
138
- return;
139
- }
140
-
141
- try {
142
- const appState = JSON.stringify(api.getAppState(), null, 2); // Pretty print for readability
143
- fs.writeFileSync("appstate.json", appState);
144
- console.log("✅ AppState saved successfully!");
145
- } catch (error) {
146
- console.error("Error saving AppState:", error);
147
- }
133
+ if (err) {
134
+ console.error("Login Error:", err);
135
+ return;
136
+ }
137
+
138
+ try {
139
+ const appState = JSON.stringify(api.getAppState(), null, 2);
140
+ fs.writeFileSync("appstate.json", appState);
141
+ console.log("✅ AppState saved successfully!");
142
+ } catch (error) {
143
+ console.error("Error saving AppState:", error);
144
+ }
148
145
  });
149
146
  ```
150
147
 
151
- Alternative: Use [c3c-fbstate](https://github.com/c3cbot/c3c-fbstate) to get fbstate.json (appstate.json)
148
+ ### Use Saved AppState
152
149
 
153
- ---
150
+ ```javascript
151
+ const fs = require("fs");
152
+ const login = require("@dongdev/fca-unofficial");
154
153
 
155
- ### Listening to a chat
154
+ login(
155
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
156
+ (err, api) => {
157
+ if (err) {
158
+ console.error("Login Error:", err);
159
+ return;
160
+ }
156
161
 
157
- #### api.listenMqtt(callback)
162
+ console.log("✅ Logged in successfully!");
163
+ // Your code here
164
+ }
165
+ );
166
+ ```
167
+
168
+ **Alternative:** Use [c3c-fbstate](https://github.com/c3cbot/c3c-fbstate) to get fbstate.json
158
169
 
159
- Listen watches for messages sent in a chat. By default this won't receive events (joining/leaving a chat, title change etc…) but it can be activated with `api.setOptions({listenEvents: true})`. This will by default ignore messages sent by the current account, you can enable listening to your own messages with `api.setOptions({selfListen: true})`.
170
+ ## 👂 Listening for Messages
160
171
 
161
- **Example**
172
+ ### Echo Bot with Stop Command
162
173
 
163
- ```js
174
+ ```javascript
164
175
  const fs = require("fs");
165
176
  const login = require("@dongdev/fca-unofficial");
166
177
 
167
- // Simple echo bot: Repeats everything you say. Stops when you say "/stop".
168
178
  login(
169
- { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
170
- (err, api) => {
171
- if (err) {
172
- console.error("Login Error:", err);
173
- return;
179
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
180
+ (err, api) => {
181
+ if (err) {
182
+ console.error("Login Error:", err);
183
+ return;
184
+ }
185
+
186
+ // Enable listening to events (join/leave, title change, etc.)
187
+ api.setOptions({ listenEvents: true });
188
+
189
+ const stopListening = api.listenMqtt((err, event) => {
190
+ if (err) {
191
+ console.error("Listen Error:", err);
192
+ return;
193
+ }
194
+
195
+ // Mark as read
196
+ api.markAsRead(event.threadID, err => {
197
+ if (err) console.error("Mark as read error:", err);
198
+ });
199
+
200
+ // Handle different event types
201
+ switch (event.type) {
202
+ case "message":
203
+ if (event.body && event.body.trim().toLowerCase() === "/stop") {
204
+ api.sendMessage("Goodbye…", event.threadID);
205
+ stopListening();
206
+ return;
207
+ }
208
+ api.sendMessage(`TEST BOT: ${event.body}`, event.threadID);
209
+ break;
210
+
211
+ case "event":
212
+ console.log("Event Received:", event);
213
+ break;
214
+ }
215
+ });
174
216
  }
217
+ );
218
+ ```
175
219
 
176
- api.setOptions({ listenEvents: true });
220
+ ### Listen Options
177
221
 
178
- const stopListening = api.listenMqtt((err, event) => {
179
- if (err) {
180
- console.error("Listen Error:", err);
181
- return;
182
- }
183
-
184
- // Mark message as read
185
- api.markAsRead(event.threadID, err => {
186
- if (err) console.error("Mark as read error:", err);
187
- });
188
-
189
- // Handle different event types
190
- switch (event.type) {
191
- case "message":
192
- if (event.body && event.body.trim().toLowerCase() === "/stop") {
193
- api.sendMessage("Goodbye…", event.threadID);
194
- stopListening();
195
- return;
196
- }
197
- api.sendMessage(`TEST BOT: ${event.body}`, event.threadID);
198
- break;
199
-
200
- case "event":
201
- console.log("Event Received:", event);
202
- break;
203
- }
204
- });
205
- }
206
- );
222
+ ```javascript
223
+ api.setOptions({
224
+ listenEvents: true, // Receive events (join/leave, rename, etc.)
225
+ selfListen: true, // Receive messages from yourself
226
+ logLevel: "silent" // Disable logs (silent/error/warn/info/verbose)
227
+ });
207
228
  ```
208
229
 
209
- `<a name="projects-using-this-api"></a>`
210
-
211
- ## Projects using this API:
212
-
213
- - [c3c](https://github.com/lequanglam/c3c) - A bot that can be customizable using plugins. Support Facebook & Discord.
214
- - [Miraiv2](https://github.com/miraiPr0ject/miraiv2) - A simple Facebook Messenger Bot made by CatalizCS and SpermLord.
215
-
216
- ## Projects using this API (original repository, facebook-chat-api):
217
-
218
- - [Messer](https://github.com/mjkaufer/Messer) - Command-line messaging for Facebook Messenger
219
- - [messen](https://github.com/tomquirk/messen) - Rapidly build Facebook Messenger apps in Node.js
220
- - [Concierge](https://github.com/concierge/Concierge) - Concierge is a highly modular, easily extensible general purpose chat bot with a built in package manager
221
- - [Marc Zuckerbot](https://github.com/bsansouci/marc-zuckerbot) - Facebook chat bot
222
- - [Marc Thuckerbot](https://github.com/bsansouci/lisp-bot) - Programmable lisp bot
223
- - [MarkovsInequality](https://github.com/logicx24/MarkovsInequality) - Extensible chat bot adding useful functions to Facebook Messenger
224
- - [AllanBot](https://github.com/AllanWang/AllanBot-Public) - Extensive module that combines the facebook api with firebase to create numerous functions; no coding experience is required to implement this.
225
- - [Larry Pudding Dog Bot](https://github.com/Larry850806/facebook-chat-bot) - A facebook bot you can easily customize the response
226
- - [fbash](https://github.com/avikj/fbash) - Run commands on your computer's terminal over Facebook Messenger
227
- - [Klink](https://github.com/KeNt178/klink) - This Chrome extension will 1-click share the link of your active tab over Facebook Messenger
228
- - [Botyo](https://github.com/ivkos/botyo) - Modular bot designed for group chat rooms on Facebook
229
- - [matrix-puppet-facebook](https://github.com/matrix-hacks/matrix-puppet-facebook) - A facebook bridge for [matrix](https://matrix.org)
230
- - [facebot](https://github.com/Weetbix/facebot) - A facebook bridge for Slack.
231
- - [Botium](https://github.com/codeforequity-at/botium-core) - The Selenium for Chatbots
232
- - [Messenger-CLI](https://github.com/AstroCB/Messenger-CLI) - A command-line interface for sending and receiving messages through Facebook Messenger.
233
- - [AssumeZero-Bot](https://github.com/AstroCB/AssumeZero-Bot) A highly customizable Facebook Messenger bot for group chats.
234
- - [Miscord](https://github.com/Bjornskjald/miscord) - An easy-to-use Facebook bridge for Discord.
235
- - [chat-bridge](https://github.com/rexx0520/chat-bridge) - A Messenger, Telegram and IRC chat bridge.
236
- - [messenger-auto-reply](https://gitlab.com/theSander/messenger-auto-reply) - An auto-reply service for Messenger.
237
- - [BotCore](https://github.com/AstroCB/BotCore) – A collection of tools for writing and managing Facebook Messenger bots.
238
- - [mnotify](https://github.com/AstroCB/mnotify) A command-line utility for sending alerts and notifications through Facebook Messenger.
230
+ **By default:**
231
+ - `listenEvents` is `false` - won't receive events like joining/leaving chat, title changes
232
+ - `selfListen` is `false` - will ignore messages sent by the current account
233
+
234
+ ## 🛠️ Projects Using This API
235
+
236
+ - **[c3c](https://github.com/lequanglam/c3c)** - Customizable bot with plugins, supports Facebook & Discord
237
+ - **[Miraiv2](https://github.com/miraiPr0ject/miraiv2)** - Simple Facebook Messenger Bot
238
+ - **[Messer](https://github.com/mjkaufer/Messer)** - Command-line messaging for Facebook Messenger
239
+ - **[messen](https://github.com/tomquirk/messen)** - Rapidly build Facebook Messenger apps in Node.js
240
+ - **[Concierge](https://github.com/concierge/Concierge)** - Highly modular chat bot with built-in package manager
241
+ - **[Marc Zuckerbot](https://github.com/bsansouci/marc-zuckerbot)** - Facebook chat bot
242
+ - **[Botyo](https://github.com/ivkos/botyo)** - Modular bot for group chat rooms
243
+ - **[matrix-puppet-facebook](https://github.com/matrix-hacks/matrix-puppet-facebook)** - Facebook bridge for Matrix
244
+ - **[Miscord](https://github.com/Bjornskjald/miscord)** - Easy-to-use Facebook bridge for Discord
245
+ - **[chat-bridge](https://github.com/rexx0520/chat-bridge)** - Messenger, Telegram and IRC chat bridge
246
+ - **[Botium](https://github.com/codeforequity-at/botium-core)** - The Selenium for Chatbots
247
+ - **[Messenger-CLI](https://github.com/AstroCB/Messenger-CLI)** - Command-line interface for Facebook Messenger
248
+ - **[BotCore](https://github.com/AstroCB/BotCore)** - Tools for writing and managing Facebook Messenger bots
249
+
250
+ [See more projects...](https://github.com/Donix-VN/fca-unofficial#projects-using-this-api)
251
+
252
+ ## 📚 Full API Documentation
253
+
254
+ See [DOCS.md](./DOCS.md) for detailed information about:
255
+ - All available API methods
256
+ - Parameters and options
257
+ - Event types
258
+ - Error handling
259
+ - Advanced usage examples
260
+
261
+ ## 🎯 Quick Reference
262
+
263
+ ### Common API Methods
264
+
265
+ ```javascript
266
+ // Send message
267
+ api.sendMessage(message, threadID, callback);
268
+
269
+ // Send typing indicator
270
+ api.sendTypingIndicator(threadID, callback);
271
+
272
+ // Mark as read
273
+ api.markAsRead(threadID, callback);
274
+
275
+ // Get user info
276
+ api.getUserInfo(userID, callback);
277
+
278
+ // Get thread info
279
+ api.getThreadInfo(threadID, callback);
280
+
281
+ // Change thread color
282
+ api.changeThreadColor(color, threadID, callback);
283
+
284
+ // Change thread emoji
285
+ api.changeThreadEmoji(emoji, threadID, callback);
286
+
287
+ // Set message reaction
288
+ api.setMessageReaction(reaction, messageID, callback);
289
+ ```
290
+
291
+ ## 🤝 Contributing
292
+
293
+ Contributions are welcome! Please:
294
+ 1. Fork the repository
295
+ 2. Create a new branch (`git checkout -b feature/AmazingFeature`)
296
+ 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
297
+ 4. Push to the branch (`git push origin feature/AmazingFeature`)
298
+ 5. Open a Pull Request
299
+
300
+ ## 📄 License
301
+
302
+ MIT License - See [LICENSE](./LICENSE) for details.
303
+
304
+ ## 👨‍💻 Author
305
+
306
+ **DongDev** - [Facebook](https://www.facebook.com/mdong.dev)
307
+
308
+ ## ⭐ Support
309
+
310
+ If this project is helpful, please give it a ⭐ on GitHub!
311
+
312
+ ## 🔗 Links
313
+
314
+ - [NPM Package](https://www.npmjs.com/package/@dongdev/fca-unofficial)
315
+ - [GitHub Repository](https://github.com/Donix-VN/fca-unofficial)
316
+ - [Issue Tracker](https://github.com/Donix-VN/fca-unofficial/issues)
317
+
318
+ ---
319
+
320
+ **Disclaimer:** This is an unofficial API and is not officially supported by Facebook. Use responsibly and comply with [Facebook Terms of Service](https://www.facebook.com/terms.php).
package/package.json CHANGED
@@ -1,16 +1,52 @@
1
1
  {
2
2
  "name": "@dongdev/fca-unofficial",
3
- "version": "2.0.7",
4
- "description": "A Facebook chat API without XMPP, will not be deprecated after April 30th, 2015.",
3
+ "version": "2.0.10",
4
+ "description": "Unofficial Facebook Chat API for Node.js - Interact with Facebook Messenger programmatically",
5
5
  "main": "index.js",
6
+ "scripts": {
7
+ "test": "mocha",
8
+ "lint": "eslint .",
9
+ "prepublishOnly": "npm test"
10
+ },
6
11
  "repository": {
7
12
  "type": "git",
8
13
  "url": "git+https://github.com/Donix-VN/fca-unofficial.git"
9
14
  },
10
- "author": "Avery, David, Maude, Benjamin, UIRI, DongDev, LunarKrystal",
15
+ "keywords": [
16
+ "facebook",
17
+ "chat",
18
+ "api",
19
+ "messenger",
20
+ "bot",
21
+ "unofficial",
22
+ "automation",
23
+ "facebook-api",
24
+ "facebook-chat",
25
+ "facebook-messenger",
26
+ "chatbot",
27
+ "nodejs",
28
+ "fca"
29
+ ],
30
+ "author": {
31
+ "name": "DongDev",
32
+ "url": "https://www.facebook.com/mdong.dev"
33
+ },
34
+ "contributors": [
35
+ {
36
+ "name": "DongDev",
37
+ "url": "https://github.com/Donix-VN"
38
+ }
39
+ ],
11
40
  "license": "MIT",
41
+ "bugs": {
42
+ "url": "https://github.com/Donix-VN/fca-unofficial/issues"
43
+ },
44
+ "homepage": "https://github.com/Donix-VN/fca-unofficial#readme",
45
+ "engines": {
46
+ "node": ">=12.0.0"
47
+ },
12
48
  "dependencies": {
13
- "axios": "^1.12.2",
49
+ "axios": "latest",
14
50
  "axios-cookiejar-support": "^5.0.5",
15
51
  "bluebird": "^3.7.2",
16
52
  "chalk": "^4.1.2",
@@ -27,31 +63,21 @@
27
63
  "ws": "^8.18.1"
28
64
  },
29
65
  "devDependencies": {
30
- "eslint": "^7.5.0",
31
- "mocha": "^10.2.0",
32
- "prettier": "^3.3.3"
33
- },
34
- "scripts": {
35
- "test": "mocha",
36
- "lint": "eslint . --ext .js,.cjs,.mjs,.ts,.tsx",
37
- "prettier": "prettier \"**/*.{js,cjs,mjs,ts,tsx,json,md,css,scss,html,yml,yaml}\" --ignore-unknown --write"
66
+ "eslint": "^8.50.0",
67
+ "mocha": "^10.2.0"
38
68
  },
39
- "keywords": [
40
- "facebook",
41
- "chat",
42
- "api",
43
- "fca",
44
- "facebook-chat-api"
69
+ "optionalDependencies": {},
70
+ "peerDependencies": {},
71
+ "files": [
72
+ "index.js",
73
+ "src/",
74
+ "utils/",
75
+ "README.md",
76
+ "LICENSE",
77
+ "DOCS.md"
45
78
  ],
46
- "engines": {
47
- "node": ">=10.x"
48
- },
49
- "types": "index.d.ts",
50
- "homepage": "https://github.com/DongDev-VN/fca-unofficial#readme",
51
- "bugs": {
52
- "url": "https://github.com/DongDev-VN/fca-unofficial/issues"
53
- },
54
- "directories": {
55
- "test": "test"
79
+ "publishConfig": {
80
+ "access": "public",
81
+ "registry": "https://registry.npmjs.org/"
56
82
  }
57
83
  }
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
 
3
- const utils = require("../../utils");
3
+ const { getType } = require("../../utils/format");
4
4
 
5
5
  module.exports = function(defaultFuncs, api, ctx) {
6
6
  return function addExternalModule(moduleObj) {
7
- if (utils.getType(moduleObj) == "Object") {
7
+ if (getType(moduleObj) == "Object") {
8
8
  for (const apiName in moduleObj) {
9
- if (utils.getType(moduleObj[apiName]) == "Function") {
9
+ if (getType(moduleObj[apiName]) == "Function") {
10
10
  api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
11
11
  } else {
12
12
  throw new Error(
13
- `Item "${apiName}" in moduleObj must be a function, not ${utils.getType(
13
+ `Item "${apiName}" in moduleObj must be a function, not ${getType(
14
14
  moduleObj[apiName]
15
15
  )}!`
16
16
  );
@@ -18,7 +18,7 @@ module.exports = function(defaultFuncs, api, ctx) {
18
18
  }
19
19
  } else {
20
20
  throw new Error(
21
- `moduleObj must be an object, not ${utils.getType(moduleObj)}!`
21
+ `moduleObj must be an object, not ${getType(moduleObj)}!`
22
22
  );
23
23
  }
24
24
  };