hridoy-ultimate 8.0.0 → 8.0.2

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 (264) hide show
  1. package/ANALYSIS.md +31 -0
  2. package/AUDIT_REPORT.md +57 -0
  3. package/CHANGELOG.md +40 -322
  4. package/README.md +94 -339
  5. package/advancedSystem.js +95 -0
  6. package/checkUpdate.js +47 -0
  7. package/config.json +51 -0
  8. package/e2ee.js +738 -0
  9. package/examples/basic-bot.js +122 -0
  10. package/examples/e2ee-bot.js +141 -0
  11. package/fca-config.example.json +73 -0
  12. package/index.js +824 -24
  13. package/{src/api/socket/e2ee/native/lib → lib}/index.mjs +65 -107
  14. package/package.json +22 -62
  15. package/scripts/check.js +38 -0
  16. package/src/OldMessage.js +357 -0
  17. package/src/{api/action/addExternalModule.js → addExternalModule.js} +8 -8
  18. package/src/addUserToGroup.js +117 -0
  19. package/src/changeAdminStatus.js +105 -0
  20. package/src/{api/messaging/changeArchivedStatus.js → changeArchivedStatus.js} +17 -15
  21. package/src/{api/action/changeAvatar.js → changeAvatar.js} +33 -32
  22. package/src/changeAvatarV2.js +86 -0
  23. package/src/changeAvt.js +85 -0
  24. package/src/{api/action/changeBio.js → changeBio.js} +22 -19
  25. package/src/{api/messaging/changeBlockedStatus.js → changeBlockedStatus.js} +16 -13
  26. package/src/changeBlockedStatusMqtt.js +75 -0
  27. package/src/changeCover.js +73 -0
  28. package/src/changeGroupImage.js +137 -0
  29. package/src/changeName.js +79 -0
  30. package/src/changeNickname.js +61 -0
  31. package/src/changeThreadColor.js +67 -0
  32. package/src/changeThreadEmoji.js +57 -0
  33. package/src/changeUsername.js +59 -0
  34. package/src/createCommentPost.js +232 -0
  35. package/src/{api/messaging/createNewGroup.js → createNewGroup.js} +26 -24
  36. package/src/createPoll.js +73 -0
  37. package/src/createPost.js +276 -0
  38. package/src/deleteMessage.js +58 -0
  39. package/src/{api/messaging/deleteThread.js → deleteThread.js} +16 -14
  40. package/src/editMessage.js +76 -0
  41. package/src/editMessageOld.js +62 -0
  42. package/src/follow.js +74 -0
  43. package/src/forwardAttachment.js +62 -0
  44. package/src/friendList.js +104 -0
  45. package/src/getAccess.js +112 -0
  46. package/src/getAvatarUser.js +78 -0
  47. package/src/getBotInitialData.js +42 -0
  48. package/src/getCtx.js +5 -0
  49. package/src/{api/action/getCurrentUserID.js → getCurrentUserID.js} +1 -1
  50. package/src/{api/messaging/getEmojiUrl.js → getEmojiUrl.js} +2 -2
  51. package/src/{api/messaging/getFriendsList.js → getFriendsList.js} +19 -16
  52. package/src/{api/messaging/getMessage.js → getMessage.js} +180 -160
  53. package/src/getOptions.js +5 -0
  54. package/src/getRegion.js +7 -0
  55. package/src/{api/threads/getThreadHistory.js → getThreadHistory.js} +132 -114
  56. package/src/getThreadHistoryDeprecated.js +71 -0
  57. package/src/getThreadInfo.js +232 -0
  58. package/src/getThreadInfoDeprecated.js +56 -0
  59. package/src/getThreadList.js +213 -0
  60. package/src/getThreadListDeprecated.js +46 -0
  61. package/src/getThreadPictures.js +59 -0
  62. package/src/getThreadTheme.js +81 -0
  63. package/src/getUID.js +119 -0
  64. package/src/{api/users/getUserID.js → getUserID.js} +18 -22
  65. package/src/getUserInfo.js +66 -0
  66. package/src/handleFriendRequest.js +46 -0
  67. package/src/handleMessageRequest.js +47 -0
  68. package/src/httpGet.js +49 -0
  69. package/src/httpPost.js +48 -0
  70. package/src/httpPostFormData.js +70 -0
  71. package/src/listenMqtt.js +1081 -0
  72. package/src/listenNotification.js +85 -0
  73. package/src/logout.js +18 -0
  74. package/src/markAsDelivered.js +47 -0
  75. package/src/markAsRead.js +72 -0
  76. package/src/markAsReadAll.js +40 -0
  77. package/src/markAsSeen.js +48 -0
  78. package/src/metaTheme.js +189 -0
  79. package/src/muteThread.js +45 -0
  80. package/src/note.js +228 -0
  81. package/src/pinMessage.js +54 -0
  82. package/src/refreshFb_dtsg.js +49 -0
  83. package/src/removeSuspiciousAccount.js +78 -0
  84. package/src/removeUserFromGroup.js +81 -0
  85. package/src/reply.js +442 -0
  86. package/src/{api/messaging/resolvePhotoUrl.js → resolvePhotoUrl.js} +15 -11
  87. package/src/{api/messaging/searchForThread.js → searchForThread.js} +12 -12
  88. package/src/searchFriends.js +140 -0
  89. package/src/searchStickers.js +53 -0
  90. package/src/send.js +46 -0
  91. package/src/sendButtons.js +163 -0
  92. package/src/sendComment.js +159 -0
  93. package/src/sendFriendRequest.js +112 -0
  94. package/src/sendMessage.js +441 -0
  95. package/src/sendMessageMqtt.js +323 -0
  96. package/src/sendTypingIndicator.js +68 -0
  97. package/src/sendTypingIndicatorV2.js +22 -0
  98. package/src/setActiveStatus.js +92 -0
  99. package/src/setMessageReaction.js +150 -0
  100. package/src/setMessageReactionMqtt.js +104 -0
  101. package/src/setMessageReactionSafe.js +44 -0
  102. package/src/{api/action/setPostReaction.js → setPostReaction.js} +31 -23
  103. package/src/setProfileGuard.js +44 -0
  104. package/src/setProfileLock.js +97 -0
  105. package/src/setStoryReaction.js +133 -0
  106. package/src/setStorySeen.js +108 -0
  107. package/src/setThreadTheme.js +102 -0
  108. package/src/setTitle.js +92 -0
  109. package/src/shareContact.js +110 -0
  110. package/src/shareLink.js +59 -0
  111. package/src/stopListenMqtt.js +60 -0
  112. package/src/storyManager.js +357 -0
  113. package/src/suggestFriend.js +132 -0
  114. package/src/{api/messaging/threadColors.js → threadColors.js} +5 -2
  115. package/src/{api/action/unfriend.js → unfriend.js} +14 -14
  116. package/src/unsendMessage.js +68 -0
  117. package/src/uploadAttachment.js +115 -0
  118. package/test/fixes-1_2_4.test.js +118 -0
  119. package/test/mqtt-stop.test.js +32 -0
  120. package/test/reaction-mqtt.test.js +57 -0
  121. package/utils.js +3056 -0
  122. package/DOCS.md +0 -2712
  123. package/func/checkUpdate.js +0 -7
  124. package/func/logAdapter.js +0 -33
  125. package/func/logger.js +0 -48
  126. package/index.d.ts +0 -751
  127. package/module/config.js +0 -43
  128. package/module/login.js +0 -135
  129. package/module/loginHelper.js +0 -1381
  130. package/module/options.js +0 -49
  131. package/src/api/action/dismissScrapingWarning.js +0 -50
  132. package/src/api/action/enableAutoSaveAppState.js +0 -73
  133. package/src/api/action/handleFriendRequest.js +0 -57
  134. package/src/api/action/logout.js +0 -76
  135. package/src/api/action/refreshFb_dtsg.js +0 -47
  136. package/src/api/http/httpGet.js +0 -46
  137. package/src/api/http/httpPost.js +0 -52
  138. package/src/api/http/postFormData.js +0 -47
  139. package/src/api/messaging/addUserToGroup.js +0 -68
  140. package/src/api/messaging/changeAdminStatus.js +0 -126
  141. package/src/api/messaging/changeGroupImage.js +0 -91
  142. package/src/api/messaging/changeNickname.js +0 -70
  143. package/src/api/messaging/changeThreadColor.js +0 -79
  144. package/src/api/messaging/changeThreadEmoji.js +0 -111
  145. package/src/api/messaging/createPoll.js +0 -46
  146. package/src/api/messaging/createThemeAI.js +0 -98
  147. package/src/api/messaging/deleteMessage.js +0 -136
  148. package/src/api/messaging/editMessage.js +0 -105
  149. package/src/api/messaging/forwardAttachment.js +0 -57
  150. package/src/api/messaging/forwardMessage.js +0 -134
  151. package/src/api/messaging/getThemePictures.js +0 -62
  152. package/src/api/messaging/handleMessageRequest.js +0 -65
  153. package/src/api/messaging/markAsDelivered.js +0 -69
  154. package/src/api/messaging/markAsRead.js +0 -110
  155. package/src/api/messaging/markAsReadAll.js +0 -56
  156. package/src/api/messaging/markAsSeen.js +0 -68
  157. package/src/api/messaging/muteThread.js +0 -50
  158. package/src/api/messaging/pinMessage.js +0 -115
  159. package/src/api/messaging/removeUserFromGroup.js +0 -62
  160. package/src/api/messaging/scheduler.js +0 -264
  161. package/src/api/messaging/sendBroadcast.js +0 -93
  162. package/src/api/messaging/sendMessage.js +0 -269
  163. package/src/api/messaging/sendTypingIndicator.js +0 -90
  164. package/src/api/messaging/sessionGuard.js +0 -130
  165. package/src/api/messaging/setMessageReaction.js +0 -109
  166. package/src/api/messaging/setTitle.js +0 -124
  167. package/src/api/messaging/shareContact.js +0 -98
  168. package/src/api/messaging/unsendMessage.js +0 -105
  169. package/src/api/messaging/uploadAttachment.js +0 -493
  170. package/src/api/socket/OldMessage.js +0 -199
  171. package/src/api/socket/core/connectMqtt.js +0 -277
  172. package/src/api/socket/core/emitAuth.js +0 -103
  173. package/src/api/socket/core/getSeqID.js +0 -331
  174. package/src/api/socket/core/getTaskResponseData.js +0 -25
  175. package/src/api/socket/core/parseDelta.js +0 -387
  176. package/src/api/socket/detail/buildStream.js +0 -215
  177. package/src/api/socket/detail/constants.js +0 -28
  178. package/src/api/socket/e2ee/crypto.js +0 -173
  179. package/src/api/socket/e2ee/index.js +0 -959
  180. package/src/api/socket/e2ee/localMediaServer.js +0 -59
  181. package/src/api/socket/e2ee/mediaDecode.js +0 -155
  182. package/src/api/socket/e2ee/native/NOTICE.md +0 -29
  183. package/src/api/socket/e2ee/native/nativeMediaBridge.js +0 -273
  184. package/src/api/socket/e2ee/proto/ArmadilloApplication.proto +0 -281
  185. package/src/api/socket/e2ee/proto/ArmadilloICDC.proto +0 -14
  186. package/src/api/socket/e2ee/proto/ConsumerApplication.proto +0 -232
  187. package/src/api/socket/e2ee/proto/MessageApplication.proto +0 -82
  188. package/src/api/socket/e2ee/proto/MessageTransport.proto +0 -77
  189. package/src/api/socket/e2ee/proto/WACommon.proto +0 -66
  190. package/src/api/socket/e2ee/proto/WAMediaTransport.proto +0 -176
  191. package/src/api/socket/e2ee/proto/proto-writer.ts +0 -76
  192. package/src/api/socket/e2ee/protocol.js +0 -196
  193. package/src/api/socket/e2ee/ratchet.js +0 -219
  194. package/src/api/socket/e2ee/store.js +0 -182
  195. package/src/api/socket/e2ee/vendor/fme/dist/index.cjs +0 -6477
  196. package/src/api/socket/e2ee/vendor/fme/proto/ArmadilloApplication.proto +0 -281
  197. package/src/api/socket/e2ee/vendor/fme/proto/ArmadilloICDC.proto +0 -14
  198. package/src/api/socket/e2ee/vendor/fme/proto/ConsumerApplication.proto +0 -232
  199. package/src/api/socket/e2ee/vendor/fme/proto/MessageApplication.proto +0 -82
  200. package/src/api/socket/e2ee/vendor/fme/proto/MessageTransport.proto +0 -77
  201. package/src/api/socket/e2ee/vendor/fme/proto/WACommon.proto +0 -66
  202. package/src/api/socket/e2ee/vendor/fme/proto/WAMediaTransport.proto +0 -176
  203. package/src/api/socket/listenE2EE.js +0 -85
  204. package/src/api/socket/listenMqtt.js +0 -492
  205. package/src/api/socket/middleware/index.js +0 -216
  206. package/src/api/socket/sendMessage.js +0 -331
  207. package/src/api/socket/sendMessageMqtt.js +0 -69
  208. package/src/api/threads/getThreadInfo.js +0 -329
  209. package/src/api/threads/getThreadList.js +0 -293
  210. package/src/api/threads/getThreadPictures.js +0 -78
  211. package/src/api/users/getUserInfo.js +0 -402
  212. package/src/api/users/getUserInfoV2.js +0 -134
  213. package/src/app/MessengerBot.js +0 -209
  214. package/src/app/MessengerContext.js +0 -32
  215. package/src/app/createFcaClient.js +0 -136
  216. package/src/app/threadInfoRealtimeSync.js +0 -284
  217. package/src/core/sendReqMqtt.js +0 -96
  218. package/src/database/helpers.js +0 -53
  219. package/src/database/models/index.js +0 -88
  220. package/src/database/models/thread.js +0 -50
  221. package/src/database/models/user.js +0 -46
  222. package/src/database/threadData.js +0 -94
  223. package/src/database/userData.js +0 -98
  224. package/src/remote/remoteClient.js +0 -123
  225. package/src/utils/antiSuspension.js +0 -219
  226. package/src/utils/broadcast.js +0 -51
  227. package/src/utils/client.js +0 -10
  228. package/src/utils/constants.js +0 -23
  229. package/src/utils/cookies.js +0 -85
  230. package/src/utils/fingerprint.js +0 -101
  231. package/src/utils/format/attachment.js +0 -357
  232. package/src/utils/format/cookie.js +0 -9
  233. package/src/utils/format/date.js +0 -50
  234. package/src/utils/format/decode.js +0 -44
  235. package/src/utils/format/delta.js +0 -195
  236. package/src/utils/format/ids.js +0 -64
  237. package/src/utils/format/index.js +0 -64
  238. package/src/utils/format/message.js +0 -88
  239. package/src/utils/format/presence.js +0 -132
  240. package/src/utils/format/readTyp.js +0 -44
  241. package/src/utils/format/thread.js +0 -42
  242. package/src/utils/format/utils.js +0 -141
  243. package/src/utils/headers.js +0 -125
  244. package/src/utils/humanizer.js +0 -256
  245. package/src/utils/loginParser/autoLogin.js +0 -125
  246. package/src/utils/loginParser/extractDtsg.js +0 -44
  247. package/src/utils/loginParser/helpers.js +0 -43
  248. package/src/utils/loginParser/index.js +0 -10
  249. package/src/utils/loginParser/parseAndCheckLogin.js +0 -241
  250. package/src/utils/loginParser/textUtils.js +0 -28
  251. package/src/utils/nexca-logger.js +0 -144
  252. package/src/utils/nexca-utils.js +0 -687
  253. package/src/utils/request/client.js +0 -26
  254. package/src/utils/request/config.js +0 -23
  255. package/src/utils/request/defaults.js +0 -46
  256. package/src/utils/request/helpers.js +0 -46
  257. package/src/utils/request/index.js +0 -17
  258. package/src/utils/request/methods.js +0 -163
  259. package/src/utils/request/proxy.js +0 -21
  260. package/src/utils/request/retry.js +0 -77
  261. package/src/utils/request/sanitize.js +0 -49
  262. package/src/utils/versionCheck.js +0 -47
  263. /package/{src/api/socket/e2ee/native/build → build}/messagix.dll +0 -0
  264. /package/{src/api/socket/e2ee/native/build → build}/messagix.so +0 -0
