@dongdev/fca-unofficial 2.0.11 → 2.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,76 @@
1
+ # Changelog
2
+ Too lazy to write changelog, sorry! (will write changelog in the next release, through.)
3
+ ## v1.0.10 - 2025-04-24
4
+ - Hotfix / auto bump
5
+
6
+ ## v1.0.11 - 2025-04-24
7
+ - Hotfix / auto bump
8
+
9
+ ## v1.0.12 - 2025-04-28
10
+ - Hotfix / auto bump
11
+
12
+ ## v1.0.13 - 2025-04-28
13
+ - Hotfix / auto bump
14
+
15
+ ## v1.0.14 - 2025-04-28
16
+ - Hotfix / auto bump
17
+
18
+ ## v1.0.15 - 2025-05-03
19
+ - Hotfix / auto bump
20
+
21
+ ## v1.0.16 - 2025-05-07
22
+ - Hotfix / auto bump
23
+
24
+ ## v1.0.17 - 2025-05-07
25
+ - Hotfix / auto bump
26
+
27
+ ## v1.0.18 - 2025-05-22
28
+ - Hotfix / auto bump
29
+
30
+ ## v1.0.19 - 2025-05-23
31
+ - Hotfix / auto bump
32
+
33
+ ## v2.0.0 - 2025-10-05
34
+ - Hotfix / auto bump
35
+
36
+ ## v2.0.1 - 2025-10-05
37
+ - Hotfix / auto bump
38
+
39
+ ## v2.0.2 - 2025-10-05
40
+ - Hotfix / auto bump
41
+
42
+ ## v2.0.3 - 2025-10-05
43
+ - Hotfix / auto bump
44
+
45
+ ## v2.0.4 - 2025-10-05
46
+ - Hotfix / auto bump
47
+
48
+ ## v2.0.5 - 2025-10-06
49
+ - Now you can turn on/off autoLogin in config file.
50
+ - Added autoUpdate feature.
51
+ ## v2.0.6-beta - 2025-10-06
52
+ - Hotfix / auto bump
53
+
54
+ ## v2.0.7 - 2025-10-06
55
+ - Hotfix / auto bump
56
+
57
+ ## v2.0.8 - 2025-10-07
58
+ - Hotfix / auto bump
59
+
60
+ ## v2.0.9 - 2025-10-07
61
+ - Hotfix / auto bump
62
+
63
+ ## v2.0.9 - 2025-10-07
64
+ - Hotfix / auto bump
65
+
66
+ ## v2.0.10 - 2025-10-07
67
+ - Hotfix / auto bump
68
+
69
+ ## v2.0.10 - 2025-10-07
70
+ - Hotfix / auto bump
71
+
72
+ ## v2.0.11 - 2025-10-07
73
+ - Hotfix / auto bump
74
+
75
+ ## v2.0.12 - 2025-10-07
76
+ - Hotfix / auto bump
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 DongDev (@dongdev/fca-unofficial)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -8,6 +8,7 @@
8
8
  ## ⚠️ Important Disclaimer
9
9
 
10
10
  **We are not responsible if your account gets banned for spammy activities such as:**
11
+
11
12
  - Sending lots of messages to people you don't know
12
13
  - Sending messages very quickly
13
14
  - Sending spammy looking URLs
@@ -15,13 +16,14 @@
15
16
 
