zai-fca 1.0.7

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 (264) 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 +460 -0
  206. package/package.json +45 -0
  207. package/src/Screenshot.js +83 -0
  208. package/src/addExternalModule.js +15 -0
  209. package/src/addUserToGroup.js +77 -0
  210. package/src/changeAdminStatus.js +47 -0
  211. package/src/changeArchivedStatus.js +41 -0
  212. package/src/changeAvt.js +85 -0
  213. package/src/changeBio.js +65 -0
  214. package/src/changeBlockedStatus.js +36 -0
  215. package/src/changeGroupImage.js +106 -0
  216. package/src/changeNickname.js +45 -0
  217. package/src/changeThreadColor.js +61 -0
  218. package/src/changeThreadEmoji.js +41 -0
  219. package/src/createNewGroup.js +70 -0
  220. package/src/createPoll.js +59 -0
  221. package/src/createPost.js +277 -0
  222. package/src/deleteMessage.js +44 -0
  223. package/src/deleteThread.js +42 -0
  224. package/src/forwardAttachment.js +47 -0
  225. package/src/getCurrentUserID.js +7 -0
  226. package/src/getEmojiUrl.js +27 -0
  227. package/src/getFriendsList.js +73 -0
  228. package/src/getThreadHistory.js +537 -0
  229. package/src/getThreadHistoryDeprecated.js +71 -0
  230. package/src/getThreadInfo.js +232 -0
  231. package/src/getThreadInfoDeprecated.js +56 -0
  232. package/src/getThreadList.js +213 -0
  233. package/src/getThreadListDeprecated.js +46 -0
  234. package/src/getThreadPictures.js +59 -0
  235. package/src/getUID.js +119 -0
  236. package/src/getUserID.js +61 -0
  237. package/src/getUserInfo.js +66 -0
  238. package/src/handleFriendRequest.js +46 -0
  239. package/src/handleMessageRequest.js +47 -0
  240. package/src/httpGet.js +49 -0
  241. package/src/httpPost.js +48 -0
  242. package/src/listenMqtt.js +827 -0
  243. package/src/listenMqtt.txt +827 -0
  244. package/src/logout.js +68 -0
  245. package/src/markAsDelivered.js +47 -0
  246. package/src/markAsRead.js +70 -0
  247. package/src/markAsReadAll.js +40 -0
  248. package/src/markAsSeen.js +48 -0
  249. package/src/muteThread.js +45 -0
  250. package/src/postFormData.txt +46 -0
  251. package/src/removeUserFromGroup.js +45 -0
  252. package/src/resolvePhotoUrl.js +36 -0
  253. package/src/searchForThread.js +42 -0
  254. package/src/sendMessage.js +329 -0
  255. package/src/sendTypingIndicator.js +70 -0
  256. package/src/setMessageReaction.js +109 -0
  257. package/src/setPostReaction.js +102 -0
  258. package/src/setTitle.js +70 -0
  259. package/src/shareContact.js +46 -0
  260. package/src/shareLink.js +62 -0
  261. package/src/threadColors.js +41 -0
  262. package/src/unfriend.js +42 -0
  263. package/src/unsendMessage.js +39 -0
  264. package/utils.js +2876 -0