package/README.md CHANGED
@@ -1,379 +1,134 @@
1
- <div align="center">
1
+ # hridoy-ultimate v8.0.1
2
2
 
3
- <h1>⚡ toru-ultimate</h1>
3
+ **Ultimate Merged, Fixed & Advanced Facebook Chat API**
4
4
 
5
- <p><b>Unofficial Facebook Messenger bot API for Node.js</b><br>
6
- Stable MQTT core · Signal Protocol E2EE · Session protection · 90+ methods</p>
5
+ > Cookie-based login, session persistence, and MQTT reconnection are best-effort. Server-side logout, checkpoints, and platform restrictions cannot be prevented or guaranteed against by this library.
7
6
 
8
- <p>
9
- <img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen?style=for-the-badge" alt="node">
10
- <img src="https://img.shields.io/badge/E2EE-Signal%20Protocol-6f42c1?style=for-the-badge" alt="e2ee">
11
- <img src="https://img.shields.io/badge/GoatBot-compatible-orange?style=for-the-badge" alt="goatbot">
12
- <img src="https://img.shields.io/badge/license-MIT-blue?style=for-the-badge" alt="license">
13
- </p>
7
+ ---
14
8
 
15
- <p>
16
- <a href="#-quick-start">Quick Start</a> ·
17
- <a href="#-features">Features</a> ·
18
- <a href="#-e2ee">E2EE</a> ·
19
- <a href="#-tools">Tools</a> ·
20
- <a href="#-api-reference">API</a> ·
21
- <a href="#-options">Options</a>
22
- </p>
9
+ ## ✅ Features
23
10
 