16
17
  **Recommendation:** Use Firefox browser or [this website](https://fca.dongdev.id.vn) to reduce logout issues, especially for iOS users.
17
18
 
18
- **Support:** If you encounter errors, contact us [here](https://www.facebook.com/minhdong.dev)
19
+ **Support:** If you encounter errors, contact us [here](https://www.facebook.com/mdong.dev)
19
20
 
20
21
  ## 🔍 Introduction
21
22
 
22
23
  Facebook now has an [official API for chat bots](https://developers.facebook.com/docs/messenger-platform), however it's only available for Facebook Pages.
23
24
 
24
25
  `@dongdev/fca-unofficial` is the only API that allows you to automate chat functionalities on a **user account** by emulating the browser. This means:
26
+
25
27
  - Making the exact same GET/POST requests as a browser
26
28
  - Does not work with auth tokens
27
29
  - Requires Facebook account credentials (email/password) or AppState
@@ -109,13 +111,13 @@ login({ appState: [] }, (err, api) => {
109
111
 
110
112
  ## 📝 Message Types
111
113
 
112
- | Type | Usage |
113
- | ---------------- | --------------------------------------------------------------- |
114
+ | Type | Usage |
115
+ | ---------------------- | ----------------------------------------------------------------- |
114
116
  | **Regular text** | `{ body: "message text" }` |
115
117
  | **Sticker** | `{ sticker: "sticker_id" }` |
116
118
  | **File/Image** | `{ attachment: fs.createReadStream(path) }` or array of streams |
117
119
  | **URL** | `{ url: "https://example.com" }` |
118
- | **Large emoji** | `{ emoji: "👍", emojiSize: "large" }` (small/medium/large) |
120
+ | **Large emoji** | `{ emoji: "👍", emojiSize: "large" }` (small/medium/large) |
119
121
 
120
122
  **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.
121
123
 
@@ -228,6 +230,7 @@ api.setOptions({
228
230
  ```
229
231
 
230
232
  **By default:**
233
+
231
234
  - `listenEvents` is `false` - won't receive events like joining/leaving chat, title changes
232
235
  - `selfListen` is `false` - will ignore messages sent by the current account
233
236
 
@@ -252,6 +255,7 @@ api.setOptions({
252
255
  ## 📚 Full API Documentation
253
256
 
254
257
  See [DOCS.md](./DOCS.md) for detailed information about:
258
+
255
259
  - All available API methods
256
260
  - Parameters and options
257
261
  - Event types
@@ -291,6 +295,7 @@ api.setMessageReaction(reaction, messageID, callback);
291
295
  ## 🤝 Contributing
292
296
 
293
297
  Contributions are welcome! Please:
298
+
294
299
  1. Fork the repository
295
300
  2. Create a new branch (`git checkout -b feature/AmazingFeature`)
296
301
  3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
@@ -0,0 +1,62 @@
1
+ // func/checkUpdate.js
2
+ const logger = require("./logger");
3
+ const fs = require("fs");
4
+ const { exec } = require("child_process");
5
+ const pkgName = "@dongdev/fca-unofficial";
6
+
7
+ function execPromise(cmd) {
8
+ return new Promise((resolve, reject) => {
9
+ exec(cmd, (error, stdout, stderr) => {
10
+ if (error) return reject({ error, stderr });
11
+ resolve({ stdout, stderr });
12
+ });
13
+ });
14
+ }
15
+
16
+ function getInstalledVersion() {
17
+ try {
18
+ const p = require.resolve(`${pkgName}/package.json`, { paths: [process.cwd(), __dirname] });
19
+ return JSON.parse(fs.readFileSync(p, "utf8")).version;
20
+ } catch {
21
+ return null;
22
+ }
23
+ }
24
+
25
+ async function _checkAndUpdateVersionImpl() {
26
+ logger("Checking version...", "info");
27
+ const latest = (await execPromise(`npm view ${pkgName} version`)).stdout.trim();
28
+ const installed = getInstalledVersion();
29
+ if (!installed || installed !== latest) {
30
+ logger(`New version available (${latest}). Current version (${installed || "not installed"}). Updating...`, "info");
31
+ try {
32
+ const { stderr } = await execPromise(`npm i ${pkgName}@latest`);
33
+ if (stderr) logger(stderr, "error");
34
+ logger(`Updated fca to the latest version: ${latest}, Restart to apply`, "info");
35
+ process.exit(1);
36
+ } catch (e) {
37
+ logger(`Error running npm install: ${e.error || e}. Trying to install from GitHub...`, "error");
38
+ try {
39
+ const { stderr } = await execPromise("npm i https://github.com/Donix-VN/fca-unofficial");
40
+ if (stderr) logger(stderr, "error");
41
+ logger(`Installed from GitHub successfully: ${latest}`, "info");
42
+ return;
43
+ } catch (gitErr) {
44
+ logger(`Error installing from GitHub: ${gitErr.error || gitErr}`, "error");
45
+ throw (gitErr.error || gitErr);
46
+ }
47
+ }
48
+ } else {
49
+ logger(`You're already on the latest version - ${latest}`, "info");
50
+ return;
51
+ }
52
+ }
53
+
54
+ function checkAndUpdateVersion(callback) {
55
+ if (typeof callback === "function") {
56
+ _checkAndUpdateVersionImpl().then(() => callback(null)).catch(err => callback(err));
57
+ return;
58
+ }
59
+ return _checkAndUpdateVersionImpl();
60
+ }
61
+
62
+ module.exports = { checkAndUpdateVersion };
package/func/logger.js ADDED
@@ -0,0 +1,48 @@
1
+ const chalk = require("chalk");
2
+ const gradient = require("gradient-string");
3
+
4
+ const themes = [
5
+ "blue", "dream2", "dream", "fiery", "rainbow", "pastel", "cristal", "red", "aqua", "pink", "retro", "sunlight", "teen", "summer", "flower", "ghost", "hacker"
6
+ ];
7
+
8
+ function buildGradient(name) {
9
+ const t = String(name || "").toLowerCase();
10
+ if (t === "blue") return gradient([{ color: "#1affa3", pos: 0.2 }, { color: "cyan", pos: 0.4 }, { color: "pink", pos: 0.6 }, { color: "cyan", pos: 0.8 }, { color: "#1affa3", pos: 1 }]);
11
+ if (t === "dream2") return gradient("blue", "pink");
12
+ if (t === "dream") return gradient([{ color: "blue", pos: 0.2 }, { color: "pink", pos: 0.3 }, { color: "gold", pos: 0.6 }, { color: "pink", pos: 0.8 }, { color: "blue", pos: 1 }]);
13
+ if (t === "fiery") return gradient("#fc2803", "#fc6f03", "#fcba03");
14
+ if (t === "rainbow") return gradient.rainbow;
15
+ if (t === "pastel") return gradient.pastel;
16
+ if (t === "cristal") return gradient.cristal;
17
+ if (t === "red") return gradient("red", "orange");
18
+ if (t === "aqua") return gradient("#0030ff", "#4e6cf2");
19
+ if (t === "pink") return gradient("#d94fff", "purple");
20
+ if (t === "retro") return gradient.retro;
21
+ if (t === "sunlight") return gradient("orange", "#ffff00", "#ffe600");
22
+ if (t === "teen") return gradient.teen;
23
+ if (t === "summer") return gradient.summer;
24
+ if (t === "flower") return gradient("blue", "purple", "yellow", "#81ff6e");
25
+ if (t === "ghost") return gradient.mind;
26
+ if (t === "hacker") return gradient("#47a127", "#0eed19", "#27f231");
27
+ return gradient("#243aff", "#4687f0", "#5800d4");
28
+ }
29
+
30
+ const themeName = themes[Math.floor(Math.random() * themes.length)];
31
+ const co = buildGradient(themeName);
32
+
33
+ module.exports = (text, type) => {
34
+ const s = String(type || "info").toLowerCase();
35
+ if (s === "warn") {
36
+ process.stderr.write(co(`\r[ FCA-WARN ] > ${text}`) + "\n");
37
+ return;
38
+ }
39
+ if (s === "error") {
40
+ process.stderr.write(chalk.bold.hex("#ff0000")(`\r[ FCA-ERROR ]`) + ` > ${text}\n`);
41
+ return;
42
+ }
43
+ if (s === "info") {
44
+ process.stderr.write(chalk.bold(co(`\r[ FCA-UNO ] > ${text}`)) + "\n");
45
+ return;
46
+ }
47
+ process.stderr.write(chalk.bold(co(`\r[ ${s.toUpperCase()} ] > ${text}`)) + "\n");
48
+ };