package/index.js ADDED
@@ -0,0 +1,460 @@
1
+ "use strict";
2
+
3
+ var utils = require("./utils");
4
+ var cheerio = require("cheerio");
5
+ var log = require("npmlog");
6
+ /*var { getThemeColors } = require("../../func/utils/log.js");
7
+ var logger = require("../../func/utils/log.js");
8
+ var { cra, cv, cb, co } = getThemeColors();*/
9
+ log.maxRecordSize = 100;
10
+ var checkVerified = null;
11
+ const Boolean_Option = ['online', 'selfListen', 'listenEvents', 'updatePresence', 'forceLogin', 'autoMarkDelivery', 'autoMarkRead', 'listenTyping', 'autoReconnect', 'emitReady'];
12
+ global.ditconmemay = false;
13
+
14
+ function setOptions(globalOptions, options) {
15
+ Object.keys(options).map(function (key) {
16
+ switch (Boolean_Option.includes(key)) {
17
+ case true: {
18
+ globalOptions[key] = Boolean(options[key]);
19
+ break;
20
+ }
21
+ case false: {
22
+ switch (key) {
23
+ case 'pauseLog': {
24
+ if (options.pauseLog) log.pause();
25
+ else log.resume();
26
+ break;
27
+ }
28
+ case 'logLevel': {
29
+ log.level = options.logLevel;
30
+ globalOptions.logLevel = options.logLevel;
31
+ break;
32
+ }
33
+ case 'logRecordSize': {
34
+ log.maxRecordSize = options.logRecordSize;
35
+ globalOptions.logRecordSize = options.logRecordSize;
36
+ break;
37
+ }
38
+ case 'pageID': {
39
+ globalOptions.pageID = options.pageID.toString();
40
+ break;
41
+ }
42
+ case 'userAgent': {
43
+ globalOptions.userAgent = (options.userAgent || 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36');
44
+ break;
45
+ }
46
+ case 'proxy': {
47
+ if (typeof options.proxy != "string") {
48
+ delete globalOptions.proxy;
49
+ utils.setProxy();
50
+ } else {
51
+ globalOptions.proxy = options.proxy;
52
+ utils.setProxy(globalOptions.proxy);
53
+ }
54
+ break;
55
+ }
56
+ default: {
57
+ log.warn("setOptions", "Unrecognized option given to setOptions: " + key);
58
+ break;
59
+ }
60
+ }
61
+ break;
62
+ }
63
+ }
64
+ });
65
+ }
66
+
67
+ function buildAPI(globalOptions, html, jar) {
68
+ let fb_dtsg = null;
69
+ let irisSeqID = null;
70
+ function extractFromHTML() {
71
+ try {
72
+ const $ = cheerio.load(html);
73
+ $('script').each((i, script) => {
74
+ if (!fb_dtsg) {
75
+ const scriptText = $(script).html() || '';
76
+ const patterns = [
77
+ /\["DTSGInitialData",\[\],{"token":"([^"]+)"}]/,
78
+ /\["DTSGInitData",\[\],{"token":"([^"]+)"/,
79
+ /"token":"([^"]+)"/,
80
+ /{\\"token\\":\\"([^\\]+)\\"/,
81
+ /,\{"token":"([^"]+)"\},\d+\]/,
82
+ /"async_get_token":"([^"]+)"/,
83
+ /"dtsg":\{"token":"([^"]+)"/,
84
+ /DTSGInitialData[^>]+>([^<]+)/
85
+ ];
86
+ for (const pattern of patterns) {
87
+ const match = scriptText.match(pattern);
88
+ if (match && match[1]) {
89
+ try {
90
+ const possibleJson = match[1].replace(/\\"/g, '"');
91
+ const parsed = JSON.parse(possibleJson);
92
+ fb_dtsg = parsed.token || parsed;
93
+ } catch {
94
+ fb_dtsg = match[1];
95
+ }
96
+ if (fb_dtsg) break;
97
+ }
98
+ }
99
+ }
100
+ });
101
+ if (!fb_dtsg) {
102
+ const dtsgInput = $('input[name="fb_dtsg"]').val();
103
+ if (dtsgInput) fb_dtsg = dtsgInput;
104
+ }
105
+ const seqMatches = html.match(/irisSeqID":"([^"]+)"/);
106
+ if (seqMatches && seqMatches[1]) {
107
+ irisSeqID = seqMatches[1];
108
+ }
109
+ try {
110
+ const jsonMatches = html.match(/\{"dtsg":({[^}]+})/);
111
+ if (jsonMatches && jsonMatches[1]) {
112
+ const dtsgData = JSON.parse(jsonMatches[1]);
113
+ if (dtsgData.token) fb_dtsg = dtsgData.token;
114
+ }
115
+ } catch { }
116
+ if (fb_dtsg) {
117
+ console.log("Đã tìm thấy fb_dtsg");
118
+ }
119
+ } catch (e) {
120
+ console.log("Lỗi khi tìm fb_dtsg:", e);
121
+ }
122
+ }
123
+ extractFromHTML();
124
+ var userID;
125
+ var cookies = jar.getCookies("https://www.facebook.com");
126
+ var userCookie = cookies.find(cookie => cookie.cookieString().startsWith("c_user="));
127
+ var tiktikCookie = cookies.find(cookie => cookie.cookieString().startsWith("i_user="));
128
+ if (!userCookie && !tiktikCookie) {
129
+ return log.error('login', "Không tìm thấy cookie cho người dùng, vui lòng kiểm tra lại thông tin đăng nhập");
130
+ }
131
+ if (html.includes("/checkpoint/block/?next")) {
132
+ return log.error('login', "Appstate die, vui lòng thay cái mới!", 'error');
133
+ }
134
+ userID = (tiktikCookie || userCookie).cookieString().split("=")[1];
135
+ //logger.log(`${cra(`[ CONNECT ]`)} Logged in as ${userID}`, "DATABASE");
136
+ try { clearInterval(checkVerified); } catch (_) { }
137
+ const clientID = (Math.random() * 2147483648 | 0).toString(16);
138
+ let mqttEndpoint = `wss://edge-chat.facebook.com/chat?region=prn&sid=${userID}`;
139
+ let region = "PRN";
140
+
141
+ try {
142
+ const endpointMatch = html.match(/"endpoint":"([^"]+)"/);
143
+ if (endpointMatch.input.includes("601051028565049")) {
144
+ console.log(`lỗi login vì dính tài khoản tự động`);
145
+ ditconmemay = true;
146
+ }
147
+ if (endpointMatch) {
148
+ mqttEndpoint = endpointMatch[1].replace(/\\\//g, '/');
149
+ const url = new URL(mqttEndpoint);
150
+ region = url.searchParams.get('region')?.toUpperCase() || "PRN";
151
+ }
152
+ } catch (e) {
153
+ console.log('Using default MQTT endpoint');
154
+ }
155
+ log.info('login', 'Fix fca by DongDev x Satoru');
156
+ var ctx = {
157
+ userID: userID,
158
+ jar: jar,
159
+ clientID: clientID,
160
+ globalOptions: globalOptions,
161
+ loggedIn: true,
162
+ access_token: 'NONE',
163
+ clientMutationId: 0,
164
+ mqttClient: undefined,
165
+ lastSeqId: irisSeqID,
166
+ syncToken: undefined,
167
+ mqttEndpoint: mqttEndpoint,
168
+ region: region,
169
+ firstListen: true,
170
+ fb_dtsg: fb_dtsg,
171
+ req_ID: 0,
172
+ callback_Task: {},
173
+ wsReqNumber: 0,
174
+ wsTaskNumber: 0,
175
+ reqCallbacks: {}
176
+ };
177
+ var api = {
178
+ setOptions: setOptions.bind(null, globalOptions),
179
+ getAppState: () => utils.getAppState(jar),
180
+ postFormData: (url, body) => utils.makeDefaults(html, userID, ctx).postFormData(url, ctx.jar, body)
181
+ };
182
+ var defaultFuncs = utils.makeDefaults(html, userID, ctx);
183
+ api.postFormData = function (url, body) {
184
+ return defaultFuncs.postFormData(url, ctx.jar, body);
185
+ };
186
+ api.getFreshDtsg = async function () {
187
+ try {
188
+ const res = await defaultFuncs.get('https://www.facebook.com/', jar, null, globalOptions);
189
+ const $ = cheerio.load(res.body);
190
+ let newDtsg;
191
+ const patterns = [
192
+ /\["DTSGInitialData",\[\],{"token":"([^"]+)"}]/,
193
+ /\["DTSGInitData",\[\],{"token":"([^"]+)"/,
194
+ /"token":"([^"]+)"/,
195
+ /name="fb_dtsg" value="([^"]+)"/
196
+ ];
197
+
198
+ $('script').each((i, script) => {
199
+ if (!newDtsg) {
200
+ const scriptText = $(script).html() || '';
201
+ for (const pattern of patterns) {
202
+ const match = scriptText.match(pattern);
203
+ if (match && match[1]) {
204
+ newDtsg = match[1];
205
+ break;
206
+ }
207
+ }
208
+ }
209
+ });
210
+
211
+ if (!newDtsg) {
212
+ newDtsg = $('input[name="fb_dtsg"]').val();
213
+ }
214
+
215
+ return newDtsg;
216
+ } catch (e) {
217
+ console.log("Error getting fresh dtsg:", e);
218
+ return null;
219
+ }
220
+ };
221
+ //if (noMqttData) api.htmlData = noMqttData;
222
+ require('fs').readdirSync(__dirname + '/src/').filter(v => v.endsWith('.js')).forEach(v => { api[v.replace('.js', '')] = require(`./src/${v}`)(utils.makeDefaults(html, userID, ctx), api, ctx); });
223
+ api.listen = api.listenMqtt;
224
+ return {
225
+ ctx,
226
+ defaultFuncs,
227
+ api
228
+ };
229
+ }
230
+
231
+ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
232
+ return async function (res) {
233
+ try {
234
+ const html = res.body;
235
+ const $ = cheerio.load(html);
236
+ let arr = [];
237
+ $("#login_form input").each((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
238
+ arr = arr.filter(v => v.val && v.val.length);
239
+ let form = utils.arrToForm(arr);
240
+ form.lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
241
+ form.lgndim = Buffer.from(JSON.stringify({ w: 1440, h: 900, aw: 1440, ah: 834, c: 24 })).toString('base64');
242
+ form.email = email;
243
+ form.pass = password;
244
+ form.default_persistent = '0';
245
+ form.lgnrnd = utils.getFrom(html, "name=\"lgnrnd\" value=\"", "\"");
246
+ form.locale = 'en_US';
247
+ form.timezone = '240';
248
+ form.lgnjs = Math.floor(Date.now() / 1000);
249
+ const willBeCookies = html.split("\"_js_");
250
+ willBeCookies.slice(1).forEach(val => {
251
+ const cookieData = JSON.parse("[\"" + utils.getFrom(val, "", "]") + "]");
252
+ jar.setCookie(utils.formatCookie(cookieData, "facebook"), "https://www.facebook.com");
253
+ });
254
+ log.info("login", "Logging in...");
255
+ const loginRes = await utils.post(
256
+ "https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110",
257
+ jar,
258
+ form,
259
+ loginOptions
260
+ );
261
+ await utils.saveCookies(jar)(loginRes);
262
+ const headers = loginRes.headers;
263
+ if (!headers.location) throw new Error("Wrong username/password.");
264
+ if (headers.location.includes('https://www.facebook.com/checkpoint/')) {
265
+ log.info("login", "You have login approvals turned on.");
266
+ const checkpointRes = await utils.get(headers.location, jar, null, loginOptions);
267
+ await utils.saveCookies(jar)(checkpointRes);
268
+ const checkpointHtml = checkpointRes.body;
269
+ const $ = cheerio.load(checkpointHtml);
270
+ let checkpointForm = [];
271
+ $("form input").each((i, v) => checkpointForm.push({ val: $(v).val(), name: $(v).attr("name") }));
272
+ checkpointForm = checkpointForm.filter(v => v.val && v.val.length);
273
+ const form = utils.arrToForm(checkpointForm);
274
+ if (checkpointHtml.includes("checkpoint/?next")) {
275
+ return new Promise((resolve, reject) => {
276
+ const submit2FA = async (code) => {
277
+ try {
278
+ form.approvals_code = code;
279
+ form['submit[Continue]'] = $("#checkpointSubmitButton").html();
280
+ const approvalRes = await utils.post(
281
+ "https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php",
282
+ jar,
283
+ form,
284
+ loginOptions
285
+ );
286
+ await utils.saveCookies(jar)(approvalRes);
287
+ const approvalError = $("#approvals_code").parent().attr("data-xui-error");
288
+ if (approvalError) throw new Error("Invalid 2FA code.");
289
+ form.name_action_selected = 'dont_save';
290
+ const finalRes = await utils.post(
291
+ "https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php",
292
+ jar,
293
+ form,
294
+ loginOptions
295
+ );
296
+ await utils.saveCookies(jar)(finalRes);
297
+ const appState = utils.getAppState(jar);
298
+ resolve(await loginHelper(appState, email, password, loginOptions, callback));
299
+ } catch (error) {
300
+ reject(error);
301
+ }
302
+ };
303
+ throw {
304
+ error: 'login-approval',
305
+ continue: submit2FA
306
+ };
307
+ });
308
+ }
309
+ if (!loginOptions.forceLogin) throw new Error("Couldn't login. Facebook might have blocked this account.");
310
+ form['submit[This was me]'] = checkpointHtml.includes("Suspicious Login Attempt") ? "This was me" : "This Is Okay";
311
+ await utils.post("https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php", jar, form, loginOptions);
312
+ form.name_action_selected = 'save_device';
313
+ const reviewRes = await utils.post("https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php", jar, form, loginOptions);
314
+ const appState = utils.getAppState(jar);
315
+ return await loginHelper(appState, email, password, loginOptions, callback);
316
+ }
317
+ await utils.get('https://www.facebook.com/', jar, null, loginOptions);
318
+ return await utils.saveCookies(jar);
319
+ } catch (error) {
320
+ callback(error);
321
+ }
322
+ };
323
+ }
324
+
325
+
326
+ function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
327
+ let mainPromise = null;
328
+ const jar = utils.getJar();
329
+ if (appState) {
330
+ try {
331
+ appState = JSON.parse(appState);
332
+ } catch (e) {
333
+ try {
334
+ appState = appState;
335
+ } catch (e) {
336
+ return callback(new Error("Failed to parse appState"));
337
+ }
338
+ }
339
+
340
+ try {
341
+ appState.forEach(c => {
342
+ const str = `${c.key}=${c.value}; expires=${c.expires}; domain=${c.domain}; path=${c.path};`;
343
+ jar.setCookie(str, "http://" + c.domain);
344
+ });
345
+
346
+ mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true })
347
+ .then(utils.saveCookies(jar));
348
+ } catch (e) {
349
+ process.exit(0);
350
+ }
351
+ } else {
352
+ mainPromise = utils
353
+ .get("https://www.facebook.com/", null, null, globalOptions, { noRef: true })
354
+ .then(utils.saveCookies(jar))
355
+ .then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
356
+ .then(() => utils.get('https://www.facebook.com/', jar, null, globalOptions).then(utils.saveCookies(jar)));
357
+ }
358
+
359
+ function handleRedirect(res) {
360
+ const reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
361
+ const redirect = reg.exec(res.body);
362
+ if (redirect && redirect[1]) {
363
+ return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
364
+ }
365
+ return res;
366
+ }
367
+
368
+ let ctx, api;
369
+ mainPromise = mainPromise
370
+ .then(handleRedirect)
371
+ .then(res => {
372
+ const mobileAgentRegex = /MPageLoadClientMetrics/gs;
373
+ if (!mobileAgentRegex.test(res.body)) {
374
+ globalOptions.userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36";
375
+ return utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
376
+ }
377
+ return res;
378
+ })
379
+ .then(handleRedirect)
380
+ .then(res => {
381
+ const html = res.body;
382
+ const Obj = buildAPI(globalOptions, html, jar);
383
+ ctx = Obj.ctx;
384
+ api = Obj.api;
385
+ return res;
386
+ });
387
+
388
+ if (globalOptions.pageID) {
389
+ mainPromise = mainPromise
390
+ .then(() => utils.get(`https://www.facebook.com/${globalOptions.pageID}/messages/?section=messages&subsection=inbox`, jar, null, globalOptions))
391
+ .then(resData => {
392
+ let url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
393
+ url = url.substring(0, url.length - 1);
394
+ return utils.get('https://www.facebook.com' + url, jar, null, globalOptions);
395
+ });
396
+ }
397
+
398
+ mainPromise
399
+ .then(async () => {
400
+ log.info('Đăng nhập thành công');
401
+ callback(null, api);
402
+ })
403
+ .catch(e => {
404
+ callback(e);
405
+ });
406
+ }
407
+
408
+
409
+ function login(loginData, options, callback) {
410
+ if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
411
+ callback = options;
412
+ options = {};
413
+ }
414
+
415
+ var globalOptions = {
416
+ selfListen: false,
417
+ listenEvents: true,
418
+ listenTyping: false,
419
+ updatePresence: false,
420
+ forceLogin: false,
421
+ autoMarkDelivery: false,
422
+ autoMarkRead: false,
423
+ autoReconnect: true,
424
+ logRecordSize: 100,
425
+ online: false,
426
+ emitReady: false,
427
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
428
+ };
429
+
430
+ var prCallback = null;
431
+ if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
432
+ var rejectFunc = null;
433
+ var resolveFunc = null;
434
+ var returnPromise = new Promise(function (resolve, reject) {
435
+ resolveFunc = resolve;
436
+ rejectFunc = reject;
437
+ });
438
+ prCallback = function (error, api) {
439
+ if (error) return rejectFunc(error);
440
+ return resolveFunc(api);
441
+ };
442
+ callback = prCallback;
443
+ }
444
+
445
+ if (loginData.email && loginData.password) {
446
+ setOptions(globalOptions, {
447
+ logLevel: "silent",
448
+ forceLogin: true,
449
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
450
+ });
451
+ loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
452
+ } else if (loginData.appState) {
453
+ setOptions(globalOptions, options);
454
+ return loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
455
+ }
456
+ return returnPromise;
457
+ }
458
+
459
+
460
+ module.exports = login;
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "zai-fca",
3
+ "version": "1.0.7",
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,15 @@
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 (let apiName in moduleObj) {
9
+ if (utils.getType(moduleObj[apiName]) == "Function") api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
10
+ else throw new Error(`Item "${apiName}" in moduleObj must be a function, not ${utils.getType(moduleObj[apiName])}!`);
11
+ }
12
+ }
13
+ else throw new Error(`moduleObj must be an object, not ${utils.getType(moduleObj)}!`);
14
+ };
15
+ };
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ return function addUserToGroup(userID, threadID, callback) {
8
+ var resolveFunc = function () { };
9
+ var rejectFunc = function () { };
10
+ var returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
+
15
+ if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
16
+
17
+ if (!callback) {
18
+ callback = function (err) {
19
+ if (err) return rejectFunc(err);
20
+ resolveFunc();
21
+ };
22
+ }
23
+
24
+ if (utils.getType(threadID) !== "Number" && utils.getType(threadID) !== "String") throw { error: "ThreadID should be of type Number or String and not " + utils.getType(threadID) + "." };
25
+
26
+ if (utils.getType(userID) !== "Array") userID = [userID];
27
+
28
+ var messageAndOTID = utils.generateOfflineThreadingID();
29
+ var form = {
30
+ client: "mercury",
31
+ action_type: "ma-type:log-message",
32
+ author: "fbid:" + ctx.userID,
33
+ thread_id: "",
34
+ timestamp: Date.now(),
35
+ timestamp_absolute: "Today",
36
+ timestamp_relative: utils.generateTimestampRelative(),
37
+ timestamp_time_passed: "0",
38
+ is_unread: false,
39
+ is_cleared: false,
40
+ is_forward: false,
41
+ is_filtered_content: false,
42
+ is_filtered_content_bh: false,
43
+ is_filtered_content_account: false,
44
+ is_spoof_warning: false,
45
+ source: "source:chat:web",
46
+ "source_tags[0]": "source:chat",
47
+ log_message_type: "log:subscribe",
48
+ status: "0",
49
+ offline_threading_id: messageAndOTID,
50
+ message_id: messageAndOTID,
51
+ threading_id: utils.generateThreadingID(ctx.clientID),
52
+ manual_retry_cnt: "0",
53
+ thread_fbid: threadID
54
+ };
55
+
56
+ for (var i = 0; i < userID.length; i++) {
57
+ if (utils.getType(userID[i]) !== "Number" && utils.getType(userID[i]) !== "String") throw { error: "Elements of userID should be of type Number or String and not " + utils.getType(userID[i]) + "." };
58
+ form["log_message_data[added_participants][" + i + "]"] = "fbid:" + userID[i];
59
+ }
60
+
61
+ defaultFuncs
62
+ .post("https://www.facebook.com/messaging/send/", ctx.jar, form)
63
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
64
+ .then(function (resData) {
65
+ if (!resData) throw { error: "Add to group failed." };
66
+ if (resData.error) throw resData;
67
+
68
+ return callback();
69
+ })
70
+ .catch(function (err) {
71
+ log.error("addUserToGroup", err);
72
+ return callback(err);
73
+ });
74
+
75
+ return returnPromise;
76
+ };
77
+ };