toru-fca 1.0.6 → 1.0.8
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 +40 -52
- package/checkUpdate.js +1 -2
- package/config.json +15 -16
- package/examples/basic-bot.js +43 -72
- package/index.js +158 -205
- package/package.json +3 -7
- package/src/listenMqtt.js +4 -2
- package/src/logout.js +4 -7
- package/src/refreshFb_dtsg.js +35 -83
- package/src/sendTypingIndicatorV2.js +22 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,54 +1,42 @@
|
|
|
1
1
|
# CHANGELOG — toru-fca
|
|
2
2
|
|
|
3
|
-
## v1.0.6
|
|
4
|
-
|
|
5
|
-
###
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
- GoatBot
|
|
37
|
-
-
|
|
38
|
-
- E2EE
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
|
|
44
|
-
### Merged From
|
|
45
|
-
- toru-fca (base): MQTT spinner, E2EE, smooth mode
|
|
46
|
-
- alpha-fca: refreshFb_dtsg, pinMessage, unsendMessage, setMessageReaction
|
|
47
|
-
- mahmud-fca: sendTypingIndicatorV2, getMessage improvements
|
|
48
|
-
- hridoy-fca: sessionGuard (backup + corruption guard)
|
|
49
|
-
|
|
50
|
-
## v1.0.1
|
|
51
|
-
- Initial merged release
|
|
52
|
-
|
|
53
|
-
## v1.0.0
|
|
54
|
-
- Base alpha-fca release
|
|
3
|
+
## v1.0.6 — Ultimate Fixed, Advanced & Merged Release
|
|
4
|
+
|
|
5
|
+
### 🔴 BROWSER LOGOUT FIX (ROOT CAUSE — FULLY FIXED)
|
|
6
|
+
|
|
7
|
+
**কারণ:** `forceLogin: true` ছিল।
|
|
8
|
+
- Facebook checkpoint এ "This was me" auto-submit করত
|
|
9
|
+
- Facebook নতুন session তৈরি করত → পুরনো browser session invalidate → **browser logout**
|
|
10
|
+
|
|
11
|
+
**Fix (3 স্তরে):**
|
|
12
|
+
1. `forceLogin: false` — checkpoint auto-submit বন্ধ → browser session অক্ষুণ্ণ
|
|
13
|
+
2. Cookie expiry minimum **1 বছর** — expire হলে session drop থেকে সুরক্ষা
|
|
14
|
+
3. SessionGuard হর 3 মিনিটে **cookie expiry extend** — bot চলার সময় কখনো expire হবে না
|
|
15
|
+
|
|
16
|
+
### ✅ সব Fix একসাথে
|
|
17
|
+
|
|
18
|
+
| File | Fix |
|
|
19
|
+
|---|---|
|
|
20
|
+
| `index.js` | forceLogin=false, cookie expiry 1yr, clean rewrite |
|
|
21
|
+
| `src/logout.js` | Cleaner no-op with better message |
|
|
22
|
+
| `src/refreshFb_dtsg.js` | Better pattern matching, error handling |
|
|
23
|
+
| `src/sendTypingIndicatorV2.js` | ctx.mqttClient undefined bug fixed |
|
|
24
|
+
| `src/listenMqtt.js` | ForcedFetch DM bug fixed, reaction off+timestamp added |
|
|
25
|
+
| `config.json` | facebookProtection added, 3min sessionGuard, 300ms smooth |
|
|
26
|
+
| `package.json` | Version 1.0.6 |
|
|
27
|
+
| `checkUpdate.js` | Version 1.0.6 |
|
|
28
|
+
| `examples/basic-bot.js` | Full rewrite, GoatBot compatible |
|
|
29
|
+
|
|
30
|
+
### Features Active in v1.0.6
|
|
31
|
+
|
|
32
|
+
- ✅ Browser logout হবে না (cookie login)
|
|
33
|
+
- ✅ Automation restriction আসবে না
|
|
34
|
+
- ✅ Inbox/DM এবং Group — উভয়তেই bot reply করবে
|
|
35
|
+
- ✅ Reaction detect (off field + timestamp)
|
|
36
|
+
- ✅ GoatBot compatible
|
|
37
|
+
- ✅ MQTT stable, auto-reconnect
|
|
38
|
+
- ✅ E2EE bridge
|
|
39
|
+
- ✅ Error-free (no crash)
|
|
40
|
+
|
|
41
|
+
## v1.0.2 — Previous Stable
|
|
42
|
+
- Anti-logout, session guard, inbox fix, GoatBot defaults, MQTT patch stream
|
package/checkUpdate.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
const CURRENT_VERSION = "1.0.6";
|
|
4
3
|
|
|
5
4
|
async function checkForFCAUpdate() {
|
|
@@ -16,7 +15,7 @@ async function checkForFCAUpdate() {
|
|
|
16
15
|
});
|
|
17
16
|
if (data && data.version && data.version !== CURRENT_VERSION) {
|
|
18
17
|
const log = require("npmlog");
|
|
19
|
-
log.warn("toru-fca", "Update available: v" + CURRENT_VERSION + " → v" + data.version + " —
|
|
18
|
+
log.warn("toru-fca", "Update available: v" + CURRENT_VERSION + " → v" + data.version + " — npm update toru-fca");
|
|
20
19
|
}
|
|
21
20
|
} catch (_) {}
|
|
22
21
|
}
|
package/config.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_info": "toru-fca v1.0.
|
|
3
|
-
|
|
4
|
-
"version": "1.0.6",
|
|
2
|
+
"_info": "toru-fca v1.0.8 — Main Config",
|
|
3
|
+
"version": "1.0.8",
|
|
5
4
|
|
|
6
5
|
"antiLogout": {
|
|
7
6
|
"enabled": true,
|
|
8
7
|
"refreshIntervalMs": 1200000,
|
|
9
|
-
"_note": "
|
|
8
|
+
"_note": "fb_dtsg হর 20 মিনিটে refresh — session alive রাখে। Browser logout হবে না।"
|
|
10
9
|
},
|
|
11
10
|
|
|
12
11
|
"sessionGuard": {
|
|
@@ -14,24 +13,24 @@
|
|
|
14
13
|
"intervalMs": 180000,
|
|
15
14
|
"debounceMs": 20000,
|
|
16
15
|
"backupEnabled": true,
|
|
17
|
-
"_note": "
|
|
16
|
+
"_note": "Appstate হর 3 মিনিটে auto-save। .bak backup রাখে। Cookie expiry extend করে।"
|
|
18
17
|
},
|
|
19
18
|
|
|
20
19
|
"automation": {
|
|
21
20
|
"enabled": false,
|
|
22
|
-
"_note": "KEEP FALSE
|
|
21
|
+
"_note": "KEEP FALSE। Background automation বন্ধ রাখে।"
|
|
23
22
|
},
|
|
24
23
|
|
|
25
24
|
"smooth": {
|
|
26
25
|
"enabled": true,
|
|
27
26
|
"messageDelay": 300,
|
|
28
|
-
"_note": "
|
|
27
|
+
"_note": "Send করার আগে typing indicator দেখাবে। 300ms delay — human-like behavior।"
|
|
29
28
|
},
|
|
30
29
|
|
|
31
30
|
"connection": {
|
|
32
31
|
"minDelayMs": 3000,
|
|
33
32
|
"maxDelayMs": 60000,
|
|
34
|
-
"_note": "MQTT reconnect backoff range
|
|
33
|
+
"_note": "MQTT reconnect backoff range।"
|
|
35
34
|
},
|
|
36
35
|
|
|
37
36
|
"e2ee": {
|
|
@@ -40,20 +39,20 @@
|
|
|
40
39
|
"devicePath": "./data/e2ee-device.json",
|
|
41
40
|
"autoReconnect": true,
|
|
42
41
|
"logLevel": "none",
|
|
43
|
-
"_note": "E2EE Labyrinth bridge
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
"inbox": {
|
|
47
|
-
"enabled": true,
|
|
48
|
-
"replyToInbox": true,
|
|
49
|
-
"_note": "Inbox always active. replyToInbox=true routes bot reply to bot inbox (not group). Required for bot message listening."
|
|
42
|
+
"_note": "E2EE Labyrinth bridge। DM + group support।"
|
|
50
43
|
},
|
|
51
44
|
|
|
52
45
|
"facebookProtection": {
|
|
53
46
|
"enabled": true,
|
|
54
47
|
"blockAutomationDetection": true,
|
|
55
48
|
"humanLikeDelay": true,
|
|
56
|
-
"_note": "
|
|
49
|
+
"_note": "online=false, updatePresence=false। Human-like 50-200ms micro-delay। Account restriction থেকে সুরক্ষা।"
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
"inbox": {
|
|
53
|
+
"enabled": true,
|
|
54
|
+
"replyToInbox": true,
|
|
55
|
+
"_note": "Bot inbox/DM এবং group উভয়তেই reply করবে।"
|
|
57
56
|
},
|
|
58
57
|
|
|
59
58
|
"enableTypingIndicator": false,
|
package/examples/basic-bot.js
CHANGED
|
@@ -1,117 +1,88 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* toru-fca v1.0.6
|
|
2
|
+
* toru-fca v1.0.6 — basic-bot.js (GoatBot compatible example)
|
|
3
3
|
*
|
|
4
|
-
* Features
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* - Graceful shutdown
|
|
12
|
-
* - GoatBot compatible
|
|
4
|
+
* Features:
|
|
5
|
+
* ✅ Cookie login — browser logout হবে না
|
|
6
|
+
* ✅ Inbox + Group — উভয়তেই bot reply করবে
|
|
7
|
+
* ✅ Session guard — appstate হর 3 মিনিটে auto-save
|
|
8
|
+
* ✅ Anti-logout — fb_dtsg 20 মিনিটে refresh
|
|
9
|
+
* ✅ Facebook protection — automation detection bypass
|
|
10
|
+
* ✅ Graceful shutdown
|
|
13
11
|
*/
|
|
14
12
|
|
|
15
13
|
"use strict";
|
|
16
14
|
|
|
17
|
-
const login = require("../index.js");
|
|
15
|
+
const login = require("../index.js");
|
|
18
16
|
const fs = require("fs");
|
|
19
17
|
const path = require("path");
|
|
20
18
|
|
|
21
|
-
// ─── Config ──────────────────────────────────────────────────────────────────
|
|
22
19
|
const APPSTATE_FILE = path.join(__dirname, "..", "appstate.json");
|
|
23
20
|
|
|
24
|
-
//
|
|
21
|
+
// ── Load appState (Cookie) ────────────────────────────────────────────────────
|
|
25
22
|
let appState;
|
|
26
23
|
try {
|
|
27
24
|
appState = JSON.parse(fs.readFileSync(APPSTATE_FILE, "utf8"));
|
|
28
25
|
} catch (err) {
|
|
29
|
-
console.error("[toru-fca] Could not load appstate.json:", err.message);
|
|
30
|
-
console.error(" Place your Facebook cookie appstate in: " + APPSTATE_FILE);
|
|
26
|
+
console.error("[toru-fca] ❌ Could not load appstate.json:", err.message);
|
|
31
27
|
process.exit(1);
|
|
32
28
|
}
|
|
33
29
|
|
|
34
|
-
//
|
|
30
|
+
// ── Login options (GoatBot compatible) ───────────────────────────────────────
|
|
35
31
|
const options = {
|
|
36
|
-
listenEvents
|
|
37
|
-
selfListen
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
listenEvents : true,
|
|
33
|
+
selfListen : false, // bot নিজের message শুনবে না
|
|
34
|
+
autoReconnect : true,
|
|
35
|
+
online : false, // automation detection bypass
|
|
36
|
+
updatePresence : false,
|
|
37
|
+
forceLogin : false, // browser logout fix
|
|
38
|
+
autoMarkRead : false,
|
|
41
39
|
autoMarkDelivery: false,
|
|
42
|
-
|
|
43
|
-
online : false, // offline mode — automation detection এড়ায়
|
|
44
|
-
logLevel : "verbose"
|
|
40
|
+
logLevel : "verbose"
|
|
45
41
|
};
|
|
46
42
|
|
|
47
|
-
//
|
|
43
|
+
// ── Login ─────────────────────────────────────────────────────────────────────
|
|
48
44
|
login({ appState }, options, function (err, api) {
|
|
49
|
-
if (err) {
|
|
50
|
-
console.error("[toru-fca] ❌ Login failed:", err.message || err);
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
45
|
+
if (err) { console.error("[toru-fca] ❌ Login failed:", err.message || err); process.exit(1); }
|
|
53
46
|
|
|
54
|
-
const
|
|
55
|
-
console.log("[toru-fca] ✅
|
|
47
|
+
const botID = api.getCurrentUserID ? api.getCurrentUserID() : "unknown";
|
|
48
|
+
console.log("[toru-fca] ✅ Bot running as:", botID);
|
|
56
49
|
|
|
57
|
-
//
|
|
58
|
-
api.sessionGuard(APPSTATE_FILE, {
|
|
59
|
-
interval: 3 * 60 * 1000, // 3 min
|
|
60
|
-
debounce: 20 * 1000, // 20 sec debounce
|
|
61
|
-
backup: true // .bak file রাখে
|
|
62
|
-
});
|
|
63
|
-
console.log("[toru-fca] 🔒 Session guard active — auto-saving appstate.");
|
|
50
|
+
// Session guard — auto-save appstate হর 3 মিনিটে
|
|
51
|
+
api.sessionGuard(APPSTATE_FILE, { interval: 3 * 60 * 1000, backup: true });
|
|
64
52
|
|
|
65
|
-
// ──
|
|
66
|
-
if (api.connectE2EE) {
|
|
67
|
-
api.connectE2EE(function (err, event) {
|
|
68
|
-
if (err) { console.error("[E2EE]", err.message || err); return; }
|
|
69
|
-
if (event && event.type) console.log("[E2EE]", event.type);
|
|
70
|
-
}).catch(e => console.error("[E2EE] connect failed:", e.message));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// ── Main message listener ───────────────────────────────────────────────
|
|
53
|
+
// ── Main listener ─────────────────────────────────────────────────────────
|
|
74
54
|
api.listenMqtt(function (err, event) {
|
|
75
|
-
if (err) {
|
|
76
|
-
console.error("[listen]", err);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
55
|
+
if (err) { console.error("[listen]", err); return; }
|
|
79
56
|
|
|
80
|
-
//
|
|
57
|
+
// Group এবং Inbox/DM — উভয়তেই কাজ করবে
|
|
81
58
|
if (event.type === "message") {
|
|
82
|
-
const { threadID, senderID, body, isGroup
|
|
83
|
-
const
|
|
84
|
-
console.log(
|
|
59
|
+
const { threadID, senderID, body, isGroup } = event;
|
|
60
|
+
const tag = isGroup ? "[Group]" : "[Inbox/DM]";
|
|
61
|
+
console.log(tag, senderID + ":", body);
|
|
85
62
|
|
|
86
|
-
// Echo
|
|
63
|
+
// Echo bot
|
|
87
64
|
if (body && body.toLowerCase() === "ping") {
|
|
88
|
-
api.sendMessage("pong!
|
|
89
|
-
if (err) console.error("[sendMessage]", err);
|
|
90
|
-
});
|
|
65
|
+
api.sendMessage("🏓 pong! — toru-fca v1.0.6", threadID);
|
|
91
66
|
}
|
|
92
67
|
}
|
|
93
68
|
|
|
94
|
-
//
|
|
95
|
-
if (event.type === "
|
|
96
|
-
console.log("[
|
|
69
|
+
// Reaction detect
|
|
70
|
+
if (event.type === "message_reaction") {
|
|
71
|
+
console.log("[Reaction]", event.senderID, event.off ? "removed reaction" : "reacted:", event.reaction);
|
|
97
72
|
}
|
|
98
|
-
});
|
|
99
73
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (!health.mqtt || !health.mqtt.connected) {
|
|
104
|
-
console.warn("[health] MQTT not connected — autoReconnect will restore.");
|
|
74
|
+
// Events (group join, leave, etc.)
|
|
75
|
+
if (event.type === "event") {
|
|
76
|
+
console.log("[Event]", event.logMessageType || event.type);
|
|
105
77
|
}
|
|
106
|
-
}
|
|
78
|
+
});
|
|
107
79
|
|
|
108
|
-
// ── Graceful shutdown
|
|
80
|
+
// ── Graceful shutdown ─────────────────────────────────────────────────────
|
|
109
81
|
function shutdown() {
|
|
110
82
|
console.log("[toru-fca] Shutting down...");
|
|
111
83
|
if (api.stopAntiLogout) api.stopAntiLogout();
|
|
112
84
|
if (api.stopListenMqtt) api.stopListenMqtt();
|
|
113
|
-
|
|
114
|
-
setTimeout(() => process.exit(0), 1500);
|
|
85
|
+
setTimeout(() => process.exit(0), 1000);
|
|
115
86
|
}
|
|
116
87
|
process.once("SIGINT", shutdown);
|
|
117
88
|
process.once("SIGTERM", shutdown);
|