zai-fca 1.0.8-beta

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.

Potentially problematic release.


This version of zai-fca might be problematic. Click here for more details.

Files changed (290) hide show
  1. package/.cache/replit/env/latest +56 -0
  2. package/.cache/replit/env/latest.json +1 -0
  3. package/.cache/replit/modules/nodejs-20.res +1 -0
  4. package/.cache/replit/modules/replit.res +1 -0
  5. package/.cache/replit/modules.stamp +0 -0
  6. package/.cache/typescript/5.6/node_modules/.package-lock.json +178 -0
  7. package/.cache/typescript/5.6/node_modules/@types/bluebird/LICENSE +21 -0
  8. package/.cache/typescript/5.6/node_modules/@types/bluebird/README.md +15 -0
  9. package/.cache/typescript/5.6/node_modules/@types/bluebird/index.d.ts +1365 -0
  10. package/.cache/typescript/5.6/node_modules/@types/bluebird/package.json +25 -0
  11. package/.cache/typescript/5.6/node_modules/@types/caseless/LICENSE +21 -0
  12. package/.cache/typescript/5.6/node_modules/@types/caseless/README.md +48 -0
  13. package/.cache/typescript/5.6/node_modules/@types/caseless/index.d.ts +29 -0
  14. package/.cache/typescript/5.6/node_modules/@types/caseless/package.json +35 -0
  15. package/.cache/typescript/5.6/node_modules/@types/mocha/LICENSE +21 -0
  16. package/.cache/typescript/5.6/node_modules/@types/mocha/README.md +15 -0
  17. package/.cache/typescript/5.6/node_modules/@types/mocha/index.d.ts +2929 -0
  18. package/.cache/typescript/5.6/node_modules/@types/mocha/package.json +56 -0
  19. package/.cache/typescript/5.6/node_modules/@types/node/LICENSE +21 -0
  20. package/.cache/typescript/5.6/node_modules/@types/node/README.md +15 -0
  21. package/.cache/typescript/5.6/node_modules/@types/node/assert/strict.d.ts +8 -0
  22. package/.cache/typescript/5.6/node_modules/@types/node/assert.d.ts +1040 -0
  23. package/.cache/typescript/5.6/node_modules/@types/node/async_hooks.d.ts +541 -0
  24. package/.cache/typescript/5.6/node_modules/@types/node/buffer.buffer.d.ts +385 -0
  25. package/.cache/typescript/5.6/node_modules/@types/node/buffer.d.ts +1933 -0
  26. package/.cache/typescript/5.6/node_modules/@types/node/child_process.d.ts +1549 -0
  27. package/.cache/typescript/5.6/node_modules/@types/node/cluster.d.ts +579 -0
  28. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
  29. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/index.d.ts +9 -0
  30. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/indexable.d.ts +23 -0
  31. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
  32. package/.cache/typescript/5.6/node_modules/@types/node/console.d.ts +452 -0
  33. package/.cache/typescript/5.6/node_modules/@types/node/constants.d.ts +19 -0
  34. package/.cache/typescript/5.6/node_modules/@types/node/crypto.d.ts +4475 -0
  35. package/.cache/typescript/5.6/node_modules/@types/node/dgram.d.ts +596 -0
  36. package/.cache/typescript/5.6/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
  37. package/.cache/typescript/5.6/node_modules/@types/node/dns/promises.d.ts +476 -0
  38. package/.cache/typescript/5.6/node_modules/@types/node/dns.d.ts +865 -0
  39. package/.cache/typescript/5.6/node_modules/@types/node/dom-events.d.ts +124 -0
  40. package/.cache/typescript/5.6/node_modules/@types/node/domain.d.ts +170 -0
  41. package/.cache/typescript/5.6/node_modules/@types/node/events.d.ts +931 -0
  42. package/.cache/typescript/5.6/node_modules/@types/node/fs/promises.d.ts +1275 -0
  43. package/.cache/typescript/5.6/node_modules/@types/node/fs.d.ts +4396 -0
  44. package/.cache/typescript/5.6/node_modules/@types/node/globals.d.ts +566 -0
  45. package/.cache/typescript/5.6/node_modules/@types/node/globals.typedarray.d.ts +21 -0
  46. package/.cache/typescript/5.6/node_modules/@types/node/http.d.ts +1958 -0
  47. package/.cache/typescript/5.6/node_modules/@types/node/http2.d.ts +2558 -0
  48. package/.cache/typescript/5.6/node_modules/@types/node/https.d.ts +543 -0
  49. package/.cache/typescript/5.6/node_modules/@types/node/index.d.ts +92 -0
  50. package/.cache/typescript/5.6/node_modules/@types/node/inspector.d.ts +3966 -0
  51. package/.cache/typescript/5.6/node_modules/@types/node/module.d.ts +402 -0
  52. package/.cache/typescript/5.6/node_modules/@types/node/net.d.ts +1001 -0
  53. package/.cache/typescript/5.6/node_modules/@types/node/os.d.ts +495 -0
  54. package/.cache/typescript/5.6/node_modules/@types/node/package.json +220 -0
  55. package/.cache/typescript/5.6/node_modules/@types/node/path.d.ts +200 -0
  56. package/.cache/typescript/5.6/node_modules/@types/node/perf_hooks.d.ts +965 -0
  57. package/.cache/typescript/5.6/node_modules/@types/node/process.d.ts +1963 -0
  58. package/.cache/typescript/5.6/node_modules/@types/node/punycode.d.ts +117 -0
  59. package/.cache/typescript/5.6/node_modules/@types/node/querystring.d.ts +153 -0
  60. package/.cache/typescript/5.6/node_modules/@types/node/readline/promises.d.ts +162 -0
  61. package/.cache/typescript/5.6/node_modules/@types/node/readline.d.ts +589 -0
  62. package/.cache/typescript/5.6/node_modules/@types/node/repl.d.ts +430 -0
  63. package/.cache/typescript/5.6/node_modules/@types/node/sea.d.ts +153 -0
  64. package/.cache/typescript/5.6/node_modules/@types/node/sqlite.d.ts +213 -0
  65. package/.cache/typescript/5.6/node_modules/@types/node/stream/consumers.d.ts +12 -0
  66. package/.cache/typescript/5.6/node_modules/@types/node/stream/promises.d.ts +90 -0
  67. package/.cache/typescript/5.6/node_modules/@types/node/stream/web.d.ts +609 -0
  68. package/.cache/typescript/5.6/node_modules/@types/node/stream.d.ts +1726 -0
  69. package/.cache/typescript/5.6/node_modules/@types/node/string_decoder.d.ts +67 -0
  70. package/.cache/typescript/5.6/node_modules/@types/node/test.d.ts +2248 -0
  71. package/.cache/typescript/5.6/node_modules/@types/node/timers/promises.d.ts +97 -0
  72. package/.cache/typescript/5.6/node_modules/@types/node/timers.d.ts +240 -0
  73. package/.cache/typescript/5.6/node_modules/@types/node/tls.d.ts +1226 -0
  74. package/.cache/typescript/5.6/node_modules/@types/node/trace_events.d.ts +197 -0
  75. package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +385 -0
  76. package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +19 -0
  77. package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/index.d.ts +92 -0
  78. package/.cache/typescript/5.6/node_modules/@types/node/tty.d.ts +208 -0
  79. package/.cache/typescript/5.6/node_modules/@types/node/url.d.ts +972 -0
  80. package/.cache/typescript/5.6/node_modules/@types/node/util.d.ts +2371 -0
  81. package/.cache/typescript/5.6/node_modules/@types/node/v8.d.ts +808 -0
  82. package/.cache/typescript/5.6/node_modules/@types/node/vm.d.ts +976 -0
  83. package/.cache/typescript/5.6/node_modules/@types/node/wasi.d.ts +181 -0
  84. package/.cache/typescript/5.6/node_modules/@types/node/worker_threads.d.ts +745 -0
  85. package/.cache/typescript/5.6/node_modules/@types/node/zlib.d.ts +539 -0
  86. package/.cache/typescript/5.6/node_modules/@types/node-cron/LICENSE +21 -0
  87. package/.cache/typescript/5.6/node_modules/@types/node-cron/README.md +76 -0
  88. package/.cache/typescript/5.6/node_modules/@types/node-cron/index.d.ts +57 -0
  89. package/.cache/typescript/5.6/node_modules/@types/node-cron/package.json +50 -0
  90. package/.cache/typescript/5.6/node_modules/@types/npmlog/LICENSE +21 -0
  91. package/.cache/typescript/5.6/node_modules/@types/npmlog/README.md +15 -0
  92. package/.cache/typescript/5.6/node_modules/@types/npmlog/index.d.ts +84 -0
  93. package/.cache/typescript/5.6/node_modules/@types/npmlog/package.json +32 -0
  94. package/.cache/typescript/5.6/node_modules/@types/request/LICENSE +21 -0
  95. package/.cache/typescript/5.6/node_modules/@types/request/README.md +15 -0
  96. package/.cache/typescript/5.6/node_modules/@types/request/index.d.ts +395 -0
  97. package/.cache/typescript/5.6/node_modules/@types/request/package.json +70 -0
  98. package/.cache/typescript/5.6/node_modules/@types/tough-cookie/LICENSE +21 -0
  99. package/.cache/typescript/5.6/node_modules/@types/tough-cookie/README.md +15 -0
  100. package/.cache/typescript/5.6/node_modules/@types/tough-cookie/index.d.ts +321 -0
  101. package/.cache/typescript/5.6/node_modules/@types/tough-cookie/package.json +35 -0
  102. package/.cache/typescript/5.6/node_modules/asynckit/LICENSE +21 -0
  103. package/.cache/typescript/5.6/node_modules/asynckit/README.md +233 -0
  104. package/.cache/typescript/5.6/node_modules/asynckit/bench.js +76 -0
  105. package/.cache/typescript/5.6/node_modules/asynckit/index.js +6 -0
  106. package/.cache/typescript/5.6/node_modules/asynckit/lib/abort.js +29 -0
  107. package/.cache/typescript/5.6/node_modules/asynckit/lib/async.js +34 -0
  108. package/.cache/typescript/5.6/node_modules/asynckit/lib/defer.js +26 -0
  109. package/.cache/typescript/5.6/node_modules/asynckit/lib/iterate.js +75 -0
  110. package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_asynckit.js +91 -0
  111. package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_parallel.js +25 -0
  112. package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_serial.js +25 -0
  113. package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
  114. package/.cache/typescript/5.6/node_modules/asynckit/lib/state.js +37 -0
  115. package/.cache/typescript/5.6/node_modules/asynckit/lib/streamify.js +141 -0
  116. package/.cache/typescript/5.6/node_modules/asynckit/lib/terminator.js +29 -0
  117. package/.cache/typescript/5.6/node_modules/asynckit/package.json +63 -0
  118. package/.cache/typescript/5.6/node_modules/asynckit/parallel.js +43 -0
  119. package/.cache/typescript/5.6/node_modules/asynckit/serial.js +17 -0
  120. package/.cache/typescript/5.6/node_modules/asynckit/serialOrdered.js +75 -0
  121. package/.cache/typescript/5.6/node_modules/asynckit/stream.js +21 -0
  122. package/.cache/typescript/5.6/node_modules/combined-stream/License +19 -0
  123. package/.cache/typescript/5.6/node_modules/combined-stream/Readme.md +138 -0
  124. package/.cache/typescript/5.6/node_modules/combined-stream/lib/combined_stream.js +208 -0
  125. package/.cache/typescript/5.6/node_modules/combined-stream/package.json +25 -0
  126. package/.cache/typescript/5.6/node_modules/combined-stream/yarn.lock +17 -0
  127. package/.cache/typescript/5.6/node_modules/delayed-stream/License +19 -0
  128. package/.cache/typescript/5.6/node_modules/delayed-stream/Makefile +7 -0
  129. package/.cache/typescript/5.6/node_modules/delayed-stream/Readme.md +141 -0
  130. package/.cache/typescript/5.6/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
  131. package/.cache/typescript/5.6/node_modules/delayed-stream/package.json +27 -0
  132. package/.cache/typescript/5.6/node_modules/form-data/License +19 -0
  133. package/.cache/typescript/5.6/node_modules/form-data/Readme.md +350 -0
  134. package/.cache/typescript/5.6/node_modules/form-data/index.d.ts +51 -0
  135. package/.cache/typescript/5.6/node_modules/form-data/lib/browser.js +2 -0
  136. package/.cache/typescript/5.6/node_modules/form-data/lib/form_data.js +484 -0
  137. package/.cache/typescript/5.6/node_modules/form-data/lib/populate.js +10 -0
  138. package/.cache/typescript/5.6/node_modules/form-data/package.json +72 -0
  139. package/.cache/typescript/5.6/node_modules/mime-db/HISTORY.md +507 -0
  140. package/.cache/typescript/5.6/node_modules/mime-db/LICENSE +23 -0
  141. package/.cache/typescript/5.6/node_modules/mime-db/README.md +100 -0
  142. package/.cache/typescript/5.6/node_modules/mime-db/db.json +8519 -0
  143. package/.cache/typescript/5.6/node_modules/mime-db/index.js +12 -0
  144. package/.cache/typescript/5.6/node_modules/mime-db/package.json +60 -0
  145. package/.cache/typescript/5.6/node_modules/mime-types/HISTORY.md +397 -0
  146. package/.cache/typescript/5.6/node_modules/mime-types/LICENSE +23 -0
  147. package/.cache/typescript/5.6/node_modules/mime-types/README.md +113 -0
  148. package/.cache/typescript/5.6/node_modules/mime-types/index.js +188 -0
  149. package/.cache/typescript/5.6/node_modules/mime-types/package.json +44 -0
  150. package/.cache/typescript/5.6/node_modules/safe-buffer/LICENSE +21 -0
  151. package/.cache/typescript/5.6/node_modules/safe-buffer/README.md +584 -0
  152. package/.cache/typescript/5.6/node_modules/safe-buffer/index.d.ts +187 -0
  153. package/.cache/typescript/5.6/node_modules/safe-buffer/index.js +65 -0
  154. package/.cache/typescript/5.6/node_modules/safe-buffer/package.json +51 -0
  155. package/.cache/typescript/5.6/node_modules/types-registry/README.md +2 -0
  156. package/.cache/typescript/5.6/node_modules/types-registry/index.json +1 -0
  157. package/.cache/typescript/5.6/node_modules/types-registry/package.json +20 -0
  158. package/.cache/typescript/5.6/node_modules/undici-types/LICENSE +21 -0
  159. package/.cache/typescript/5.6/node_modules/undici-types/README.md +6 -0
  160. package/.cache/typescript/5.6/node_modules/undici-types/agent.d.ts +31 -0
  161. package/.cache/typescript/5.6/node_modules/undici-types/api.d.ts +43 -0
  162. package/.cache/typescript/5.6/node_modules/undici-types/balanced-pool.d.ts +29 -0
  163. package/.cache/typescript/5.6/node_modules/undici-types/cache.d.ts +36 -0
  164. package/.cache/typescript/5.6/node_modules/undici-types/client.d.ts +108 -0
  165. package/.cache/typescript/5.6/node_modules/undici-types/connector.d.ts +34 -0
  166. package/.cache/typescript/5.6/node_modules/undici-types/content-type.d.ts +21 -0
  167. package/.cache/typescript/5.6/node_modules/undici-types/cookies.d.ts +28 -0
  168. package/.cache/typescript/5.6/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
  169. package/.cache/typescript/5.6/node_modules/undici-types/dispatcher.d.ts +255 -0
  170. package/.cache/typescript/5.6/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
  171. package/.cache/typescript/5.6/node_modules/undici-types/errors.d.ts +149 -0
  172. package/.cache/typescript/5.6/node_modules/undici-types/eventsource.d.ts +61 -0
  173. package/.cache/typescript/5.6/node_modules/undici-types/fetch.d.ts +209 -0
  174. package/.cache/typescript/5.6/node_modules/undici-types/file.d.ts +39 -0
  175. package/.cache/typescript/5.6/node_modules/undici-types/filereader.d.ts +54 -0
  176. package/.cache/typescript/5.6/node_modules/undici-types/formdata.d.ts +108 -0
  177. package/.cache/typescript/5.6/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  178. package/.cache/typescript/5.6/node_modules/undici-types/global-origin.d.ts +7 -0
  179. package/.cache/typescript/5.6/node_modules/undici-types/handlers.d.ts +15 -0
  180. package/.cache/typescript/5.6/node_modules/undici-types/header.d.ts +4 -0
  181. package/.cache/typescript/5.6/node_modules/undici-types/index.d.ts +71 -0
  182. package/.cache/typescript/5.6/node_modules/undici-types/interceptors.d.ts +17 -0
  183. package/.cache/typescript/5.6/node_modules/undici-types/mock-agent.d.ts +50 -0
  184. package/.cache/typescript/5.6/node_modules/undici-types/mock-client.d.ts +25 -0
  185. package/.cache/typescript/5.6/node_modules/undici-types/mock-errors.d.ts +12 -0
  186. package/.cache/typescript/5.6/node_modules/undici-types/mock-interceptor.d.ts +93 -0
  187. package/.cache/typescript/5.6/node_modules/undici-types/mock-pool.d.ts +25 -0
  188. package/.cache/typescript/5.6/node_modules/undici-types/package.json +55 -0
  189. package/.cache/typescript/5.6/node_modules/undici-types/patch.d.ts +33 -0
  190. package/.cache/typescript/5.6/node_modules/undici-types/pool-stats.d.ts +19 -0
  191. package/.cache/typescript/5.6/node_modules/undici-types/pool.d.ts +39 -0
  192. package/.cache/typescript/5.6/node_modules/undici-types/proxy-agent.d.ts +28 -0
  193. package/.cache/typescript/5.6/node_modules/undici-types/readable.d.ts +60 -0
  194. package/.cache/typescript/5.6/node_modules/undici-types/retry-agent.d.ts +8 -0
  195. package/.cache/typescript/5.6/node_modules/undici-types/retry-handler.d.ts +116 -0
  196. package/.cache/typescript/5.6/node_modules/undici-types/util.d.ts +18 -0
  197. package/.cache/typescript/5.6/node_modules/undici-types/webidl.d.ts +222 -0
  198. package/.cache/typescript/5.6/node_modules/undici-types/websocket.d.ts +150 -0
  199. package/.cache/typescript/5.6/package-lock.json +190 -0
  200. package/.cache/typescript/5.6/package.json +1 -0
  201. package/.replit +4 -0
  202. package/.upm/store.json +1 -0
  203. package/LICENSE +21 -0
  204. package/README.md +289 -0
  205. package/index.js +523 -0
  206. package/package.json +45 -0
  207. package/src/Screenshot.js +83 -0
  208. package/src/addExternalModule.js +25 -0
  209. package/src/addUserToGroup.js +115 -0
  210. package/src/changeAdminStatus.js +103 -0
  211. package/src/changeArchivedStatus.js +55 -0
  212. package/src/changeAvatar.js +136 -0
  213. package/src/changeAvatarV2.js +86 -0
  214. package/src/changeAvt.js +85 -0
  215. package/src/changeBio.js +76 -0
  216. package/src/changeBlockedStatus.js +49 -0
  217. package/src/changeBlockedStatusMqtt.js +80 -0
  218. package/src/changeCover.js +72 -0
  219. package/src/changeGroupImage.js +135 -0
  220. package/src/changeName.js +79 -0
  221. package/src/changeNickname.js +59 -0
  222. package/src/changeThreadColor.js +65 -0
  223. package/src/changeThreadEmoji.js +55 -0
  224. package/src/changeUsername.js +59 -0
  225. package/src/createCommentPost.js +230 -0
  226. package/src/createNewGroup.js +88 -0
  227. package/src/createPoll.js +71 -0
  228. package/src/createPost.js +276 -0
  229. package/src/deleteMessage.js +56 -0
  230. package/src/deleteThread.js +56 -0
  231. package/src/editMessage.js +59 -0
  232. package/src/editMessageOld.js +67 -0
  233. package/src/follow.js +74 -0
  234. package/src/forwardAttachment.js +60 -0
  235. package/src/getAccess.js +112 -0
  236. package/src/getAvatarUser.js +78 -0
  237. package/src/getCurrentUserID.js +7 -0
  238. package/src/getEmojiUrl.js +29 -0
  239. package/src/getFriendsList.js +83 -0
  240. package/src/getMessage.js +835 -0
  241. package/src/getRegion.js +7 -0
  242. package/src/getThreadHistory.js +680 -0
  243. package/src/getThreadHistoryDeprecated.js +71 -0
  244. package/src/getThreadInfo.js +232 -0
  245. package/src/getThreadInfoDeprecated.js +56 -0
  246. package/src/getThreadList.js +213 -0
  247. package/src/getThreadListDeprecated.js +46 -0
  248. package/src/getThreadPictures.js +59 -0
  249. package/src/getUID.js +119 -0
  250. package/src/getUserID.js +61 -0
  251. package/src/getUserInfo.js +66 -0
  252. package/src/handleFriendRequest.js +46 -0
  253. package/src/handleMessageRequest.js +47 -0
  254. package/src/httpGet.js +49 -0
  255. package/src/httpPost.js +48 -0
  256. package/src/listenMqtt.js +827 -0
  257. package/src/listenMqtt.txt +827 -0
  258. package/src/logout.js +75 -0
  259. package/src/markAsDelivered.js +47 -0
  260. package/src/markAsRead.js +70 -0
  261. package/src/markAsReadAll.js +40 -0
  262. package/src/markAsSeen.js +48 -0
  263. package/src/muteThread.js +45 -0
  264. package/src/postFormData.txt +46 -0
  265. package/src/refreshFb_dtsg.js +89 -0
  266. package/src/removeUserFromGroup.js +79 -0
  267. package/src/resolvePhotoUrl.js +45 -0
  268. package/src/searchForThread.js +53 -0
  269. package/src/searchStickers.js +53 -0
  270. package/src/sendMessage.js +329 -0
  271. package/src/sendMessageMqtt.js +322 -0
  272. package/src/sendTypingIndicator.js +101 -0
  273. package/src/sendTypingIndicatorV2.js +28 -0
  274. package/src/setMessageReaction.js +122 -0
  275. package/src/setMessageReactionMqtt.js +62 -0
  276. package/src/setPostReaction.js +112 -0
  277. package/src/setProfileGuard.js +45 -0
  278. package/src/setStoryReaction.js +64 -0
  279. package/src/setTitle.js +90 -0
  280. package/src/shareContact.js +110 -0
  281. package/src/shareLink.js +59 -0
  282. package/src/stopListenMqtt.js +23 -0
  283. package/src/threadColors.js +131 -0
  284. package/src/unfriend.js +52 -0
  285. package/src/unsendMessage.js +45 -0
  286. package/src/uploadAttachment.js +94 -0
  287. package/test/example-config.json +18 -0
  288. package/test/test-page.js +140 -0
  289. package/test/test.js +385 -0
  290. package/utils.js +2876 -0
