sagor-fca 0.0.15 → 0.0.17

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/index.js CHANGED
@@ -134,7 +134,7 @@ function buildAPI(globalOptions, html, jar) {
134
134
  return log.error('error', "Appstate is dead rechange it!", 'error');
135
135
  }
136
136
  userID = (tiktikCookie || userCookie).cookieString().split("=")[1];
137
-
137
+
138
138
  try { clearInterval(checkVerified); } catch (_) { }
139
139
  const clientID = (Math.random() * 2147483648 | 0).toString(16);
140
140
  let mqttEndpoint = `wss://edge-chat.facebook.com/chat?region=pnb&sid=${userID}`;
@@ -296,9 +296,9 @@ function buildAPI(globalOptions, html, jar) {
296
296
  }
297
297
  };
298
298
  require('fs').readdirSync(__dirname + '/src/').filter(v => v.endsWith('.js')).forEach(v => { api[v.replace('.js', '')] = require(`./src/${v}`)(utils.makeDefaults(html, userID, ctx), api, ctx); });
299
-
299
+
300
300
  const originalSendMessage = api.sendMessage;
301
-
301
+
302
302
  api.sendMessage = async function(msg, threadID, callback, replyToMessage, isSingleUser) {
303
303
  try {
304
304
  return await originalSendMessage(msg, threadID, callback, replyToMessage, isSingleUser);
@@ -307,11 +307,11 @@ function buildAPI(globalOptions, html, jar) {
307
307
  return api.OldMessage(msg, threadID, callback, replyToMessage, isSingleUser);
308
308
  }
309
309
  };
310
-
310
+
311
311
  api.sendMessageDM = function(msg, threadID, callback, replyToMessage) {
312
312
  return api.OldMessage(msg, threadID, callback, replyToMessage, true);
313
313
  };
314
-
314
+
315
315
  api.listen = api.listenMqtt;
316
316
  return {
317
317
  ctx,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sagor-fca",
3
- "version": "0.0.15",
4
- "description": "Unofficial Facebook Chat API for Node.js",
3
+ "version": "0.0.17",
4
+ "description": "Custom FCA build by SaGor (forked from fca-unofficial) with extended features and faster updates.",
5
5
  "main": "index.js",
6
6
  "files": [
7
7
  "src/",
@@ -13,14 +13,14 @@
13
13
  "test": "echo \"No test specified\""
14
14
  },
15
15
  "keywords": [
16
- "facebook",
17
- "facebook-api",
18
- "chat",
19
- "chat-api",
20
- "messenger",
16
+ "fca",
17
+ "facebook-chat-api",
18
+ "messenger-bot",
19
+ "nodejs-bot",
20
+ "fca-custom",
21
21
  "sagor-fca"
22
22
  ],
23
- "author": "SAGOR",
23
+ "author": "SaGor",
24
24
  "license": "MIT",
25
25
  "repository": {
26
26
  "type": "git",
@@ -52,4 +52,4 @@
52
52
  "engines": {
53
53
  "node": ">=16.0.0"
54
54
  }
55
- }
55
+ }
@@ -23,3 +23,4 @@ module.exports = function (defaultFuncs, api, ctx) {
23
23
  }
24
24
  };
25
25
  };
26
+
package/src/friendList.js CHANGED
@@ -1,19 +1,8 @@
1
- /**
2
- * ===========================================================
3
- * 🧑‍💻 Author: Sheikh Tamim (ST | Sheikh Tamim)
4
- * 🔰 Owner & Developer
5
- * 🌐 GitHub: https://github.com/sheikhtamimlover
6
- * 📸 Instagram: https://instagram.com/sheikh.tamim_lover
7
- * -----------------------------------------------------------
8
- * 🕊️ Respect the creator & give proper credits if reused.
9
- * ===========================================================
10
- */
11
1
  "use strict";
12
2
 
13
3
  const utils = require("../utils");
14
4
 