24
- </div>
11
+ | Feature | Status |
12
+ |---|---|
13
+ | Session refresh helper (best-effort) | ⚠️ Best-effort only |
14
+ | Conservative presence/delay options | ⚠️ No guarantee |
15
+ | Inbox Smooth (bot inbox reply) | ✅ Active |
16
+ | GoatBot Compatible | ✅ Ready |
17
+ | Session Guard (auto-save) | ✅ Every 3min |
18
+ | fb_dtsg Auto-Refresh | ✅ Every 20min |
19
+ | MQTT Stable Reconnect | ✅ Active |
20
+ | Error reporting | ✅ Host process handlers preserved |
21
+ | E2EE Labyrinth Bridge | ✅ Active |
22
+ | Facebook Protection | ✅ New in v1.0.6 |
23
+ | Human-like Delay | ✅ New in v1.0.6 |
25
24
 
26
25
  ---
27
26
 
28
- ## 🚀 Quick Start
27
+ ## 📦 Install
29
28
 
30
29
  ```bash
31
- npm install toru-ultimate
30
+ npm install
32
31
  ```
33
32
 
34
- > Requires **Node.js 20+**
33
+ ---
34
+
35
+ ## 🚀 Usage (GoatBot / Goat-Bot)
35
36
 
36
- ```javascript
37
- const login = require("toru-ultimate");
37
+ ```js
38
+ const login = require("hridoy-ultimate");
39
+ const fs = require("fs");
38
40
 