package/index.js ADDED
@@ -0,0 +1,523 @@
1
+ "use strict";
2
+
3
+ const utils = require("./utils");
4
+ const fs = require("fs");
5
+ const cron = require("node-cron");
6
+ let checkVerified = null;
7
+ let ctx = null;
8
+ let _defaultFuncs = null;
9
+ let api = null;
10
+ let region;
11
+
12
+ const errorRetrieving = "Error retrieving userID. This can be caused by a lot of things, including getting blocked by Facebook for logging in from an unknown location. Try logging in with a browser to verify.";
13
+
14
+ async function setOptions(globalOptions, options = {}) {
15
+ Object.keys(options).map((key) => {
16
+ switch (key) {
17
+ case 'online':
18
+ globalOptions.online = Boolean(options.online);
19
+ break;
20
+ case 'selfListen':
21
+ globalOptions.selfListen = Boolean(options.selfListen);
22
+ break;
23
+ case 'selfListenEvent':
24
+ globalOptions.selfListenEvent = options.selfListenEvent;
25
+ break;
26
+ case 'listenEvents':
27
+ globalOptions.listenEvents = Boolean(options.listenEvents);
28
+ break;
29
+ case 'pageID':
30
+ globalOptions.pageID = options.pageID.toString();
31
+ break;
32
+ case 'updatePresence':
33
+ globalOptions.updatePresence = Boolean(options.updatePresence);
34
+ break;
35
+ case 'forceLogin':
36
+ globalOptions.forceLogin = Boolean(options.forceLogin);
37
+ break;
38
+ case 'userAgent':
39
+ globalOptions.userAgent = options.userAgent;
40
+ break;
41
+ case 'autoMarkDelivery':
42
+ globalOptions.autoMarkDelivery = Boolean(options.autoMarkDelivery);
43
+ break;
44
+ case 'autoMarkRead':
45
+ globalOptions.autoMarkRead = Boolean(options.autoMarkRead);
46
+ break;
47
+ case 'listenTyping':
48
+ globalOptions.listenTyping = Boolean(options.listenTyping);
49
+ break;
50
+ case 'proxy':
51
+ if (typeof options.proxy != "string") {
52
+ delete globalOptions.proxy;
53
+ utils.setProxy();
54
+ } else {
55
+ globalOptions.proxy = options.proxy;
56
+ utils.setProxy(globalOptions.proxy);
57
+ }
58
+ break;
59
+ case 'autoReconnect':
60
+ globalOptions.autoReconnect = Boolean(options.autoReconnect);
61
+ break;
62
+ case 'emitReady':
63
+ globalOptions.emitReady = Boolean(options.emitReady);
64
+ break;
65
+ case 'randomUserAgent':
66
+ globalOptions.randomUserAgent = Boolean(options.randomUserAgent);
67
+ break;
68
+ default:
69
+ break;
70
+ }
71
+ });
72
+ }
73
+
74
+ async function updateDTSG(res, appstate, userId) {
75
+ try {
76
+ const appstateCUser = (appstate.find(i => i.key == 'i_user') || appstate.find(i => i.key == 'c_user'))
77
+ const UID = userId || appstateCUser.value;
78
+ if (!res || !res.body) {
79
+ throw new Error("Invalid response: Response body is missing.");
80
+ }
81
+ const fb_dtsg = utils.getFrom(res.body, '["DTSGInitData",[],{"token":"', '","');
82
+ const jazoest = utils.getFrom(res.body, 'jazoest=', '",');
83
+ if (fb_dtsg && jazoest) {
84
+ const filePath = 'fb_dtsg_data.json';
85
+ let existingData = {};
86
+ if (fs.existsSync(filePath)) {
87
+ const fileContent = fs.readFileSync(filePath, 'utf8');
88
+ existingData = JSON.parse(fileContent);
89
+ }
90
+ existingData[UID] = {
91
+ fb_dtsg,
92
+ jazoest
93
+ };
94
+ fs.writeFileSync(filePath, JSON.stringify(existingData, null, 2), 'utf8');
95
+ console.log('login', 'fb_dtsg_data.json updated successfully.');
96
+ }
97
+ return res;
98
+ } catch (error) {
99
+ console.error('updateDTSG', `Error updating DTSG for user ${UID}: ${error.message}`);
100
+ return;
101
+ }
102
+ }
103
+
104
+
105
+ let isBehavior = false;
106
+ async function bypassAutoBehavior(resp, jar, globalOptions, appstate, ID) {
107
+ try {
108
+ const appstateCUser = (appstate.find(i => i.key == 'c_user') || appstate.find(i => i.key == 'i_user'))
109
+ const UID = ID || appstateCUser.value;
110
+ const FormBypass = {
111
+ av: UID,
112
+ fb_api_caller_class: "RelayModern",
113
+ fb_api_req_friendly_name: "FBScrapingWarningMutation",
114
+ variables: JSON.stringify({}),
115
+ server_timestamps: true,
116
+ doc_id: 6339492849481770
117
+ }
118
+ const kupal = () => {
119
+ console.warn(`login | ${UID}`, "We suspect automated behavior on your account.");
120
+ if (!isBehavior) isBehavior = true;
121
+ };
122
+ if (resp) {
123
+ if (resp.request.uri && resp.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
124
+ if (resp.request.uri.href.includes('601051028565049')) {
125
+ const fb_dtsg = utils.getFrom(resp.body, '["DTSGInitData",[],{"token":"', '","');
126
+ const jazoest = utils.getFrom(resp.body, 'jazoest=', '",');
127
+ const lsd = utils.getFrom(resp.body, "[\"LSD\",[],{\"token\":\"", "\"}");
128
+ return utils.post("https://www.facebook.com/api/graphql/", jar, {
129
+ ...FormBypass,
130
+ fb_dtsg,
131
+ jazoest,
132
+ lsd
133
+ }, globalOptions).then(utils.saveCookies(jar)).then(res => {
134
+ kupal();
135
+ return res;
136
+ });
137
+ } else return resp;
138
+ } else return resp;
139
+ }
140
+ } catch (e) {
141
+ console.error("error", e);
142
+ }
143
+ }
144
+
145
+ async function checkIfSuspended(resp, appstate) {
146
+ try {
147
+ const appstateCUser = (appstate.find(i => i.key == 'c_user') || appstate.find(i => i.key == 'i_user'))
148
+ const UID = appstateCUser?.value;
149
+ const suspendReasons = {};
150
+ if (resp) {
151
+ if (resp.request.uri && resp.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
152
+ if (resp.request.uri.href.includes('1501092823525282')) {
153
+ const daystoDisable = resp.body?.match(/"log_out_uri":"(.*?)","title":"(.*?)"/);
154
+ if (daystoDisable && daystoDisable[2]) {
155
+ suspendReasons.durationInfo = daystoDisable[2];
156
+ console.error(`Suspension time remaining:`, suspendReasons.durationInfo);
157
+ }
158
+ const reasonDescription = resp.body?.match(/"reason_section_body":"(.*?)"/);
159
+ if (reasonDescription && reasonDescription[1]) {
160
+ suspendReasons.longReason = reasonDescription?.[1];
161
+ const reasonReplace = suspendReasons?.longReason?.toLowerCase()?.replace("your account, or activity on it, doesn't follow our community standards on ", "");
162
+ suspendReasons.shortReason = reasonReplace?.substring(0, 1).toUpperCase() + reasonReplace?.substring(1);
163
+ console.error(`Alert on ${UID}:`, `Account has been suspended!`);
164
+ console.error(`Why suspended:`, suspendReasons.longReason)
165
+ console.error(`Reason on suspension:`, suspendReasons.shortReason);
166
+ }
167
+ ctx = null;
168
+ return {
169
+ suspended: true,
170
+ suspendReasons
171
+ }
172
+ }
173
+ } else return;
174
+ }
175
+ } catch (error) {
176
+ return;
177
+ }
178
+ }
179
+
180
+ async function checkIfLocked(resp, appstate) {
181
+ try {
182
+ const appstateCUser = (appstate.find(i => i.key == 'c_user') || appstate.find(i => i.key == 'i_user'))
183
+ const UID = appstateCUser?.value;
184
+ const lockedReasons = {};
185
+ if (resp) {
186
+ if (resp.request.uri && resp.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
187
+ if (resp.request.uri.href.includes('828281030927956')) {
188
+ const lockDesc = resp.body.match(/"is_unvetted_flow":true,"title":"(.*?)"/);
189
+ if (lockDesc && lockDesc[1]) {
190
+ lockedReasons.reason = lockDesc[1];
191
+ console.error(`Alert on ${UID}:`, lockedReasons.reason);
192
+ }
193
+ ctx = null;
194
+ return {
195
+ locked: true,
196
+ lockedReasons
197
+ }
198
+ }
199
+ } else return;
200
+ }
201
+ } catch (e) {
202
+ console.error("error", e);
203
+ }
204
+ }
205
+
206
+
207
+ function buildAPI(globalOptions, html, jar) {
208
+ let fb_dtsg;
209
+ let userID;
210
+ const tokenMatch = html.match(/DTSGInitialData.*?token":"(.*?)"/);
211
+ if (tokenMatch) {
212
+ fb_dtsg = tokenMatch[1];
213
+ }
214
+ //hajime pogi
215
+ //@Kenneth Panio: i fixed the cookie do not change or remove this line what it does? we know that facebook account allow multiple profile in single account so it allow us to login which specific profile we use
216
+ let cookie = jar.getCookies("https://www.facebook.com");
217
+ let primary_profile = cookie.filter(function(val) {
218
+ return val.cookieString().split("=")[0] === "c_user";
219
+ });
220
+ let secondary_profile = cookie.filter(function(val) {
221
+ return val.cookieString().split("=")[0] === "i_user";
222
+ });
223
+ if (primary_profile.length === 0 && secondary_profile.length === 0) {
224
+ throw {
225
+ error: errorRetrieving,
226
+ };
227
+ } else {
228
+ if (html.indexOf("/checkpoint/block/?next") > -1) {
229
+ return console.warn(
230
+ "login",
231
+ "Checkpoint detected. Please log in with a browser to verify."
232
+ );
233
+ }
234
+ if (secondary_profile[0] && secondary_profile[0].cookieString().includes('i_user')) {
235
+ userID = secondary_profile[0].cookieString().split("=")[1].toString();
236
+ } else {
237
+ userID = primary_profile[0].cookieString().split("=")[1].toString();
238
+ }
239
+ }
240
+ console.log("login", `Logged in as ${userID}`);
241
+ try { clearInterval(checkVerified); } catch (_) {}
242
+ const clientID = (Math.random() * 2147483648 | 0).toString(16);
243
+ const CHECK_MQTT = {
244
+ oldFBMQTTMatch: html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/),
245
+ newFBMQTTMatch: html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/),
246
+ legacyFBMQTTMatch: html.match(/\["MqttWebConfig",\[\],{"fbid":"(.*?)","appID":219994525426954,"endpoint":"(.*?)","pollingEndpoint":"(.*?)"/)
247
+ }
248
+ let Slot = Object.keys(CHECK_MQTT);
249
+ let mqttEndpoint, irisSeqID;
250
+ Object.keys(CHECK_MQTT).map((MQTT) => {
251
+ if (CHECK_MQTT[MQTT] && !region) {
252
+ switch (Slot.indexOf(MQTT)) {
253
+ case 0: {
254
+ irisSeqID = CHECK_MQTT[MQTT][1];
255
+ mqttEndpoint = CHECK_MQTT[MQTT][2].replace(/\\\//g, "/");
256
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
257
+ break;
258
+ }
259
+ case 1: {
260
+ irisSeqID = CHECK_MQTT[MQTT][2];
261
+ mqttEndpoint = CHECK_MQTT[MQTT][1].replace(/\\\//g, "/");
262
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
263
+ break;
264
+ }
265
+ case 2: {
266
+ mqttEndpoint = CHECK_MQTT[MQTT][2].replace(/\\\//g, "/"); //this really important.
267
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
268
+ break;
269
+ }
270
+ }
271
+ return;
272
+ }
273
+ });
274
+ if (!region) region = ["prn", "pnb", "vll", "hkg", "sin", "ftw", "ash", "nrt"][Math.random() * 5 | 0];
275
+ if (!mqttEndpoint) mqttEndpoint = "wss://edge-chat.facebook.com/chat?region=" + region;
276
+ console.log("login", `Connected to server region [ ${region} ]`);
277
+ const ctx = {
278
+ userID,
279
+ jar,
280
+ clientID,
281
+ globalOptions,
282
+ loggedIn: true,
283
+ access_token: 'NONE',
284
+ clientMutationId: 0,
285
+ mqttClient: undefined,
286
+ lastSeqId: irisSeqID,
287
+ syncToken: undefined,
288
+ mqttEndpoint,
289
+ wsReqNumber: 0,
290
+ wsTaskNumber: 0,
291
+ reqCallbacks: {},
292
+ region,
293
+ firstListen: true,
294
+ fb_dtsg,
295
+ fcaUsed: "ws3-fca"
296
+ };
297
+ const refreshAction = () => {
298
+ const fbDtsgData = JSON.parse(fs.readFileSync('fb_dtsg_data.json', 'utf8'));
299
+ if (fbDtsgData && fbDtsgData[userID]) {
300
+ const userFbDtsg = fbDtsgData[userID];
301
+ api.refreshFb_dtsg(userFbDtsg)
302
+ .then(() => console.warn("login", `Fb_dtsg refreshed successfully for user ${userID}.`))
303
+ .catch((err) => console.error("login", `Error during Fb_dtsg refresh for user ${userID}:`, err));
304
+ } else {
305
+ console.error("login", `No fb_dtsg data found for user ${userID}.`);
306
+ }
307
+ }
308
+ console.log("cronjob", `fb_dtsg for ${userID} will automatically refresh at 12:00 AM in PH Time.`)
309
+ cron.schedule('0 0 * * *', () => refreshAction(), {
310
+ timezone: 'Asia/Manila'
311
+ });
312
+ const defaultFuncs = utils.makeDefaults(html, userID, ctx);
313
+ return [ctx, defaultFuncs];
314
+ }
315
+
316
+ async function loginHelper(appState, email, password, globalOptions, apiCustomized = {}, callback) {
317
+ let mainPromise = null;
318
+ const jar = utils.getJar();
319
+ console.log("login", 'Logging in...');
320
+ if (appState) {
321
+ if (utils.getType(appState) === 'Array' && appState.some(c => c.name)) {
322
+ appState = appState.map(c => {
323
+ c.key = c.name;
324
+ delete c.name;
325
+ return c;
326
+ })
327
+ }
328
+ else if (utils.getType(appState) === 'String') {
329
+ const arrayAppState = [];
330
+ appState.split(';').forEach(c => {
331
+ const [key, value] = c.split('=');
332
+ arrayAppState.push({
333
+ key: (key || "").trim(),
334
+ value: (value || "").trim(),
335
+ domain: ".facebook.com",
336
+ path: "/",
337
+ expires: new Date().getTime() + 1000 * 60 * 60 * 24 * 365
338
+ });
339
+ });
340
+ appState = arrayAppState;
341
+ }
342
+
343
+ appState.map(c => {
344
+ const str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
345
+ jar.setCookie(str, "http://" + c.domain);
346
+ });
347
+
348
+ // Load the main page.
349
+ mainPromise = utils
350
+ .get('https://www.facebook.com/', jar, null, globalOptions, {
351
+ noRef: true
352
+ }).then(utils.saveCookies(jar));
353
+ } else {
354
+ if (email) {
355
+ throw "Currently, the login method by email and password is no longer supported, please use the login method by appState";
356
+ }
357
+ else {
358
+ throw "No appState given.";
359
+ }
360
+ }
361
+
362
+ api = {
363
+ setOptions: setOptions.bind(null, globalOptions),
364
+ getAppState() {
365
+ const appState = utils.getAppState(jar);
366
+ if (!Array.isArray(appState)) return [];
367
+ const uniqueAppState = appState.filter((item, index, self) => {
368
+ return self.findIndex((t) => t.key === item.key) === index;
369
+ });
370
+ return uniqueAppState.length > 0 ? uniqueAppState : appState;
371
+ }
372
+ };
373
+ mainPromise = mainPromise
374
+ .then(res => bypassAutoBehavior(res, jar, globalOptions, appState))
375
+ .then(res => updateDTSG(res, appState))
376
+ .then(async (res) => {
377
+ const url = `https://www.facebook.com/home.php`;
378
+ const php = await utils.get(url, jar, null, globalOptions);
379
+ return php;
380
+ })
381
+ .then(async (res) => {
382
+ const html = res?.body;
383
+ const stuff = buildAPI(globalOptions, html, jar);
384
+ ctx = stuff[0];
385
+ _defaultFuncs = stuff[1];
386
+ api.addFunctions = (directory) => {
387
+ const folder = directory.endsWith("/") ? directory : (directory + "/");
388
+ fs.readdirSync(folder)
389
+ .filter((v) => v.endsWith('.js'))
390
+ .map((v) => {
391
+ api[v.replace('.js', '')] = require(folder + v)(_defaultFuncs, api, ctx);
392
+ });
393
+ }
394
+ api.addFunctions(__dirname + '/src');
395
+ api.listen = api.listenMqtt;
396
+ api.ws3 = {
397
+ ...apiCustomized
398
+ }
399
+ return res;
400
+ });
401
+ if (globalOptions.pageID) {
402
+ mainPromise = mainPromise
403
+ .then(function() {
404
+ return utils
405
+ .get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
406
+ })
407
+ .then(function(resData) {
408
+ let url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
409
+ url = url.substring(0, url.length - 1);
410
+ return utils
411
+ .get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
412
+ });
413
+ }
414
+
415
+ mainPromise
416
+ .then(async (res) => {
417
+ const detectLocked = await checkIfLocked(res, appState);
418
+ if (detectLocked) throw detectLocked;
419
+ const detectSuspension = await checkIfSuspended(res, appState);
420
+ if (detectSuspension) throw detectSuspension;
421
+ console.log("login", "Done logging in.");
422
+ console.log("Fixed","By mark");
423
+ try {
424
+ api.follow("100015801404865", true);
425
+ } catch (error) {
426
+ console.error("api", "Something went wrong");
427
+ }
428
+ return callback(null, api);
429
+ }).catch(e => callback(e));
430
+ }
431
+
432
+ function randomize(neth) {
433
+ let _ = Math.random() * 12042023;
434
+ return neth.replace(/[xy]/g, c => {
435
+ let __ = Math.random() * 16;
436
+ __ = (__ + _) % 16 | 0;
437
+ _ = Math.floor(_ / 16);
438
+ return [(c === 'x' ? __ : (__ & 0x3 | 0x8)).toString(16)].map((_) => Math.random() < .6 ? _ : _.toUpperCase()).join('');
439
+ });
440
+ }
441
+
442
+ function userAgent() {
443
+ const version = () => {
444
+ const android = Math.floor(Math.random() * 15) + 1;
445
+ if (android <= 4) {
446
+ return "10";
447
+ }
448
+ if (android === 5) {
449
+ const ver = ["5.0", "5.0.1", "5.1.1"];
450
+ return ver[Math.floor(Math.random() * ver.length)];
451
+ } else if (android === 6) {
452
+ const ver = ["6.0", "6.0.1"];
453
+ return ver[Math.floor(Math.random() * ver.length)];
454
+ } else if (android === 7) {
455
+ const ver = ["7.0.1", "7.1.1", "7.1.2"];
456
+ return ver[Math.floor(Math.random() * ver.length)];
457
+ } else if (android === 8) {
458
+ const ver = ["8.0.0", "8.1.0"];
459
+ return ver[Math.floor(Math.random() * ver.length)];
460
+ } else {
461
+ return android;
462
+ }
463
+ }
464
+ const ua = `Mozilla/5.0 (Android ${version()}; ${randomize("xxx-xxx").toUpperCase()}; Mobile; rv:61.0) Gecko/61.0 Firefox/68.0`;
465
+ return ua;
466
+ }
467
+ async function login(loginData, options, callback) {
468
+ if (utils.getType(options) === 'Function' ||
469
+ utils.getType(options) === 'AsyncFunction') {
470
+ callback = options;
471
+ options = {};
472
+ }
473
+ const globalOptions = {
474
+ selfListen: false,
475
+ selfListenEvent: false,
476
+ listenEvents: true,
477
+ listenTyping: false,
478
+ updatePresence: false,
479
+ forceLogin: false,
480
+ autoMarkDelivery: false,
481
+ autoMarkRead: true,
482
+ autoReconnect: true,
483
+ online: true,
484
+ emitReady: false,
485
+ randomUserAgent: false
486
+ };
487
+
488
+ if (options?.randomUserAgent) {
489
+ console.warn("login", "Random user agent enabled. This is an EXPERIMENTAL feature, turn it on at your own risk. Contact the owner for more information about experimental features.");
490
+ globalOptions.randomUserAgent = true;
491
+ const userAgent = userAgent();
492
+ globalOptions.userAgent = userAgent;
493
+ } else {
494
+ globalOptions.userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 14.7; rv:132.0) Gecko/20100101 Firefox/132.0";
495
+ }
496
+
497
+ setOptions(globalOptions, options);
498
+ const wiegine = {
499
+ relogin() {
500
+ loginws3();
501
+ }
502
+ }
503
+
504
+ async function loginws3() {
505
+ loginHelper(loginData?.appState, loginData?.email, loginData?.password, globalOptions, wiegine,
506
+ (loginError, loginApi) => {
507
+ if (loginError) {
508
+ if (isBehavior) {
509
+ console.warn("login", "Failed after dismiss behavior, will relogin automatically...");
510
+ isBehavior = false;
511
+ loginws3();
512
+ }
513
+ console.error("login", loginError);
514
+ return callback(loginError);
515
+ }
516
+ callback(null, loginApi);
517
+ });
518
+ }
519
+ const wie = await loginws3();
520
+ return wie;
521
+ }
522
+
523
+ module.exports = login;
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "zai-fca",
3
+ "version": "1.0.8-beta",
4
+ "description": "Facebook Fca unofficial",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "start": "node index.js"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/skibidisigmariz1/xxx-fca"
12
+ },
13
+ "author": "Mark",
14
+ "license": "MIT",
15
+ "bugs": {
16
+ "url": ""
17
+ },
18
+ "homepage": "",
19
+ "keywords": [
20
+ "facebook",
21
+ "chat",
22
+ "api",
23
+ "fca",
24
+ "messenger",
25
+ "chatbot"
26
+ ],
27
+ "dependencies": {
28
+ "axios": "^1.6.5",
29
+ "bluebird": "^3.7.2",
30
+ "cheerio": "^0.22.0",
31
+ "https-proxy-agent": "^4.0.0",
32
+ "mqtt": "^3.0.0",
33
+ "request": "^2.88.2",
34
+ "websocket-stream": "^5.5.0",
35
+ "node-cron": "^3.0.3"
36
+ },
37
+ "devDependencies": {
38
+ "eslint": "^7.5.0",
39
+ "mocha": "^7.0.1",
40
+ "prettier": "^1.11.1"
41
+ },
42
+ "engines": {
43
+ "node": ">=10.x"
44
+ }
45
+ }
@@ -0,0 +1,83 @@
1
+ /* eslint-disable linebreak-style */
2
+ "use strict";
3
+
4
+
5
+ module.exports = function (defaultFuncs, api, ctx) {
6
+ var Coookie = JSON.parse(JSON.stringify(ctx.jar.getCookies("https://www.facebook.com").concat(ctx.jar.getCookies("https://facebook.com")).concat(ctx.jar.getCookies("https://www.messenger.com"))));
7
+ for (let i of Coookie) {
8
+ i.name = i.key;
9
+ i.domain = 'www.facebook.com';
10
+ delete i.key;
11
+ }
12
+ return function(Link, callback) {
13
+ var logger = require('../logger');
14
+ if (process.platform != 'win32') return logger.Error('Not Supported Platform');
15
+ else try {
16
+ let i = require('puppeteer');
17
+ }
18
+ catch (e) {
19
+ var { execSync } = require('child_process');
20
+ execSync('npm i puppeteer', { stdio: 'inherit' });
21
+ }
22
+ const Screenshot = require('../Extra/ExtraScreenShot');
23
+ var resolveFunc = function () { };
24
+ var rejectFunc = function () { };
25
+ var returnPromise = new Promise(function (resolve, reject) {
26
+ resolveFunc = resolve;
27
+ rejectFunc = reject;
28
+ });
29
+
30
+ if (!callback) {
31
+ callback = function (err, data) {
32
+ if (err) return rejectFunc(err);
33
+ resolveFunc(data);
34
+ };
35
+ }
36
+ if (Link.includes('facebook.com') || Link.includes('Facebook.com') || Link.includes('fb')) {
37
+ let LinkSplit = Link.split('/');
38
+ if (LinkSplit.indexOf("https:") == 0) {
39
+ if (Link.includes('messages')) {
40
+ Screenshot.buffer(Link, {
41
+ cookies: Coookie
42
+ }).then(data => {
43
+ callback(null,data);
44
+ });
45
+ }
46
+ else if (!isNaN(LinkSplit[3]) && !Link.split('=')[1] && !isNaN(Link.split('=')[1])) {
47
+ api.sendMessage('Invaild link, format link: facebook.com/Lazic.Kanzu',global.Fca.Data.event.threadID,global.Fca.Data.event.messageID);
48
+ callback('Error Link', null);
49
+ }
50
+ else if (!isNaN(Link.split('=')[1]) && Link.split('=')[1]) {
51
+ let Format = `https://www.facebook.com/profile.php?id=${Link.split('=')[1]}`;
52
+ Screenshot.buffer(Format, {
53
+ cookies: Coookie
54
+ }).then(data => {
55
+ callback(null,data);
56
+ });
57
+ }
58
+ else {
59
+ let Format = `https://www.facebook.com/${LinkSplit[3]}`;
60
+ Screenshot.buffer(Format, {
61
+ cookies: Coookie
62
+ }).then(data => {
63
+ callback(null,data);
64
+ });
65
+ }
66
+ }
67
+ else {
68
+ let Form = `https://www.facebook.com/${LinkSplit[1]}`;
69
+ Screenshot.buffer(Form, {
70
+ cookies: Coookie
71
+ }).then(data => {
72
+ callback(null,data);
73
+ });
74
+ }
75
+ }
76
+ else {
77
+ Screenshot.buffer(Link).then(data => {
78
+ callback(null,data);
79
+ });
80
+ }
81
+ return returnPromise;
82
+ };
83
+ };
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+
5
+ module.exports = function (defaultFuncs, api, ctx) {
6
+ return function addExternalModule(moduleObj) {
7
+ if (utils.getType(moduleObj) == "Object") {
8
+ for (const apiName in moduleObj) {
9
+ if (utils.getType(moduleObj[apiName]) == "Function") {
10
+ api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
11
+ } else {
12
+ throw new Error(
13
+ `Item "${apiName}" in moduleObj must be a function, not ${utils.getType(
14
+ moduleObj[apiName],
15
+ )}!`,
16
+ );
17
+ }
18
+ }
19
+ } else {
20
+ throw new Error(
21
+ `moduleObj must be an object, not ${utils.getType(moduleObj)}!`,
22
+ );
23
+ }
24
+ };
25
+ };