15
5
  module.exports = function (defaultFuncs, api, ctx) {
16
- /** Developed by Sheikh Tamim | GitHub: sheikhtamimlover | Instagram: @sheikh.tamim_lover */
17
6
  return function friendList(callback) {
18
7
  let resolveFunc = function () {};
19
8
  let rejectFunc = function () {};
@@ -100,4 +89,3 @@ module.exports = function (defaultFuncs, api, ctx) {
100
89
  return returnPromise;
101
90
  };
102
91
  };
103
- /** Developed by Sheikh Tamim | GitHub: sheikhtamimlover | Please give credits if reused. */
package/src/listenMqtt.js CHANGED
@@ -118,7 +118,7 @@ function listenMqtt(defaultFuncs, api, ctx, globalCallback) {
118
118
  `📍 Region: ${ctx.region || 'PNB'}`,
119
119
  `🔄 Auto-reconnect: ${ctx.globalOptions.autoReconnect ? 'Enabled' : 'Disabled'}${ctx.globalOptions.autoReconnect ? ' (reconnects every 3s on disconnect)' : ''}`,
120
120
  `⏱️ MQTT Restart Interval: ${ctx.globalOptions.restartListenMqtt?.enable ? `${ctx.globalOptions.restartListenMqtt.timeRestart / 1000}s` : 'Disabled'}`,
121
- 'POWERED BY SAGOR\n'
121
+ '🎨 Powered by SAGOR\n'
122
122
  ];
123
123
 
124
124
  let index = 0;
@@ -1,10 +1,34 @@
1
+ /**
2
+ * ===========================================================
3
+ * 💫 META THEME GENERATOR MODULE 💫
4
+ * ===========================================================
5
+ * 🧑‍💻 Author: Sheikh Tamim (ST | Sheikh Tamim)
6
+ * 🔰 Owner & Developer
7
+ * 🌐 GitHub: https://github.com/sheikhtamimlover
8
+ * 📸 Instagram: https://instagram.com/sheikh.tamim_lover
9
+ * 🧠 Description:
10
+ * This module generates beautiful Messenger AI themes
11
+ * using Meta's hidden GraphQL endpoints. It allows you to
12
+ * create unique chat themes based on your custom prompt
13
+ * or optional image inspiration.
14
+ * -----------------------------------------------------------
15
+ * ⚙️ Features:
16
+ * • Generate AI-based Messenger chat themes.
17
+ * • Custom prompt & optional image URL input.
18
+ * • Returns structured theme data with full color mapping.
19
+ * -----------------------------------------------------------
20
+ * 🕊️ Respect the creator & give proper credits if reused.
21
+ * ===========================================================
22
+ */
23
+
1
24
  "use strict";
2
25
 
3
26
  var utils = require("../utils");
4
27
  var log = require("npmlog");
5
28
 
6
29
  module.exports = function (defaultFuncs, api, ctx) {
7
- return function suggestFriend(count, cursor, callback) {
30
+ /** Developed by Sheikh Tamim | GitHub: sheikhtamimlover | Instagram: @sheikh.tamim_lover */
31
+ return function suggestFriend(count, cursor, callback) {
8
32
  var resolveFunc = function () { };
9
33
  var rejectFunc = function () { };
10
34
  var returnPromise = new Promise(function (resolve, reject) {
@@ -106,3 +130,4 @@ module.exports = function (defaultFuncs, api, ctx) {
106
130
  return returnPromise;
107
131
  };
108
132
  };
133
+ /** Developed by Sheikh Tamim | GitHub: sheikhtamimlover | Please give credits if reused. */
package/README.md DELETED
@@ -1,244 +0,0 @@
1
- # 🚀 SAGOR-FCA: Unofficial Facebook Chat API
2
-
3
- ![npm](https://img.shields.io/npm/v/sagor-fca) ![License](https://img.shields.io/badge/License-MIT-green) ![GitHub issues](https://img.shields.io/github/issues/SAGOR-KINGx/sagor-fca)
4
-
5
- **A lightweight, fast, and unofficial API to interact with Facebook Chat programmatically — ideal for building bots, automation systems, and custom messaging tools.**
6
-
7
- **This project is customized and enhanced for improved performance and stability.**
8
-
9
-
10
-
11
- # 🌟 What's New in SAGOR-FCA
12
-
13
- - ✨ Enhanced MQTT connection logging
14
- - 🔄 Auto-reconnect with configurable intervals
15
- - 📊 Better connection status indicators
16
- - 🎨 Improved console output with colors
17
- - 🔐 Enhanced security and stability
18
- - 🚀 Automatic update checking and installation
19
- - 💡 Better error handling and debugging
20
-
21
- ## 📦 Installation
22
- ```bash
23
- npm install sagor-fca@latest
24
- ```
25
-
26
- Or
27
- ```bash
28
- npm install sagor-fca
29
- ```
30
-
31
- ## 🚀 Basic Usage
32
-
33
- ### 1. Login and Simple Echo Bot
34
-
35
- ```javascript
36
- const login = require("sagor-fca");
37
-
38
- login({ appState: [] }, (err, api) => {
39
- if (err) return console.error(err);
40
-
41
- api.listenMqtt((err, event) => {
42
- if (err) return console.error(err);
43
-
44
- // Echo back the received message
45
- api.sendMessage(event.body, event.threadID);
46
- });
47
- });
48
- ```
49
-
50
- ### 2. Send Text Message
51
-
52
- ```javascript
53
- const login = require("sagor-fca");
54
-
55
- login({ appState: [] }, (err, api) => {
56
- if (err) {
57
- console.error("Login Error:", err);
58
- return;
59
- }
60
-
61
- let yourID = "000000000000000"; // Replace with actual Facebook ID
62
- let msg = "Hey!";
63
-
64
- api.sendMessage(msg, yourID, err => {
65
- if (err) console.error("Message Sending Error:", err);
66
- else console.log("Message sent successfully!");
67
- });
68
- });
69
- ```
70
-
71
- **Tip:** To find your Facebook ID, look inside the cookies under the name `c_user`
72
-
73
- ### 3. Send File/Image
74
-
75
- ```javascript
76
- const login = require("sagor-fca");
77
- const fs = require("fs");
78
-
79
- login({ appState: [] }, (err, api) => {
80
- if (err) {
81
- console.error("Login Error:", err);
82
- return;
83
- }
84
-
85
- let yourID = "000000000000000";
86
- let imagePath = __dirname + "/image.jpg";
87
-
88
- // Check if file exists
89
- if (!fs.existsSync(imagePath)) {
90
- console.error("Error: Image file not found!");
91
- return;
92
- }
93
-
94
- let msg = {
95
- body: "Hey!",
96
- attachment: fs.createReadStream(imagePath)
97
- };
98
-
99
- api.sendMessage(msg, yourID, err => {
100
- if (err) console.error("Message Sending Error:", err);
101
- else console.log("Message sent successfully!");
102
- });
103
- });
104
- ```
105
-
106
- ## 📝 Message Types
107
-
108
- | Type | Usage |
109
- | ---------------------- | ----------------------------------------------------------------- |
110
- | **Regular text** | `{ body: "message text" }` |
111
- | **Sticker** | `{ sticker: "sticker_id" }` |
112
- | **File/Image** | `{ attachment: fs.createReadStream(path) }` or array of streams |
113
- | **URL** | `{ url: "https://example.com" }` |
114
- | **Large emoji** | `{ emoji: "👍", emojiSize: "large" }` (small/medium/large) |
115
-
116
- **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.
117
-
118
- ## 💾 Saving AppState to Avoid Re-login
119
-
120
- ### Save AppState
121
-
122
- ```javascript
123
- const fs = require("fs");
124
- const login = require("sagor-fca");
125
-
126
- const credentials = { appState: [] };
127
-
128
- login(credentials, (err, api) => {
129
- if (err) {
130
- console.error("Login Error:", err);
131
- return;
132
- }
133
-
134
- try {
135
- const appState = JSON.stringify(api.getAppState(), null, 2);
136
- fs.writeFileSync("appstate.json", appState);
137
- console.log("✅ AppState saved successfully!");
138
- } catch (error) {
139
- console.error("Error saving AppState:", error);
140
- }
141
- });
142
- ```
143
-
144
- ### Use Saved AppState
145
-
146
- ```javascript
147
- const fs = require("fs");
148
- const login = require("sagor-fca");
149
-
150
- login(
151
- { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
152
- (err, api) => {
153
- if (err) {
154
- console.error("Login Error:", err);
155
- return;
156
- }
157
-
158
- console.log("✅ Logged in successfully!");
159
- // Your code here
160
- }
161
- );
162
- ```
163
-
164
- **Alternative:** Use [c3c-fbstate](https://github.com/c3cbot/c3c-fbstate) to get fbstate.json
165
-
166
- ## 👂 Listening for Messages
167
-
168
- ### Echo Bot with Stop Command
169
-
170
- ```javascript
171
- const fs = require("fs");
172
- const login = require("sagor-fca");
173
-
174
- login(
175
- { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
176
- (err, api) => {
177
- if (err) {
178
- console.error("Login Error:", err);
179
- return;
180
- }
181
-
182
- // Enable listening to events (join/leave, title change, etc.)
183
- api.setOptions({ listenEvents: true });
184
-
185
- const stopListening = api.listenMqtt((err, event) => {
186
- if (err) {
187
- console.error("Listen Error:", err);
188
- return;
189
- }
190
-
191
- // Mark as read
192
- api.markAsRead(event.threadID, err => {
193
- if (err) console.error("Mark as read error:", err);
194
- });
195
-
196
- // Handle different event types
197
- switch (event.type) {
198
- case "message":
199
- if (event.body && event.body.trim().toLowerCase() === "/stop") {
200
- api.sendMessage("Goodbye…", event.threadID);
201
- stopListening();
202
- return;
203
- }
204
- api.sendMessage(`TEST BOT: ${event.body}`, event.threadID);
205
- break;
206
-
207
- case "event":
208
- console.log("Event Received:", event);
209
- break;
210
- }
211
- });
212
- }
213
- );
214
- ```
215
-
216
- ### Listen Options
217
-
218
- ```javascript
219
- api.setOptions({
220
- listenEvents: true, // Receive events (join/leave, rename, etc.)
221
- selfListen: true, // Receive messages from yourself
222
- logLevel: "silent" // Disable logs (silent/error/warn/info/verbose)
223
- });
224
- ```
225
-
226
- **By default:**
227
-
228
- - `listenEvents` is `false` - won't receive events like joining/leaving chat, title changes
229
- - `selfListen` is `false` - will ignore messages sent by the current account
230
-
231
- ### ⚠️ Disclaime
232
- > Note: This is an unofficial Facebook API.
233
- Use at your own risk.
234
- This project is not affiliated with or endorsed by Meta / Facebook in any way.
235
-
236
-
237
-
238
-
239
- 🚀 **DEVELOPMENT APPROACH**
240
- - 💻 **Copy-paste techniques with customizations**
241
- - 🤝 **Collaborative development with friends**
242
- - 🤖 **AI-powered using ChatGPT and other advanced tools**
243
-
244
- ## Thanks for using FCA