39
- login({ appState: require("./account.json") }, { listenEvents: true }, (err, api) => {
40
- if (err) throw err;
41
+ login({ appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) }, {
42
+ listenEvents: true,
43
+ selfListen: false,
44
+ autoReconnect: true,
45
+ online: false
46
+ }, (err, api) => {
47
+ if (err) return console.error(err);
41
48
 
42
- api.sessionGuard("./account.json");
49
+ // Session guard — auto-save appstate
50
+ api.sessionGuard("appstate.json");
43
51
 
44
52
  api.listenMqtt((err, event) => {
45
- if (err) throw err;
46
- if (event.type === "message") api.sendMessage(event.body, event.threadID);
53
+ if (event.type === "message") {
54
+ api.sendMessage("Hello!", event.threadID);
55
+ }
47
56
  });
48
57
  });
49
58
  ```
50
59
 
51
60
  ---
52
61
 
53
- ## ✨ Features
54
-
55
- | | Feature | What you get |
56
- |---|---|---|
57
- | 📡 | **NEXCA MQTT core** | Auto-reconnect with jitter, extended `connectTimeout`, stale-client guard (`isActiveClient()`), fixed subscribe race condition |
58
- | 🔐 | **E2EE** | Real encrypted conversations over Signal Protocol, auto-connects after login |
59
- | 🎞️ | **Native media engine** | Optional mautrix-go engine for reliable E2EE media, reactions and unsend |
60
- | 🛡️ | **sessionGuard** | Auto-save, corruption guard, `.bak` backup, silent-logout protection |
61
- | 🧑 | **Humanizer** | Human-like reply delay, per-thread cooldown, typing indicator |
62
- | 📢 | **sendBroadcast** | Rate-limited, parallel or sequential multi-thread sending |
63
- | 🤖 | **MessengerBot** | Discord.js / Telegraf style: `.command`, `.hears`, `.launch` |
64
- | 🧩 | **createFcaClient** | Namespaced facade: `client.messages`, `client.threads`, `client.users` |
65
- | 🐐 | **GoatBot / Mirai ready** | Drop-in replacement, signatures unchanged (`threadID` optional etc.) |
62
+ ## ⚙️ config.json Options
66
63
 
67
- ---
68
-
69
- ## 🔐 E2EE
70
-
71
- `connectE2EE()` runs **automatically** right after login. Do not call it yourself, a second call opens a racing connection. Check status with `api.e2ee.isConnected()`.
72
-
73
- ```javascript
74
- api.listenE2EE((err, event) => {
75
- if (event.type !== "message") return;
76
- if (event.isE2EE) api.e2ee.sendMessage(event.threadID, "Encrypted reply!");
77
- else api.sendMessage("Normal reply!", event.threadID);
78
- });
79
- ```
80
-
81
- ```javascript
82
- await api.e2ee.sendMessage(threadID, "Hello!");
83
- await api.e2ee.sendMessage(threadID, { body: "Photo!", attachment: fs.createReadStream("photo.jpg") });
84
- await api.e2ee.sendReaction(threadID, messageID, "❤️");
85
- await api.e2ee.sendTyping(threadID, true);
86
- await api.e2ee.unsendMessage(messageID, threadID);
87
- await api.e2ee.editMessage(threadID, messageID, "Updated!");
88
- await api.e2ee.disconnect();
89
- ```
90
-
91
- **GoatBot users:** nothing else to change. `api.sendMessage`, `api.setMessageReaction` and `api.unsendMessage` detect encrypted DMs and route through E2EE internally. If your `login.js` has an explicit `api.connectE2EE()` call, delete it.
92
-
93
- <details>
94
- <summary><b>🎞️ Native media engine (opt-in)</b></summary>
95
-
96
- <br>
97
-
98
- Image, video, audio and document sends, reactions and unsend in E2EE threads can run through a precompiled **mautrix-go / mautrix-meta** binary (`src/api/socket/e2ee/native/`) via `koffi`.
99
-
100
- **Disabled by default.** Both engines register as the same E2EE device, and Facebook keeps only one live socket per device, so running both makes them kick each other in a loop. Enable it only if you accept that churn:
101
-
102
- ```bash
103
- FCA_E2EE_NATIVE=1
104
- ```
105
-
106
- | Mode | Works |
107
- |---|---|
108
- | **Off** (default) | E2EE DM text and DM media via the built-in engine. E2EE group send/receive and markRead unavailable |
109
- | **On** | Adds E2EE group text, native media, reactions, unsend, edit, markRead |
110
-
111
- - Binaries ship for **Linux (.so)** and **Windows (.dll)** x64. On macOS or ARM the load fails and everything falls back to the built-in engine.
112
- - On any native failure the log shows `[native-media] ... falling back to legacy vendor engine`.
113
- - The E2EE socket User-Agent defaults to desktop Windows Chrome 139. Override with `FCA_E2EE_UA`.
114
-
115
- </details>
116
-
117
- <details>
118
- <summary><b>📥 Receiving E2EE media</b></summary>
119
-
120
- <br>
121
-
122
- Incoming encrypted attachments (including replies) are decrypted and served on a short-lived local URL (`http://127.0.0.1:<port>/<token>`, 15 min TTL), then filled into `event.attachments` and `event.messageReply.attachments`, same shape as normal attachments. Reply-based commands work unchanged.
123
-
124
- ```javascript
125
- if (event.messageReply?.attachments.length) {
126
- const url = event.messageReply.attachments[0].url; // works for E2EE too
64
+ ```json
65
+ {
66
+ "antiLogout": { "enabled": true, "refreshIntervalMs": 1200000 },
67
+ "sessionGuard": { "enabled": true, "intervalMs": 180000 },
68
+ "automation": { "enabled": false },
69
+ "smooth": { "enabled": true, "messageDelay": 300 },
70
+ "facebookProtection": { "enabled": true, "blockAutomationDetection": true, "humanLikeDelay": true },
71
+ "inbox": { "enabled": true, "replyToInbox": true }
127
72
  }
128
73
  ```
129
74
 
130
- If media fails, check the console for `[media-resolve]` / `[media-decode]`. You may need to adjust `FB_E2EE_MEDIA_DOWNLOAD_HOST` (default `rupload.facebook.com`).
131
-
132
- </details>
133
-
134
75
  ---
135
76
 
136
- ## 🧰 Tools
137
-
138
- ### 🛡️ sessionGuard
139
-
140
- ```javascript
141
- api.sessionGuard("./account.json", { interval: 3 * 60 * 1000, debounce: 30 * 1000 });
142
-
143
- api.saveSession(); // force save now
144
- api.restoreSessionBackup(); // restore from .bak
145
- api.stopSessionGuard(); // stop the timer
146
- ```
147
-
148
- Saves every N minutes and after each successful send (debounced). Never overwrites a larger appstate with a smaller one, and writes a `.bak` before every overwrite.
149
-
150
- ### 🧑 Humanizer (command anti-spam)
151
-
152
- On by default. Delays command replies, applies a per-thread cooldown, and drops commands sent faster than a human could.
153
-
154
- ```javascript
155
- login({ appState }, {
156
- humanize: {
157
- enabled: true,
158
- reactDelayMs: [2000, 3000], // random delay before a command passes
159
- cooldownMs: 5500, // min gap between accepted commands
160
- resetMs: 10000, // idle time before cooldown resets
161
- maxPerMinute: 20, // global cap
162
- commands: ["/", "!", "."], // prefixes counted as commands
163
- perThread: true
164
- }
165
- }, cb);
166
-
167
- api.setOptions({ humanize: { enabled: false } }); // turn off
168
- ```
169
-
170
- Under GoatBot it also detects no-prefix admin commands, `onChat` triggers and `onReply` flows automatically. For anything else:
171
-
172
- ```javascript
173
- const h = api.getHumanizer();
174
- h.setMatcher((event) => event.body === "my trigger");
175
- h.stats(); // accepted / dropped counters
176
- h.reset(); // clear cooldown state
177
- ```
178
-
179
- The typing indicator and reply delay are the same window, not two stacked waits.
180
-
181
- ### 📢 sendBroadcast
182
-
183
- ```javascript
184
- const result = await api.sendBroadcast("Hello everyone!", ["T1", "T2", "T3"], {
185
- delay: 2000,
186
- parallel: 2,
187
- onEach: (err, info, id) => console.log(err ? "Failed: " + id : "Sent: " + id)
188
- });
189
- console.log(`${result.sent.length}/${result.total} delivered`);
190
- ```
191
-
192
- ### 🤖 MessengerBot
193
-
194
- ```javascript
195
- const { createMessengerBot } = require("toru-ultimate");
196
-
197
- const bot = await createMessengerBot(
198
- { appState: require("./account.json") },
199
- { commandPrefix: "/", stopOnSignals: true }
200
- );
77
+ ## 🔐 Anti-Logout System
201
78
 
202
- bot.command("ping", async ctx => await ctx.replyAsync("pong 🏓"));
203
- bot.hears(/hello/i, async ctx => await ctx.replyAsync("Hi! 👋"));
204
- bot.on("messageCreate", event => console.log(event.body));
205
-
206
- await bot.launch({ stopOnSignals: true });
207
- ```
208
-
209
- ### 🧩 createFcaClient
210
-
211
- ```javascript
212
- const { createFcaClient } = require("toru-ultimate");
213
- const client = createFcaClient(api);
214
-
215
- await client.messages.send("Hello!", threadID);
216
- await client.messages.react("❤️", messageID, threadID);
217
- await client.threads.getInfo(threadID);
218
- await client.users.getInfo(userID);
219
- await client.account.refreshDtsg();
220
- ```
79
+ Cookie login করলে `api.logout()` automatically blocked হয়।
80
+ - Session refresh does not guarantee that Facebook will preserve a login session
81
+ - `api.logout()` is currently overridden; use `api.forceLogout()` only when you explicitly intend to terminate the session
82
+ - Force logout দরকার হলে: `api.forceLogout()`
83
+ - Anti-logout বন্ধ করতে: `api.stopAntiLogout()`
221
84
 
222
85
  ---
223
86
 
224
- ## 📖 API Reference
225
-
226
- <details open>
227
- <summary><b>💬 Messages</b></summary>
228
-
229
- ```javascript
230
- api.sendMessage("Hello!", threadID);
231
- api.sendMessage({ body: "Photo!", attachment: fs.createReadStream("photo.jpg") }, threadID);
232
- api.sendMessage({ body: "Hey @John", mentions: [{ id: "uid", tag: "@John", fromIndex: 4 }] }, threadID);
233
- api.sendMessage({ sticker: "369239263222822" }, threadID);
234
- api.sendMessage({ location: { latitude: 23.8, longitude: 90.4, current: true } }, threadID);
235
- api.sendGif("https://media.giphy.com/xyz.gif", threadID);
236
- api.sendLocation(23.8, 90.4, threadID);
237
- api.sendImage("./photo.jpg", threadID, "caption");
238
- api.sendVideo("./video.mp4", threadID);
239
- api.sendAudio("./voice.ogg", threadID);
240
- api.sendFile("./doc.pdf", threadID);
241
- api.shareLink("https://github.com", threadID, "Check this!");
242
- api.shareContact("Meet my friend!", userID, threadID);
243
-
244
- api.editMessage("Updated text", messageID);
245
- api.unsendMessage(messageID);
246
- api.deleteMessage([messageID]);
247
- api.setMessageReaction("😍", messageID, threadID); // threadID optional
248
- api.setMessageReaction("", messageID); // remove reaction
249
- api.getMessage(threadID, messageID);
250
- api.forwardAttachment(attachmentID, [userID]);
251
- api.uploadAttachment([fs.createReadStream("photo.jpg")]);
252
- ```
253
-
254
- </details>
87
+ ## 📊 API Methods
255
88
 
256
- <details>
257
- <summary><b>👁️ Read receipts & typing</b></summary>
258
-
259
- ```javascript
260
- api.markAsRead(threadID);
261
- api.markAsReadAll();
262
- api.markAsDelivered(threadID, messageID);
263
- api.markAsSeen();
264
- api.sendTypingIndicator(threadID, true);
265
- ```
266
-
267
- </details>
268
-
269
- <details>
270
- <summary><b>🧵 Threads & groups</b></summary>
271
-
272
- ```javascript
273
- api.getThreadInfo(threadID);
274
- api.getThreadList(10, null, ["INBOX"]);
275
- api.getThreadHistory(threadID, 20);
276
- api.createGroup("Hey!", ["uid1", "uid2"]);
277
- api.deleteThread(threadID);
278
- api.muteThread(threadID, 3600);
279
- api.changeArchivedStatus(threadID, true);
280
- api.handleMessageRequest(threadID, true);
281
- api.searchForThread("query");
282
-
283
- api.setTitle("New Name", threadID);
284
- api.changeThreadColor("#0084FF", threadID);
285
- api.changeThreadEmoji("🔥", threadID);
286
- api.changeNickname("The Boss", threadID, userID);
287
- api.changeGroupImage(fs.createReadStream("group.jpg"), threadID);
288
- api.changeAdminStatus(threadID, userID, true);
289
- api.addUserToGroup(userID, threadID);
290
- api.removeUserFromGroup(userID, threadID);
291
- api.createPoll("Question?", threadID, { "Yes": false, "No": false });
292
- api.pinMessage(messageID, threadID);
293
- api.unpinMessage(messageID, threadID);
294
- ```
295
-
296
- </details>
297
-
298
- <details>
299
- <summary><b>👤 Users & social</b></summary>
300
-
301
- ```javascript
302
- api.getUserInfo(userID);
303
- api.getUserID("John Doe", callback);
304
- api.getUID("https://facebook.com/zuck");
305
- api.getFriendsList();
306
- api.getAvatarUser(userID);
307
- api.getProfileInfo(userID);
308
- api.getPublicData(userID);
309
- api.sendFriendRequest(userID);
310
- api.handleFriendRequest(userID, true);
311
- api.changeBlockedStatus(userID, true);
312
- api.followUser(userID);
313
- api.unfollowUser(userID);
314
- api.unfriend(userID);
315
-
316
- api.reactToPost(postID, "love");
317
- api.reactToComment(commentID, "haha");
318
- api.postComment(postID, "Great post!");
319
- api.sharePost(postID, "Check this!");
320
- ```
321
-
322
- </details>
323
-
324
- <details>
325
- <summary><b>⚙️ Account, config & HTTP</b></summary>
326
-
327
- ```javascript
328
- api.getCurrentUserID();
329
- api.getAppState();
330
- api.setOptions({ listenTyping: true });
331
- api.logout();
332
- api.refreshFb_dtsg();
333
- api.addExternalModule("myFunc", (defaultFuncs, api, ctx) => {
334
- return (text, threadID) => api.sendMessage("[BOT] " + text, threadID);
335
- });
336
-
337
- api.httpGet(url, params, callback);
338
- api.httpPost(url, form, callback);
339
- api.httpPostFormData(url, form, callback);
340
- api.uploadImageToImgbb(imageUrl);
341
- ```
342
-
343
- </details>
344
-
345
- ---
346
-
347
- ## 📋 Options
348
-
349
- | Option | Type | Default | Description |
350
- |---|---|---|---|
351
- | `selfListen` | boolean | `false` | Receive your own sent messages |
352
- | `listenEvents` | boolean | `true` | Receive thread/group events |
353
- | `listenTyping` | boolean | `false` | Receive typing events |
354
- | `updatePresence` | boolean | `false` | Receive online/offline presence |
355
- | `autoMarkDelivery` | boolean | `false` | Auto-mark incoming as delivered |
356
- | `autoMarkRead` | boolean | `false` | Auto-mark threads as read |
357
- | `autoReconnect` | boolean | `true` | Reconnect MQTT on disconnect |
358
- | `online` | boolean | `false` | Appear online to others |
359
- | `emitReady` | boolean | `false` | Emit a ready event when MQTT connects |
360
- | `proxy` | string | none | HTTP proxy URL |
361
- | `userAgent` | string | Safari UA | Override HTTP User-Agent |
89
+ | Method | Description |
90
+ |---|---|
91
+ | `api.sendMessage(msg, threadID)` | Message পাঠাও |
92
+ | `api.listenMqtt(callback)` | Message শোনো |
93
+ | `api.sessionGuard(path, opts)` | Appstate auto-save |
94
+ | `api.saveSession(path)` | Manual session save |
95
+ | `api.getHealth()` | MQTT + session health |
96
+ | `api.forceLogout()` | Force logout (opt-in) |
97
+ | `api.stopAntiLogout()` | Anti-logout timer বন্ধ |
98
+ | `api.refreshFb_dtsg()` | Manual fb_dtsg refresh |
99
+ | `api.sendTypingIndicatorV2(typing, threadID)` | MQTT typing indicator |
362
100
 
363
101
  ---
364
102
 
365
- ## 📄 License
103
+ ## 🛡️ Facebook Protection (v1.0.6)
366
104
 
367
- MIT. **toru-ultimate** by **HR ID OY**.
105
+ - `humanLikeDelay: true` — প্রতিটি message এ random 50-200ms delay, bot traffic pattern unpredictable
106
+ - `blockAutomationDetection: true` — online=false, presence update বন্ধ
107
+ - ফলে Facebook account এ restriction বা ban আসে না
368
108
 
369
- NEXCA MQTT core by [Deku](https://github.com/dekuzxc) (MIT).
370
-
371
- > The native E2EE media engine bundles a precompiled binary built from **mautrix-go / mautrix-meta**, © Tulir Asokan and contributors, licensed under **MPL-2.0** (not MIT). See `src/api/socket/e2ee/native/NOTICE.md`. This notice must be preserved in any redistribution.
372
-
373
- <div align="center">
374
-
375
- <br>
376
-
377
- Made with ❤️ by **HR ID OY**
109
+ ---
378
110
 
379
- </div>
111
+ **hridoy-ultimate v8.0.1** — Built on toru-fca 1.2.0 (itself derived from HRIDOY-FCA / ST-FCA). Other packages were analysed and only selected ideas were ported — see ANALYSIS.md
112
+
113
+
114
+ ## What's new in v1.2.4
115
+ - **Critical fix:** MQTT auto-reconnect crashed with `ReferenceError: getSeqID is not defined` (the reconnect timer called a function that lives in another scope). The factory now exposes it as `ctx._getSeqID` and the timer uses that, guarded by try/catch.
116
+ - `changeCover`: missing `npmlog` import (ReferenceError on every error path) fixed.
117
+ - `createCommentPost`: fixed `calback` typo (crash whenever a callback was passed), undefined `image` in the attachment error, and failures that *resolved* with the error object instead of rejecting.
118
+ - `package.json`: declared `form-data` and `https-proxy-agent` (both were required but missing); removed unused `chalk`, `tough-cookie`, `protobufjs`.
119
+ - `checkUpdate` now reads its version from `package.json` (was hard-coded 1.2.1). Example config version synced. CRLF line endings normalised to LF.
120
+ - New `npm run check` (syntax + relative/undeclared require check on every file) and regression tests in `test/fixes-1_2_4.test.js`.
121
+
122
+ ## Earlier: v1.2.3
123
+ - **Reactions:** `message_reaction` events now carry `off`, `action` ("add"/"remove"), `userID` (reactor), `isGroup`, `isSingleUser` (inbox vs group) and are null-safe. `selfListen:false` also ignores the bot's own reactions.
124
+ - **api.setMessageReactionSafe(reaction, messageID, threadID, opts):** MQTT first, HTTP fallback with retry (idea from shadowx `setMessageReactionv2`). `setMessageReaction` now accepts any real emoji and no longer crashes on retry/redirect (it passed `ctx.jar` instead of `ctx` to `parseAndCheckLogin`; same bug fixed in `forwardAttachment`).
125
+ - **api.setMessageReactionMqtt:** the old `isCallable()` helper *called* your callback with no arguments and the call could throw synchronously. Fixed; supports callbacks and Promises; real ack via `/ls_resp`.
126
+ - **MQTT stability:** events from replaced clients are ignored (no double-reconnect loops), a failed `getSeqID` during reconnect now retries with backoff instead of silently killing the listener, spinner only draws on a TTY.
127
+ - **Session safety:** cookie-expiry extension now really works (v1.2.0 edited a throw-away copy). Login callback can no longer fire twice.
128
+ - **Errors:** uncaught exceptions are still non-fatal but now print the stack instead of hiding it.
129
+ - E2EE is off by default (needs the native `messagix` binary which is not bundled).
130
+ - Update check never installs anything; disable with `HRIDOY_ULTIMATE_NO_UPDATE_CHECK=1` (old `TORU_FCA_NO_UPDATE_CHECK` still works).
131
+
132
+ ## Honest notes
133
+ - Login: use `appState` (cookie array / cookie string). `api.logout()` is blocked on purpose; use `api.forceLogout()` if you really want to log out.
134
+ - "Facebook protection" (online=false, small delays) only lowers noise. No library can guarantee Facebook will not flag or checkpoint an account that is driven by a bot.
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * AdvancedSystem — minimal queue + health monitor for alpha-fca.
5
+ * Automation is OFF by default. No background polling, no aggressive requests.
6
+ * Only runs tasks you explicitly enqueue.
7
+ */
8
+
9
+ const EventEmitter = require("events");
10
+
11
+ class AdvancedSystem extends EventEmitter {
12
+ constructor(options) {
13
+ super();
14
+ options = options || {};
15
+ this.options = Object.assign({
16
+ automationEnabled: false,
17
+ minDelayMs: 1000,
18
+ maxDelayMs: 30000,
19
+ maxQueue: 50
20
+ }, options);
21
+ this.startedAt = Date.now();
22
+ this._queue = [];
23
+ this._running = false;
24
+ this._stats = { enqueued: 0, completed: 0, failed: 0 };
25
+ }
26
+
27
+ /** @returns {boolean} */
28
+ isAutomationEnabled() {
29
+ return this.options.automationEnabled === true;
30
+ }
31
+
32
+ /** Explicit opt-in only — no background automation started automatically. */
33
+ setAutomationEnabled(enabled) {
34
+ this.options.automationEnabled = Boolean(enabled);
35
+ this.emit("automation", this.options.automationEnabled);
36
+ return this.options.automationEnabled;
37
+ }
38
+
39
+ /** Health snapshot — safe to call anytime. */
40
+ health(api) {
41
+ const mqttClient = api && (api.mqttClient || (api.ctx && api.ctx.mqttClient));
42
+ return {
43
+ version: "1.0.0",
44
+ uptimeMs: Date.now() - this.startedAt,
45
+ automationEnabled: this.isAutomationEnabled(),
46
+ inboxEnabled: true,
47
+ mqtt: mqttClient ? {
48
+ connected: Boolean(mqttClient.connected),
49
+ reconnecting: Boolean(mqttClient.reconnecting)
50
+ } : null,
51
+ queue: { size: this._queue.length, running: this._running },
52
+ stats: Object.assign({}, this._stats)
53
+ };
54
+ }
55
+
56
+ /**
57
+ * Enqueue a task function. Runs sequentially.
58
+ * @param {Function} task async () => result
59
+ * @returns {Promise<any>}
60
+ */
61
+ enqueue(task) {
62
+ if (typeof task !== "function") return Promise.reject(new TypeError("task must be a function"));
63
+ if (this._queue.length >= this.options.maxQueue) {
64
+ return Promise.reject(new Error("AdvancedSystem queue is full (" + this.options.maxQueue + ")"));
65
+ }
66
+ this._stats.enqueued++;
67
+ return new Promise((resolve, reject) => {
68
+ this._queue.push({ task, resolve, reject });
69
+ this._drain();
70
+ });
71
+ }
72
+
73
+ async _drain() {
74
+ if (this._running || this._queue.length === 0) return;
75
+ this._running = true;
76
+ while (this._queue.length > 0) {
77
+ const { task, resolve, reject } = this._queue.shift();
78
+ try {
79
+ const result = await task();
80
+ this._stats.completed++;
81
+ resolve(result);
82
+ } catch (err) {
83
+ this._stats.failed++;
84
+ reject(err);
85
+ }
86
+ // Small throttle between tasks to avoid burst requests
87
+ if (this._queue.length > 0) {
88
+ await new Promise(r => setTimeout(r, this.options.minDelayMs));
89
+ }
90
+ }
91
+ this._running = false;
92
+ }
93
+ }
94
+
95
+ module.exports = AdvancedSystem;
package/checkUpdate.js ADDED
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ // v1.2.4: read from package.json so the notice can never drift from the real version.
4
+ const CURRENT_VERSION = (function () {
5
+ try { return require("./package.json").version; } catch (_) { return "0.0.0"; }
6
+ })();
7
+
8
+ async function checkForFCAUpdate() {
9
+ try {
10
+ if (process.env.HRIDOY_ULTIMATE_NO_UPDATE_CHECK || process.env.TORU_FCA_NO_UPDATE_CHECK) return; // v1.2.1: opt-out, never auto-installs anything
11
+ const https = require("https");
12
+
13
+ const data = await new Promise(function(resolve) {
14
+ var req = https.get(
15
+ "https://registry.npmjs.org/hridoy-ultimate/latest",
16
+ { timeout: 5000 },
17
+ function(res) {
18
+ var body = "";
19
+ res.on("data", function(c) { body += c; });
20
+ res.on("end", function() {
21
+ try { resolve(JSON.parse(body)); } catch (_) { resolve(null); }
22
+ });
23
+ res.on("error", function() { resolve(null); });
24
+ }
25
+ );
26
+ req.on("error", function() { resolve(null); });
27
+ // Destroy on timeout to avoid hanging socket
28
+ req.on("timeout", function() { req.destroy(); resolve(null); });
29
+ // Hard abort after 8s as a belt-and-suspenders guard
30
+ var hard = setTimeout(function() { try { req.destroy(); } catch (_) {} resolve(null); }, 8000);
31
+ if (hard.unref) hard.unref();
32
+ });
33
+
34
+ if (data && data.version && data.version !== CURRENT_VERSION) {
35
+ var log = require("npmlog");
36
+ log.warn(
37
+ "hridoy-ultimate",
38
+ "Update available: v" + CURRENT_VERSION + " \u2192 v" + data.version +
39
+ " \u2014 npm update hridoy-ultimate"
40
+ );
41
+ }
42
+ } catch (_) {
43
+ // Non-fatal; version check is best-effort only
44
+ }
45
+ }
46
+
47
+ module.exports = { checkForFCAUpdate, CURRENT_VERSION };
package/config.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "_info": "hridoy-ultimate v8.0.1 \u2014 Main Config",
3
+ "version": "1.2.4",
4
+ "antiLogout": {
5
+ "enabled": true,
6
+ "refreshIntervalMs": 1200000,
7
+ "_note": "Periodically refreshes fb_dtsg when supported; this cannot guarantee session persistence or prevent server-side logout."
8
+ },
9
+ "sessionGuard": {
10
+ "enabled": true,
11
+ "intervalMs": 180000,
12
+ "debounceMs": 20000,
13
+ "backupEnabled": true,
14
+ "_note": "Periodically saves valid appstate and a backup. Cookie expiry changes cannot override server-side session expiry."
15
+ },
16
+ "automation": {
17
+ "enabled": false,
18
+ "_note": "KEEP FALSE. Disables background automation. Protects against Facebook restrictions."
19
+ },
20
+ "smooth": {
21
+ "enabled": true,
22
+ "messageDelay": 300,
23
+ "_note": "Shows typing indicator before sending. 300ms delay for human-like behavior."
24
+ },
25
+ "connection": {
26
+ "minDelayMs": 3000,
27
+ "maxDelayMs": 60000,
28
+ "_note": "MQTT reconnect exponential backoff range."
29
+ },
30
+ "e2ee": {
31
+ "enable": true,
32
+ "saveType": "memory",
33
+ "devicePath": "./data/e2ee-device.json",
34
+ "autoReconnect": true,
35
+ "logLevel": "none",
36
+ "_note": "E2EE Labyrinth bridge. Needs the native build/messagix binary (not bundled). Keep false unless you add it."
37
+ },
38
+ "facebookProtection": {
39
+ "enabled": true,
40
+ "blockAutomationDetection": true,
41
+ "humanLikeDelay": true,
42
+ "_note": "Optional request delays and conservative presence settings; no method can guarantee avoidance of platform restrictions."
43
+ },
44
+ "inbox": {
45
+ "enabled": true,
46
+ "replyToInbox": true,
47
+ "_note": "Bot replies in both inbox/DM and group threads."
48
+ },
49
+ "enableTypingIndicator": false,
50
+ "typingDuration": 4000
51
+ }