fca-priyansh 21.0.0 → 22.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/.gitlab-ci.yml +22 -22
- package/CountTime.json +1 -1
- package/DOCS.md +637 -0
- package/Extra/Balancer.js +49 -49
- package/Extra/Bypass/956/index.js +233 -233
- package/Extra/Bypass/test/aaaa.json +169 -169
- package/Extra/Bypass/test/index.js +187 -187
- package/Extra/Database/index.js +375 -469
- package/Extra/ExtraAddons.js +82 -82
- package/Extra/ExtraFindUID.js +61 -61
- package/Extra/ExtraGetThread.js +365 -365
- package/Extra/ExtraScreenShot.js +430 -430
- package/Extra/ExtraUptimeRobot.js +142 -142
- package/Extra/Html/Classic/script.js +118 -118
- package/Extra/Html/Classic/style.css +7 -7
- package/Extra/Security/Base/Step_1.js +5 -5
- package/Extra/Security/Base/Step_2.js +22 -22
- package/Extra/Security/Base/Step_3.js +22 -22
- package/Extra/Security/Base/index.js +190 -190
- package/Extra/Security/Index.js +4 -4
- package/Extra/Security/Step_1.js +5 -5
- package/Extra/Security/Step_2.js +22 -22
- package/Extra/Security/Step_3.js +22 -22
- package/Extra/Src/Change_Environment.js +24 -24
- package/Extra/Src/Check_Update.js +66 -66
- package/Extra/Src/History.js +114 -114
- package/Extra/Src/Instant_Update.js +64 -64
- package/Extra/Src/Last-Run.js +64 -64
- package/Extra/Src/Premium.js +81 -81
- package/Extra/Src/Websocket.js +212 -212
- package/Extra/Src/uuid.js +137 -137
- package/Func/AcceptAgreement.js +31 -31
- package/Func/ClearCache.js +64 -64
- package/Func/ReportV1.js +54 -54
- package/LICENSE +21 -21
- package/Language/index.json +228 -228
- package/README.md +439 -198
- package/broadcast.json +3 -0
- package/errorHandler.js +151 -151
- package/logger.js +69 -69
- package/package.json +11 -9
- package/src/Dev_Horizon_Data.js +124 -124
- package/src/Dev_getThreadInfoOLD.js +421 -421
- package/src/Dev_shareTest2.js +68 -68
- package/src/Dev_shareTest3.js +71 -71
- package/src/Premium.js +24 -24
- package/src/Screenshot.js +82 -82
- package/src/addExternalModule.js +16 -16
- package/src/addUserToGroup.js +79 -79
- package/src/changeAdminStatus.js +79 -79
- package/src/changeArchivedStatus.js +41 -41
- package/src/changeAvt.js +84 -84
- package/src/changeBio.js +65 -65
- package/src/changeBlockedStatus.js +36 -36
- package/src/changeGroupImage.js +106 -106
- package/src/changeNickname.js +45 -45
- package/src/changeThreadColor.js +62 -62
- package/src/changeThreadEmoji.js +42 -42
- package/src/changeThreadTheme.js +268 -263
- package/src/comment.js +244 -244
- package/src/createNewGroup.js +70 -70
- package/src/createPoll.js +60 -60
- package/src/deleteMessage.js +45 -45
- package/src/deleteThread.js +43 -43
- package/src/editMessage.js +70 -70
- package/src/follow.js +119 -119
- package/src/forwardAttachment.js +48 -48
- package/src/friend.js +383 -383
- package/src/generateAiTheme.js +1 -0
- package/src/getAccessToken.js +27 -27
- package/src/getCurrentUserID.js +7 -7
- package/src/getEmojiUrl.js +27 -27
- package/src/getFriendsList.js +73 -73
- package/src/getMessage.js +102 -102
- package/src/getPendingFriendRequests.js +45 -45
- package/src/getThreadHistory.js +537 -537
- package/src/getThreadInfo.js +424 -424
- package/src/getThreadInfoOLD.js +421 -421
- package/src/getThreadList.js +213 -213
- package/src/getThreadMain.js +219 -219
- package/src/getThreadPictures.js +59 -59
- package/src/getUID.js +58 -58
- package/src/getUserID.js +62 -62
- package/src/getUserInfo.js +112 -112
- package/src/getUserInfoMain.js +64 -64
- package/src/getUserInfoV2.js +31 -31
- package/src/getUserInfoV3.js +62 -62
- package/src/getUserInfoV4.js +54 -54
- package/src/getUserInfoV5.js +60 -60
- package/src/handleFriendRequest.js +46 -46
- package/src/handleMessageRequest.js +49 -49
- package/src/httpGet.js +49 -49
- package/src/httpPost.js +48 -48
- package/src/httpPostFormData.js +40 -40
- package/src/listenMqttV1.js +832 -832
- package/src/logout.js +68 -68
- package/src/markAsDelivered.js +48 -48
- package/src/markAsRead.js +70 -70
- package/src/markAsReadAll.js +42 -42
- package/src/markAsSeen.js +51 -51
- package/src/muteThread.js +47 -47
- package/src/notes.js +279 -279
- package/src/removeUserFromGroup.js +49 -49
- package/src/resolvePhotoUrl.js +37 -37
- package/src/searchForThread.js +43 -43
- package/src/sendMention.js +325 -325
- package/src/sendMqttMessage.js +70 -70
- package/src/sendTypingIndicator.js +79 -79
- package/src/setMessageReaction.js +109 -109
- package/src/setPostReaction.js +101 -101
- package/src/setTitle.js +74 -74
- package/src/share.js +98 -98
- package/src/shareContact.js +55 -55
- package/src/shareLink.js +58 -58
- package/src/stickers.js +525 -525
- package/src/story.js +267 -267
- package/src/threadColors.js +38 -38
- package/src/unfriend.js +43 -43
- package/src/unsendMessage.js +47 -47
- package/src/unsendMqttMessage.js +65 -65
- package/test/data/shareAttach.js +146 -146
- package/test/data/test.txt +7 -7
- package/test/example-config.json +18 -18
- package/test/test-page.js +140 -140
- package/test/test.js +385 -385
- package/test/testv2.js +2 -2
- package/userAgentManager.js +129 -129
package/.gitlab-ci.yml
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
image: node:
|
|
2
|
-
|
|
3
|
-
stages:
|
|
4
|
-
- publish
|
|
5
|
-
|
|
6
|
-
publish_npm:
|
|
7
|
-
stage: publish
|
|
8
|
-
script:
|
|
9
|
-
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
|
|
10
|
-
- npm install
|
|
11
|
-
- |
|
|
12
|
-
CURRENT=$(node -p "require('./package.json').version")
|
|
13
|
-
PUBLISHED=$(npm view $(node -p "require('./package.json').name") version || echo "0")
|
|
14
|
-
|
|
15
|
-
if [ "$CURRENT" = "$PUBLISHED" ]; then
|
|
16
|
-
echo "Version unchanged. Skipping publish."
|
|
17
|
-
else
|
|
18
|
-
echo "Publishing version $CURRENT..."
|
|
19
|
-
npm publish --access public
|
|
20
|
-
fi
|
|
21
|
-
only:
|
|
22
|
-
- main
|
|
1
|
+
image: node:20
|
|
2
|
+
|
|
3
|
+
stages:
|
|
4
|
+
- publish
|
|
5
|
+
|
|
6
|
+
publish_npm:
|
|
7
|
+
stage: publish
|
|
8
|
+
script:
|
|
9
|
+
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
|
|
10
|
+
- npm install
|
|
11
|
+
- |
|
|
12
|
+
CURRENT=$(node -p "require('./package.json').version")
|
|
13
|
+
PUBLISHED=$(npm view $(node -p "require('./package.json').name") version || echo "0")
|
|
14
|
+
|
|
15
|
+
if [ "$CURRENT" = "$PUBLISHED" ]; then
|
|
16
|
+
echo "Version unchanged. Skipping publish."
|
|
17
|
+
else
|
|
18
|
+
echo "Publishing version $CURRENT..."
|
|
19
|
+
npm publish --access public
|
|
20
|
+
fi
|
|
21
|
+
only:
|
|
22
|
+
- main
|
package/CountTime.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
617016.3788941329
|
package/DOCS.md
ADDED
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
# 📚 FCA-Priyansh Complete Documentation
|
|
2
|
+
|
|
3
|
+
**Comprehensive guides for Facebook Chat API (FCA) development**
|
|
4
|
+
|
|
5
|
+
**Maintained by:** [Priyanshu Rajput](https://priyanshuapi.xyz) | **GitHub:** [@priyanshfsdev](https://github.com/priyanshfsdev) | **GitLab:** [@priyanshufsdev](https://gitlab.com/priyanshufsdev) | **Instagram:** [@pri_yanshu12](https://instagram.com/pri_yanshu12) | **Telegram:** [@Priyanshrajput](https://t.me/Priyanshrajput)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 📖 Table of Contents
|
|
10
|
+
|
|
11
|
+
1. [Getting Started Guide](#getting-started)
|
|
12
|
+
2. [Authentication & Login](#authentication)
|
|
13
|
+
3. [API Reference](#api-reference)
|
|
14
|
+
4. [Message Types & Features](#message-features)
|
|
15
|
+
5. [Event Handling](#event-handling)
|
|
16
|
+
6. [Advanced Topics](#advanced-topics)
|
|
17
|
+
7. [Troubleshooting](#troubleshooting)
|
|
18
|
+
8. [Best Practices](#best-practices)
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 🚀 Getting Started with FCA
|
|
23
|
+
|
|
24
|
+
### What is FCA-Priyansh?
|
|
25
|
+
|
|
26
|
+
**FCA (Facebook Chat API)** is a powerful Node.js library that allows you to:
|
|
27
|
+
- 🤖 Create automated Facebook Messenger bots
|
|
28
|
+
- 💬 Send and receive messages programmatically
|
|
29
|
+
- 📱 Build real-time chat applications
|
|
30
|
+
- 🔔 Implement notification systems
|
|
31
|
+
- 👥 Manage group conversations
|
|
32
|
+
- 📊 Monitor and log messages
|
|
33
|
+
|
|
34
|
+
FCA-Priyansh is the community-maintained fork with:
|
|
35
|
+
- ⚡ Faster feature updates
|
|
36
|
+
- 🐛 Active bug fixes
|
|
37
|
+
- 📈 Enhanced functionality
|
|
38
|
+
- 👥 Community support
|
|
39
|
+
|
|
40
|
+
### Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# From NPM (Recommended for production)
|
|
44
|
+
npm install fca-priyansh
|
|
45
|
+
|
|
46
|
+
# From GitLab (Latest development features)
|
|
47
|
+
npm install https://gitlab.com/priyanshufsdev/fca-priyansh.git
|
|
48
|
+
|
|
49
|
+
# From GitHub Mirror
|
|
50
|
+
npm install https://github.com/priyanshfsdev/fca-priyansh.git
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Minimum Requirements
|
|
54
|
+
|
|
55
|
+
- **Node.js:** 12.0 or higher (LTS recommended)
|
|
56
|
+
- **Operating System:** Windows, macOS, Linux
|
|
57
|
+
- **Internet:** Stable connection
|
|
58
|
+
- **Facebook Account:** For authentication
|
|
59
|
+
- **Basic JavaScript Knowledge:** For implementation
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 🔐 Authentication & Login Guide
|
|
64
|
+
|
|
65
|
+
### Method 1: Email & Password Login
|
|
66
|
+
|
|
67
|
+
**⚠️ Warning:** Storing passwords in code is NOT SAFE. Use AppState caching instead.
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
const login = require("fca-priyansh");
|
|
71
|
+
|
|
72
|
+
login({
|
|
73
|
+
email: "your@email.com",
|
|
74
|
+
password: "your_password"
|
|
75
|
+
}, (err, api) => {
|
|
76
|
+
if(err) return console.error(err);
|
|
77
|
+
console.log("✅ Logged in successfully!");
|
|
78
|
+
|
|
79
|
+
// Your bot code here
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Method 2: AppState Session Caching (RECOMMENDED)
|
|
84
|
+
|
|
85
|
+
#### Step 1: Generate and Save AppState
|
|
86
|
+
|
|
87
|
+
```javascript
|
|
88
|
+
const fs = require("fs");
|
|
89
|
+
const login = require("fca-priyansh");
|
|
90
|
+
|
|
91
|
+
var credentials = {
|
|
92
|
+
email: "your@email.com",
|
|
93
|
+
password: "your_password"
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
login(credentials, (err, api) => {
|
|
97
|
+
if(err) return console.error(err);
|
|
98
|
+
|
|
99
|
+
// Save the session
|
|
100
|
+
var appState = api.getAppState();
|
|
101
|
+
fs.writeFileSync('appstate.json', JSON.stringify(appState));
|
|
102
|
+
console.log("✅ AppState saved! You can now use it for future logins.");
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
#### Step 2: Use Saved AppState (No Password Needed)
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
const fs = require("fs");
|
|
110
|
+
const login = require("fca-priyansh");
|
|
111
|
+
|
|
112
|
+
var appState = JSON.parse(fs.readFileSync('appstate.json', 'utf8'));
|
|
113
|
+
|
|
114
|
+
login({appState: appState}, (err, api) => {
|
|
115
|
+
if(err) return console.error(err);
|
|
116
|
+
console.log("✅ Logged in using saved session!");
|
|
117
|
+
|
|
118
|
+
// Your bot code here
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Login Options
|
|
123
|
+
|
|
124
|
+
```javascript
|
|
125
|
+
login(credentials, {
|
|
126
|
+
pageID: "123456789", // Login as a Facebook page
|
|
127
|
+
selfListen: true, // Receive your own messages
|
|
128
|
+
listenEvents: true, // Receive group events
|
|
129
|
+
updatePresence: true, // Show online status
|
|
130
|
+
forceLogin: false, // Force new login if session invalid
|
|
131
|
+
}, callback);
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Handling 2FA (Two-Factor Authentication)
|
|
135
|
+
|
|
136
|
+
```javascript
|
|
137
|
+
login({
|
|
138
|
+
email: "your@email.com",
|
|
139
|
+
password: "your_password",
|
|
140
|
+
twoFactorNumber: "123456" // Your 2FA code from authenticator app
|
|
141
|
+
}, (err, api) => {
|
|
142
|
+
if(err) return console.error(err);
|
|
143
|
+
// Logged in successfully
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## 🎯 Core API Reference
|
|
150
|
+
|
|
151
|
+
### Message Operations
|
|
152
|
+
|
|
153
|
+
#### **api.sendMessage(message, threadID, [callback], [messageID])**
|
|
154
|
+
|
|
155
|
+
Send messages to individuals or groups.
|
|
156
|
+
|
|
157
|
+
**Parameters:**
|
|
158
|
+
- `message` (Object|String) - Message content object or text string
|
|
159
|
+
- `threadID` (String) - Target user or group ID
|
|
160
|
+
- `callback` (Function) - Optional callback for response
|
|
161
|
+
- `messageID` (String) - Optional message ID for replies
|
|
162
|
+
|
|
163
|
+
**Message Object Structure:**
|
|
164
|
+
```javascript
|
|
165
|
+
{
|
|
166
|
+
body: "Text message", // Text content
|
|
167
|
+
attachment: fs.createReadStream('image.jpg'), // Single or array of files
|
|
168
|
+
sticker: "STICKER_ID", // Sticker ID
|
|
169
|
+
url: "https://example.com", // Link to share
|
|
170
|
+
emoji: "😀", // Emoji to react
|
|
171
|
+
emojiSize: "large", // Emoji size: small/medium/large
|
|
172
|
+
mentions: [{tag: "@name", id: "USER_ID"}] // Mention users
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Example: Send Text Message**
|
|
177
|
+
```javascript
|
|
178
|
+
api.sendMessage("Hello! This is an automated message.", "USER_ID", (err) => {
|
|
179
|
+
if(err) console.error("Failed to send message:", err);
|
|
180
|
+
else console.log("✅ Message sent!");
|
|
181
|
+
});
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Example: Send Image**
|
|
185
|
+
```javascript
|
|
186
|
+
api.sendMessage({
|
|
187
|
+
body: "Check out this image!",
|
|
188
|
+
attachment: fs.createReadStream('photo.jpg')
|
|
189
|
+
}, "USER_ID");
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Example: Send Multiple Attachments**
|
|
193
|
+
```javascript
|
|
194
|
+
api.sendMessage({
|
|
195
|
+
body: "Here are some files:",
|
|
196
|
+
attachment: [
|
|
197
|
+
fs.createReadStream('file1.pdf'),
|
|
198
|
+
fs.createReadStream('file2.doc')
|
|
199
|
+
]
|
|
200
|
+
}, "USER_ID");
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
#### **api.sendTypingIndicator(threadID, [callback])**
|
|
206
|
+
|
|
207
|
+
Show "typing..." indicator in chat.
|
|
208
|
+
|
|
209
|
+
```javascript
|
|
210
|
+
api.sendTypingIndicator("USER_ID", (err) => {
|
|
211
|
+
if(err) console.error(err);
|
|
212
|
+
else console.log("Typing indicator sent");
|
|
213
|
+
});
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
#### **api.setMessageReaction(emoji, messageID, [callback])**
|
|
219
|
+
|
|
220
|
+
React to a message with emoji.
|
|
221
|
+
|
|
222
|
+
```javascript
|
|
223
|
+
api.setMessageReaction("😂", "MESSAGE_ID", (err) => {
|
|
224
|
+
if(err) console.error(err);
|
|
225
|
+
else console.log("✅ Reaction added!");
|
|
226
|
+
});
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
#### **api.deleteMessage(messageID, [callback])**
|
|
232
|
+
|
|
233
|
+
Delete a sent message (must be your own message).
|
|
234
|
+
|
|
235
|
+
```javascript
|
|
236
|
+
api.deleteMessage("MESSAGE_ID", (err) => {
|
|
237
|
+
if(err) console.error(err);
|
|
238
|
+
else console.log("✅ Message deleted!");
|
|
239
|
+
});
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
#### **api.unsendMessage(messageID, [callback])**
|
|
245
|
+
|
|
246
|
+
Unsend a message (removes for all participants).
|
|
247
|
+
|
|
248
|
+
```javascript
|
|
249
|
+
api.unsendMessage("MESSAGE_ID", (err) => {
|
|
250
|
+
if(err) console.error(err);
|
|
251
|
+
else console.log("✅ Message unsent!");
|
|
252
|
+
});
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
### Thread/Chat Operations
|
|
258
|
+
|
|
259
|
+
#### **api.getThreadList(limit, [timestamp], [callback])**
|
|
260
|
+
|
|
261
|
+
Get list of conversations.
|
|
262
|
+
|
|
263
|
+
```javascript
|
|
264
|
+
api.getThreadList(20, null, (err, threads) => {
|
|
265
|
+
if(err) return console.error(err);
|
|
266
|
+
|
|
267
|
+
threads.forEach(thread => {
|
|
268
|
+
console.log(thread.name + " (" + thread.threadID + ")");
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
#### **api.getThreadInfo(threadID, [callback])**
|
|
276
|
+
|
|
277
|
+
Get detailed information about a thread.
|
|
278
|
+
|
|
279
|
+
```javascript
|
|
280
|
+
api.getThreadInfo("THREAD_ID", (err, info) => {
|
|
281
|
+
if(err) return console.error(err);
|
|
282
|
+
|
|
283
|
+
console.log("Thread name:", info.threadName);
|
|
284
|
+
console.log("Participants:", info.participantIDs);
|
|
285
|
+
console.log("Unread count:", info.unreadCount);
|
|
286
|
+
});
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
#### **api.getThreadHistory(threadID, amount, [timestamp], [callback])**
|
|
292
|
+
|
|
293
|
+
Retrieve message history from a conversation.
|
|
294
|
+
|
|
295
|
+
```javascript
|
|
296
|
+
api.getThreadHistory("THREAD_ID", 10, null, (err, messages) => {
|
|
297
|
+
if(err) return console.error(err);
|
|
298
|
+
|
|
299
|
+
messages.forEach(msg => {
|
|
300
|
+
console.log(msg.senderName + ": " + msg.body);
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
#### **api.setTitle(newTitle, threadID, [callback])**
|
|
308
|
+
|
|
309
|
+
Change group chat title/name.
|
|
310
|
+
|
|
311
|
+
```javascript
|
|
312
|
+
api.setTitle("New Group Name 🎉", "GROUP_ID", (err) => {
|
|
313
|
+
if(err) console.error(err);
|
|
314
|
+
else console.log("✅ Title changed!");
|
|
315
|
+
});
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
#### **api.createNewGroup([names], [callback])**
|
|
321
|
+
|
|
322
|
+
Create a new group chat.
|
|
323
|
+
|
|
324
|
+
```javascript
|
|
325
|
+
var userIds = ["USER_ID_1", "USER_ID_2", "USER_ID_3"];
|
|
326
|
+
|
|
327
|
+
api.createNewGroup(userIds, (err, groupID) => {
|
|
328
|
+
if(err) console.error(err);
|
|
329
|
+
else console.log("✅ Group created: " + groupID);
|
|
330
|
+
});
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
### Message Markings
|
|
336
|
+
|
|
337
|
+
#### **api.markAsRead(threadID, [callback])**
|
|
338
|
+
|
|
339
|
+
Mark messages as read in a thread.
|
|
340
|
+
|
|
341
|
+
```javascript
|
|
342
|
+
api.markAsRead("THREAD_ID", (err) => {
|
|
343
|
+
if(err) console.error(err);
|
|
344
|
+
else console.log("✅ Marked as read!");
|
|
345
|
+
});
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
#### **api.markAsSeen(threadID, [callback])**
|
|
351
|
+
|
|
352
|
+
Mark thread as seen (removes notification badge).
|
|
353
|
+
|
|
354
|
+
```javascript
|
|
355
|
+
api.markAsSeen("THREAD_ID", (err) => {
|
|
356
|
+
if(err) console.error(err);
|
|
357
|
+
});
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
### User Information
|
|
363
|
+
|
|
364
|
+
#### **api.getUserInfo(userIDs, [callback])**
|
|
365
|
+
|
|
366
|
+
Get information about users.
|
|
367
|
+
|
|
368
|
+
```javascript
|
|
369
|
+
api.getUserInfo(["USER_ID_1", "USER_ID_2"], (err, users) => {
|
|
370
|
+
if(err) return console.error(err);
|
|
371
|
+
|
|
372
|
+
Object.keys(users).forEach(id => {
|
|
373
|
+
console.log(users[id].name);
|
|
374
|
+
console.log(users[id].profilePicture);
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
#### **api.getCurrentUserID()**
|
|
382
|
+
|
|
383
|
+
Get the ID of the logged-in account.
|
|
384
|
+
|
|
385
|
+
```javascript
|
|
386
|
+
var myID = api.getCurrentUserID();
|
|
387
|
+
console.log("My ID:", myID);
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## 📞 Event Handling Guide
|
|
393
|
+
|
|
394
|
+
### Listening to Messages & Events
|
|
395
|
+
|
|
396
|
+
```javascript
|
|
397
|
+
api.setOptions({
|
|
398
|
+
listenEvents: true, // Receive group events
|
|
399
|
+
selfListen: true // Receive your own messages
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
api.listenMqtt((err, event) => {
|
|
403
|
+
if(err) return console.error(err);
|
|
404
|
+
|
|
405
|
+
switch(event.type) {
|
|
406
|
+
case "message":
|
|
407
|
+
console.log("Message from", event.senderName);
|
|
408
|
+
console.log("Content:", event.body);
|
|
409
|
+
break;
|
|
410
|
+
|
|
411
|
+
case "event":
|
|
412
|
+
console.log("Group event:", event.logMessageData);
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### Event Properties
|
|
419
|
+
|
|
420
|
+
**Message Event:**
|
|
421
|
+
```javascript
|
|
422
|
+
{
|
|
423
|
+
type: "message",
|
|
424
|
+
senderID: "USER_ID",
|
|
425
|
+
senderName: "John Doe",
|
|
426
|
+
threadID: "THREAD_ID",
|
|
427
|
+
body: "Message text",
|
|
428
|
+
isGroup: true,
|
|
429
|
+
messageID: "MSG_ID",
|
|
430
|
+
attachments: [],
|
|
431
|
+
timestamp: 1609459200000
|
|
432
|
+
}
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
**Event (Group Change):**
|
|
436
|
+
```javascript
|
|
437
|
+
{
|
|
438
|
+
type: "event",
|
|
439
|
+
threadID: "GROUP_ID",
|
|
440
|
+
logMessageType: "log:thread-name", // Type of event
|
|
441
|
+
logMessageData: {
|
|
442
|
+
name: "New Group Name" // Event details
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
---
|
|
448
|
+
|
|
449
|
+
## 🔧 Advanced Topics
|
|
450
|
+
|
|
451
|
+
### Custom Error Handling
|
|
452
|
+
|
|
453
|
+
```javascript
|
|
454
|
+
login(credentials, (err, api) => {
|
|
455
|
+
if(err) {
|
|
456
|
+
switch(err.code) {
|
|
457
|
+
case 1: // Wrong email/password
|
|
458
|
+
console.log("❌ Invalid credentials");
|
|
459
|
+
break;
|
|
460
|
+
case 2: // 2FA needed
|
|
461
|
+
console.log("⚠️ Two-factor authentication required");
|
|
462
|
+
break;
|
|
463
|
+
default:
|
|
464
|
+
console.log("❌ Login failed:", err.message);
|
|
465
|
+
}
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// Successfully logged in
|
|
470
|
+
});
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
### Rate Limiting & Delays
|
|
474
|
+
|
|
475
|
+
```javascript
|
|
476
|
+
function sendMessageWithDelay(api, message, threadID, delayMs = 1000) {
|
|
477
|
+
setTimeout(() => {
|
|
478
|
+
api.sendMessage(message, threadID);
|
|
479
|
+
}, delayMs);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// Send multiple messages with delays to avoid spam detection
|
|
483
|
+
var messages = ["Hello", "How are you?", "I'm a bot!"];
|
|
484
|
+
messages.forEach((msg, index) => {
|
|
485
|
+
sendMessageWithDelay(api, msg, "THREAD_ID", index * 2000);
|
|
486
|
+
});
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
### Session Persistence
|
|
490
|
+
|
|
491
|
+
```javascript
|
|
492
|
+
const fs = require("fs");
|
|
493
|
+
const path = require("path");
|
|
494
|
+
|
|
495
|
+
const saveAppState = (appState, filePath = 'appstate.json') => {
|
|
496
|
+
fs.writeFileSync(path.join(__dirname, filePath),
|
|
497
|
+
JSON.stringify(appState, null, 2));
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
const loadAppState = (filePath = 'appstate.json') => {
|
|
501
|
+
return JSON.parse(fs.readFileSync(path.join(__dirname, filePath), 'utf8'));
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
// Usage
|
|
505
|
+
saveAppState(api.getAppState());
|
|
506
|
+
// Later...
|
|
507
|
+
login({appState: loadAppState()}, callback);
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
---
|
|
511
|
+
|
|
512
|
+
## 🐛 Troubleshooting Common Issues
|
|
513
|
+
|
|
514
|
+
### Issue: "repository not found"
|
|
515
|
+
**Solution:** Check your GitLab/GitHub URL and credentials.
|
|
516
|
+
|
|
517
|
+
### Issue: Messages not sending
|
|
518
|
+
**Solution:**
|
|
519
|
+
1. Verify threadID is correct
|
|
520
|
+
2. Check account is not temporarily blocked
|
|
521
|
+
3. Ensure you have permission to message the user
|
|
522
|
+
4. Look for rate limiting (too many messages)
|
|
523
|
+
|
|
524
|
+
### Issue: Login fails with valid credentials
|
|
525
|
+
**Solution:**
|
|
526
|
+
1. Try manual login on Facebook.com
|
|
527
|
+
2. Check for 2FA or security alerts
|
|
528
|
+
3. Try disabling browser extensions
|
|
529
|
+
4. Wait 15 minutes if account is temporarily locked
|
|
530
|
+
|
|
531
|
+
### Issue: listenMqtt stops working
|
|
532
|
+
**Solution:**
|
|
533
|
+
1. Restart the bot
|
|
534
|
+
2. Check internet connection
|
|
535
|
+
3. Verify AppState is still valid
|
|
536
|
+
4. Re-login if session expired
|
|
537
|
+
|
|
538
|
+
---
|
|
539
|
+
|
|
540
|
+
## ✅ Best Practices
|
|
541
|
+
|
|
542
|
+
### 1. Secure Credential Management
|
|
543
|
+
```javascript
|
|
544
|
+
// ❌ DON'T: Store credentials in code
|
|
545
|
+
const credentials = {
|
|
546
|
+
email: "user@gmail.com",
|
|
547
|
+
password: "password123"
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
// ✅ DO: Use environment variables
|
|
551
|
+
const credentials = {
|
|
552
|
+
email: process.env.FB_EMAIL,
|
|
553
|
+
password: process.env.FB_PASSWORD
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
// ✅ BEST: Use saved AppState
|
|
557
|
+
const credentials = {
|
|
558
|
+
appState: JSON.parse(fs.readFileSync('.appstate.json'))
|
|
559
|
+
};
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
### 2. Error Handling
|
|
563
|
+
```javascript
|
|
564
|
+
api.sendMessage(message, threadID, (err) => {
|
|
565
|
+
if(err) {
|
|
566
|
+
console.error("❌ Send failed:", err.message);
|
|
567
|
+
// Retry logic or logging
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
### 3. Rate Limiting
|
|
573
|
+
```javascript
|
|
574
|
+
// Add delays between messages
|
|
575
|
+
setTimeout(() => {
|
|
576
|
+
api.sendMessage("Message 1", threadID);
|
|
577
|
+
}, 1000);
|
|
578
|
+
|
|
579
|
+
setTimeout(() => {
|
|
580
|
+
api.sendMessage("Message 2", threadID);
|
|
581
|
+
}, 3000);
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
### 4. Logging & Monitoring
|
|
585
|
+
```javascript
|
|
586
|
+
api.setOptions({
|
|
587
|
+
logLevel: "warning" // Only show warnings and errors
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
// Log all events
|
|
591
|
+
api.listenMqtt((err, event) => {
|
|
592
|
+
console.log(`[${new Date().toISOString()}] Event:`, event.type);
|
|
593
|
+
});
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
### 5. Graceful Shutdown
|
|
597
|
+
```javascript
|
|
598
|
+
const stopListening = api.listenMqtt((err, event) => {
|
|
599
|
+
// Handle events
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
// Clean shutdown
|
|
603
|
+
process.on("SIGINT", () => {
|
|
604
|
+
console.log("Shutting down...");
|
|
605
|
+
stopListening();
|
|
606
|
+
process.exit(0);
|
|
607
|
+
});
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
---
|
|
611
|
+
|
|
612
|
+
## 📞 Support & Community
|
|
613
|
+
|
|
614
|
+
### Get Help
|
|
615
|
+
|
|
616
|
+
- 📖 **Read Docs:** Check [README.md](README.md)
|
|
617
|
+
- 🐛 **Report Bugs:** [GitLab Issues](https://gitlab.com/priyanshufsdev/fca-priyansh/-/issues)
|
|
618
|
+
- 💬 **Ask Questions:** [Telegram Community](https://t.me/Priyanshrajput)
|
|
619
|
+
- 📧 **Email:** Contact via [priyanshuapi.xyz](https://priyanshuapi.xyz)
|
|
620
|
+
|
|
621
|
+
### Related Resources
|
|
622
|
+
|
|
623
|
+
- [Facebook Messenger Platform](https://developers.facebook.com/docs/messenger-platform)
|
|
624
|
+
- [Node.js Documentation](https://nodejs.org/docs/)
|
|
625
|
+
- [NPM Package](https://www.npmjs.com/package/fca-priyansh)
|
|
626
|
+
|
|
627
|
+
---
|
|
628
|
+
|
|
629
|
+
## 📝 License
|
|
630
|
+
|
|
631
|
+
This documentation and code are licensed under the MIT License. See [LICENSE](LICENSE) for details.
|
|
632
|
+
|
|
633
|
+
---
|
|
634
|
+
|
|
635
|
+
**Last Updated:** March 2026 | **Version:** FCA-Priyansh Latest | **Maintainer:** [Priyanshu Rajput](https://priyanshuapi.xyz)
|
|
636
|
+
|
|
637
|
+
**Happy Bot Building! 🤖** Built with ❤️ by the FCA Community
|