raidenbot 1.1.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 (69) hide show
  1. package/.gitattributes +2 -0
  2. package/.travis.yml +6 -0
  3. package/CHANGELOG.md +2 -0
  4. package/DOCS.md +1738 -0
  5. package/LICENSE-MIT +21 -0
  6. package/README.md +219 -0
  7. package/index.js +542 -0
  8. package/package.json +73 -0
  9. package/replit.nix +5 -0
  10. package/src/Screenshot.js +83 -0
  11. package/src/addExternalModule.js +15 -0
  12. package/src/addUserToGroup.js +77 -0
  13. package/src/changeAdminStatus.js +47 -0
  14. package/src/changeArchivedStatus.js +41 -0
  15. package/src/changeAvt.js +85 -0
  16. package/src/changeBio.js +65 -0
  17. package/src/changeBlockedStatus.js +36 -0
  18. package/src/changeGroupImage.js +106 -0
  19. package/src/changeNickname.js +45 -0
  20. package/src/changeThreadColor.js +61 -0
  21. package/src/changeThreadEmoji.js +41 -0
  22. package/src/createNewGroup.js +70 -0
  23. package/src/createPoll.js +59 -0
  24. package/src/deleteMessage.js +44 -0
  25. package/src/deleteThread.js +42 -0
  26. package/src/forwardAttachment.js +47 -0
  27. package/src/getCurrentUserID.js +7 -0
  28. package/src/getEmojiUrl.js +27 -0
  29. package/src/getFriendsList.js +73 -0
  30. package/src/getThreadHistory.js +537 -0
  31. package/src/getThreadHistoryDeprecated.js +71 -0
  32. package/src/getThreadInfo.js +171 -0
  33. package/src/getThreadInfoDeprecated.js +56 -0
  34. package/src/getThreadList.js +213 -0
  35. package/src/getThreadListDeprecated.js +46 -0
  36. package/src/getThreadPictures.js +59 -0
  37. package/src/getUserID.js +61 -0
  38. package/src/getUserInfo.js +66 -0
  39. package/src/handleFriendRequest.js +46 -0
  40. package/src/handleMessageRequest.js +47 -0
  41. package/src/httpGet.js +49 -0
  42. package/src/httpPost.js +48 -0
  43. package/src/listenMqtt.js +704 -0
  44. package/src/logout.js +68 -0
  45. package/src/markAsDelivered.js +47 -0
  46. package/src/markAsRead.js +70 -0
  47. package/src/markAsReadAll.js +40 -0
  48. package/src/markAsSeen.js +48 -0
  49. package/src/muteThread.js +45 -0
  50. package/src/removeUserFromGroup.js +45 -0
  51. package/src/resolvePhotoUrl.js +36 -0
  52. package/src/searchForThread.js +42 -0
  53. package/src/sendMessage.js +328 -0
  54. package/src/sendTypingIndicator.js +70 -0
  55. package/src/setMessageReaction.js +109 -0
  56. package/src/setPostReaction.js +102 -0
  57. package/src/setTitle.js +70 -0
  58. package/src/shareContact.js +47 -0
  59. package/src/threadColors.js +41 -0
  60. package/src/unfriend.js +42 -0
  61. package/src/unsendMessage.js +39 -0
  62. package/test/data/shareAttach.js +146 -0
  63. package/test/data/something.mov +0 -0
  64. package/test/data/test.png +0 -0
  65. package/test/data/test.txt +7 -0
  66. package/test/example-config.json +18 -0
  67. package/test/test-page.js +140 -0
  68. package/test/test.js +385 -0
  69. package/utils.js +1196 -0
package/index.js ADDED
@@ -0,0 +1,542 @@
1
+ "use strict";
2
+
3
+ var utils = require("./utils");
4
+ var cheerio = require("cheerio");
5
+ var log = require("npmlog");
6
+ var chalk = require('chalk');
7
+ var colors = ['red', 'yellow', 'blue', 'magenta', 'cyan', 'green', 'magentaBright'];
8
+ var checkVerified = null;
9
+
10
+ var defaultLogRecordSize = 100;
11
+ log.maxRecordSize = defaultLogRecordSize;
12
+
13
+ function setOptions(globalOptions, options) {
14
+ Object.keys(options).map(function (key) {
15
+ switch (key) {
16
+ case 'pauseLog':
17
+ if (options.pauseLog) log.pause();
18
+ break;
19
+ case 'online':
20
+ globalOptions.online = Boolean(options.online);
21
+ break;
22
+ case 'logLevel':
23
+ log.level = options.logLevel;
24
+ globalOptions.logLevel = options.logLevel;
25
+ break;
26
+ case 'logRecordSize':
27
+ log.maxRecordSize = options.logRecordSize;
28
+ globalOptions.logRecordSize = options.logRecordSize;
29
+ break;
30
+ case 'selfListen':
31
+ globalOptions.selfListen = Boolean(options.selfListen);
32
+ break;
33
+ case 'listenEvents':
34
+ globalOptions.listenEvents = Boolean(options.listenEvents);
35
+ break;
36
+ case 'pageID':
37
+ globalOptions.pageID = options.pageID.toString();
38
+ break;
39
+ case 'updatePresence':
40
+ globalOptions.updatePresence = Boolean(options.updatePresence);
41
+ break;
42
+ case 'forceLogin':
43
+ globalOptions.forceLogin = Boolean(options.forceLogin);
44
+ break;
45
+ case 'userAgent':
46
+ globalOptions.userAgent = options.userAgent;
47
+ break;
48
+ case 'autoMarkDelivery':
49
+ globalOptions.autoMarkDelivery = Boolean(options.autoMarkDelivery);
50
+ break;
51
+ case 'autoMarkRead':
52
+ globalOptions.autoMarkRead = Boolean(options.autoMarkRead);
53
+ break;
54
+ case 'listenTyping':
55
+ globalOptions.listenTyping = Boolean(options.listenTyping);
56
+ break;
57
+ case 'proxy':
58
+ if (typeof options.proxy != "string") {
59
+ delete globalOptions.proxy;
60
+ utils.setProxy();
61
+ }
62
+ else {
63
+ globalOptions.proxy = options.proxy;
64
+ utils.setProxy(globalOptions.proxy);
65
+ }
66
+ break;
67
+ case 'autoReconnect':
68
+ globalOptions.autoReconnect = Boolean(options.autoReconnect);
69
+ break;
70
+ case 'emitReady':
71
+ globalOptions.emitReady = Boolean(options.emitReady);
72
+ break;
73
+ default:
74
+ log.warn("setOptions", "Unrecognized option given to setOptions: " + key);
75
+ break;
76
+ }
77
+ });
78
+ }
79
+
80
+ function buildAPI(globalOptions, html, jar) {
81
+ var maybeCookie = jar.getCookies("https://www.facebook.com").filter(function (val) {
82
+ return val.cookieString().split("=")[0] === "c_user";
83
+ });
84
+
85
+ if (maybeCookie.length === 0) throw { Lỗi: "Lỗi truy xuất ID người dùng. Điều này có thể do nhiều nguyên nhân gây ra, bao gồm cả việc bị Facebook chặn đăng nhập từ một địa điểm không xác định. Hãy thử đăng nhập bằng trình duyệt để xác minh. (Hoặc có thể sai tài khoản, mật khẩu)" };
86
+
87
+ if (html.indexOf("/checkpoint/block/?next") > -1) log.warn("login", "Checkpoint detected. Please log in with a browser to verify.");
88
+
89
+ var userID = Object.values(jar._jar.store.idx['facebook.com']['/']).map($=>$.toString()).join(';').match(/i_user=([^;]+);/)?.[1]||maybeCookie[0].cookieString().split("=")[1].toString();
90
+ console.log(chalk.bold[colors[Math.floor(Math.random() * colors.length)]](`┣➤ [ LOGIN ] » [ RaidenBot ] » Đăng Nhập Tại `) + chalk[colors[Math.floor(Math.random() * colors.length)]](userID));
91
+
92
+ try {
93
+ clearInterval(checkVerified);
94
+ }
95
+ catch (_) { }
96
+
97
+ var clientID = (Math.random() * 2147483648 | 0).toString(16);
98
+
99
+ let oldFBMQTTMatch = html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/);
100
+ let mqttEndpoint = null;
101
+ let region = null;
102
+ let irisSeqID = null;
103
+ var noMqttData = null;
104
+
105
+ if (oldFBMQTTMatch) {
106
+ irisSeqID = oldFBMQTTMatch[1];
107
+ mqttEndpoint = oldFBMQTTMatch[2];
108
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
109
+ console.log(chalk.bold[colors[Math.floor(Math.random() * colors.length)]](`┣➤ [ LOGIN ] » [ RaidenBot ] » Đã nhận được vùng tin nhắn của tài khoản này: `) + chalk[colors[Math.floor(Math.random() * colors.length)]](region));
110
+ }
111
+ else {
112
+ let newFBMQTTMatch = html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/);
113
+ if (newFBMQTTMatch) {
114
+ irisSeqID = newFBMQTTMatch[2];
115
+ mqttEndpoint = newFBMQTTMatch[1].replace(/\\\//g, "/");
116
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
117
+ console.log(chalk.bold[colors[Math.floor(Math.random() * colors.length)]](`┣➤ [ LOGIN ] » [ RaidenBot ] » Đã nhận được vùng tin nhắn của tài khoản này: `) + chalk[colors[Math.floor(Math.random() * colors.length)]](region));
118
+ }
119
+ else {
120
+ let legacyFBMQTTMatch = html.match(/(\["MqttWebConfig",\[\],{fbid:")(.+?)(",appID:219994525426954,endpoint:")(.+?)(",pollingEndpoint:")(.+?)(3790])/);
121
+ if (legacyFBMQTTMatch) {
122
+ mqttEndpoint = legacyFBMQTTMatch[4];
123
+ region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
124
+ log.warn("login", `Cannot get sequence ID with new RegExp. Fallback to old RegExp (without seqID)...`);
125
+ console.log(chalk.bold[colors[Math.floor(Math.random() * colors.length)]](`┣➤ [ LOGIN ] » [ RaidenBot ] » Đã nhận được vùng tin nhắn của tài khoản này: `) + chalk[colors[Math.floor(Math.random() * colors.length)]](region));
126
+ log.info("login", `[Unused] Polling endpoint: ${legacyFBMQTTMatch[6]}`);
127
+ }
128
+ else {
129
+ log.warn("login", "Cannot get MQTT region & sequence ID.");
130
+ noMqttData = html;
131
+ }
132
+ }
133
+ }
134
+
135
+ // All data available to api functions
136
+ var ctx = {
137
+ userID: userID,
138
+ jar: jar,
139
+ clientID: clientID,
140
+ globalOptions: globalOptions,
141
+ loggedIn: true,
142
+ access_token: 'NONE',
143
+ clientMutationId: 0,
144
+ mqttClient: undefined,
145
+ lastSeqId: irisSeqID,
146
+ syncToken: undefined,
147
+ mqttEndpoint,
148
+ region,
149
+ firstListen: true
150
+ };
151
+
152
+ var api = {
153
+ setOptions: setOptions.bind(null, globalOptions),
154
+ getAppState: function getAppState() {
155
+ return utils.getAppState(jar);
156
+ }
157
+ };
158
+
159
+ if (noMqttData) api["htmlData"] = noMqttData;
160
+
161
+ const apiFuncNames = [
162
+ 'addExternalModule',
163
+ 'addUserToGroup',
164
+ 'changeAdminStatus',
165
+ 'changeArchivedStatus',
166
+ 'changeBio',
167
+ 'changeBlockedStatus',
168
+ 'changeGroupImage',
169
+ 'changeNickname',
170
+ 'changeThreadColor',
171
+ 'changeThreadEmoji',
172
+ 'createNewGroup',
173
+ 'createPoll',
174
+ 'deleteMessage',
175
+ 'deleteThread',
176
+ 'forwardAttachment',
177
+ 'getCurrentUserID',
178
+ 'getEmojiUrl',
179
+ 'getFriendsList',
180
+ 'getThreadHistory',
181
+ 'getThreadInfo',
182
+ 'getThreadList',
183
+ 'getThreadPictures',
184
+ 'getUserID',
185
+ 'getUserInfo',
186
+ 'handleMessageRequest',
187
+ 'listenMqtt',
188
+ 'logout',
189
+ 'markAsDelivered',
190
+ 'markAsRead',
191
+ 'markAsReadAll',
192
+ 'markAsSeen',
193
+ 'muteThread',
194
+ 'removeUserFromGroup',
195
+ 'resolvePhotoUrl',
196
+ 'searchForThread',
197
+ 'sendMessage',
198
+ 'sendTypingIndicator',
199
+ 'setMessageReaction',
200
+ 'setTitle',
201
+ 'threadColors',
202
+ 'unsendMessage',
203
+ 'unfriend',
204
+ 'shareContact',
205
+
206
+ // HTTP
207
+ 'httpGet',
208
+ 'httpPost',
209
+
210
+ // Deprecated features
211
+ "getThreadListDeprecated",
212
+ 'getThreadHistoryDeprecated',
213
+ 'getThreadInfoDeprecated',
214
+ ];
215
+
216
+ var defaultFuncs = utils.makeDefaults(html, userID, ctx);
217
+ api.postFormData = function(url, body) {
218
+ return defaultFuncs.postFormData(url, ctx.jar, body);
219
+ };
220
+ // Load all api functions in a loop
221
+ apiFuncNames.map(v => api[v] = require('./src/' + v)(defaultFuncs, api, ctx));
222
+
223
+ return [ctx, defaultFuncs, api];
224
+ }
225
+
226
+ function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
227
+ return function (res) {
228
+ var html = res.body;
229
+ var $ = cheerio.load(html);
230
+ var arr = [];
231
+
232
+ // This will be empty, but just to be sure we leave it
233
+ $("#login_form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
234
+
235
+ arr = arr.filter(function (v) {
236
+ return v.val && v.val.length;
237
+ });
238
+
239
+ var form = utils.arrToForm(arr);
240
+ form.lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
241
+ form.lgndim = Buffer.from("{\"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 = ~~(Date.now() / 1000);
249
+
250
+
251
+ // Getting cookies from the HTML page... (kill me now plz)
252
+ // we used to get a bunch of cookies in the headers of the response of the
253
+ // request, but FB changed and they now send those cookies inside the JS.
254
+ // They run the JS which then injects the cookies in the page.
255
+ // The "solution" is to parse through the html and find those cookies
256
+ // which happen to be conveniently indicated with a _js_ in front of their
257
+ // variable name.
258
+ //
259
+ // ---------- Very Hacky Part Starts -----------------
260
+ var willBeCookies = html.split("\"_js_");
261
+ willBeCookies.slice(1).map(function (val) {
262
+ var cookieData = JSON.parse("[\"" + utils.getFrom(val, "", "]") + "]");
263
+ jar.setCookie(utils.formatCookie(cookieData, "facebook"), "https://www.facebook.com");
264
+ });
265
+ // ---------- Very Hacky Part Ends -----------------
266
+
267
+ log.info("RaidenBot", "Đang Đăng Nhập...");
268
+ return utils
269
+ .post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, form, loginOptions)
270
+ .then(utils.saveCookies(jar))
271
+ .then(function (res) {
272
+ var headers = res.headers;
273
+ if (!headers.location) throw { error: "Wrong username/password." };
274
+
275
+ // This means the account has login approvals turned on.
276
+ if (headers.location.indexOf('https://www.facebook.com/checkpoint/') > -1) {
277
+ log.info("login", "You have login approvals turned on.");
278
+ var nextURL = 'https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php';
279
+
280
+ return utils
281
+ .get(headers.location, jar, null, loginOptions)
282
+ .then(utils.saveCookies(jar))
283
+ .then(function (res) {
284
+ var html = res.body;
285
+ // Make the form in advance which will contain the fb_dtsg and nh
286
+ var $ = cheerio.load(html);
287
+ var arr = [];
288
+ $("form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
289
+
290
+ arr = arr.filter(function (v) {
291
+ return v.val && v.val.length;
292
+ });
293
+
294
+ var form = utils.arrToForm(arr);
295
+ if (html.indexOf("checkpoint/?next") > -1) {
296
+ setTimeout(() => {
297
+ checkVerified = setInterval((_form) => { }, 5000, {
298
+ fb_dtsg: form.fb_dtsg,
299
+ jazoest: form.jazoest,
300
+ dpr: 1
301
+ });
302
+ }, 2500);
303
+ throw {
304
+ error: 'login-approval',
305
+ continue: function submit2FA(code) {
306
+ form.approvals_code = code;
307
+ form['submit[Continue]'] = $("#checkpointSubmitButton").html(); //'Continue';
308
+ var prResolve = null;
309
+ var prReject = null;
310
+ var rtPromise = new Promise(function (resolve, reject) {
311
+ prResolve = resolve;
312
+ prReject = reject;
313
+ });
314
+ if (typeof code == "string") {
315
+ utils
316
+ .post(nextURL, jar, form, loginOptions)
317
+ .then(utils.saveCookies(jar))
318
+ .then(function (res) {
319
+ var $ = cheerio.load(res.body);
320
+ var error = $("#approvals_code").parent().attr("data-xui-error");
321
+ if (error) {
322
+ throw {
323
+ error: 'login-approval',
324
+ errordesc: "Invalid 2FA code.",
325
+ lerror: error,
326
+ continue: submit2FA
327
+ };
328
+ }
329
+ })
330
+ .then(function () {
331
+ // Use the same form (safe I hope)
332
+ delete form.no_fido;
333
+ delete form.approvals_code;
334
+ form.name_action_selected = 'dont_save'; //'save_device';
335
+
336
+ return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
337
+ })
338
+ .then(function (res) {
339
+ var headers = res.headers;
340
+ if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: "Something went wrong with login approvals." };
341
+
342
+ var appState = utils.getAppState(jar);
343
+
344
+ if (callback === prCallback) {
345
+ callback = function (err, api) {
346
+ if (err) return prReject(err);
347
+ return prResolve(api);
348
+ };
349
+ }
350
+
351
+ // Simply call loginHelper because all it needs is the jar
352
+ // and will then complete the login process
353
+ return loginHelper(appState, email, password, loginOptions, callback);
354
+ })
355
+ .catch(function (err) {
356
+ // Check if using Promise instead of callback
357
+ if (callback === prCallback) prReject(err);
358
+ else callback(err);
359
+ });
360
+ }
361
+ else {
362
+ utils
363
+ .post("https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php", jar, form, loginOptions, null, { "Referer": "https://www.facebook.com/checkpoint/?next" })
364
+ .then(utils.saveCookies(jar))
365
+ .then(res => {
366
+ try {
367
+ JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, ""));
368
+ }
369
+ catch (ex) {
370
+ clearInterval(checkVerified);
371
+ log.info("login", "Verified from browser. Logging in...");
372
+ if (callback === prCallback) {
373
+ callback = function (err, api) {
374
+ if (err) return prReject(err);
375
+ return prResolve(api);
376
+ };
377
+ }
378
+ return loginHelper(utils.getAppState(jar), email, password, loginOptions, callback);
379
+ }
380
+ })
381
+ .catch(ex => {
382
+ log.error("login", ex);
383
+ if (callback === prCallback) prReject(ex);
384
+ else callback(ex);
385
+ });
386
+ }
387
+ return rtPromise;
388
+ }
389
+ };
390
+ }
391
+ else {
392
+ if (!loginOptions.forceLogin) throw { error: "Couldn't login. Facebook might have blocked this account. Please login with a browser or enable the option 'forceLogin' and try again." };
393
+
394
+ if (html.indexOf("Suspicious Login Attempt") > -1) form['submit[This was me]'] = "This was me";
395
+ else form['submit[This Is Okay]'] = "This Is Okay";
396
+
397
+ return utils
398
+ .post(nextURL, jar, form, loginOptions)
399
+ .then(utils.saveCookies(jar))
400
+ .then(function () {
401
+ // Use the same form (safe I hope)
402
+ form.name_action_selected = 'save_device';
403
+
404
+ return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
405
+ })
406
+ .then(function (res) {
407
+ var headers = res.headers;
408
+
409
+ if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: "Something went wrong with review recent login." };
410
+
411
+ var appState = utils.getAppState(jar);
412
+
413
+ // Simply call loginHelper because all it needs is the jar
414
+ // and will then complete the login process
415
+ return loginHelper(appState, email, password, loginOptions, callback);
416
+ })
417
+ .catch(e => callback(e));
418
+ }
419
+ });
420
+ }
421
+
422
+ return utils.get('https://www.facebook.com/', jar, null, loginOptions).then(utils.saveCookies(jar));
423
+ });
424
+ };
425
+ }
426
+
427
+ // Helps the login
428
+ function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
429
+ var mainPromise = null;
430
+ var jar = utils.getJar();
431
+
432
+ // If we're given an appState we loop through it and save each cookie
433
+ // back into the jar.
434
+ if (appState) {
435
+ appState.map(function (c) {
436
+ var str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
437
+ jar.setCookie(str, "http://" + c.domain);
438
+ });
439
+
440
+ // Load the main page.
441
+ mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
442
+ }
443
+ else {
444
+ // Open the main page, then we login with the given credentials and finally
445
+ // load the main page again (it'll give us some IDs that we need)
446
+ mainPromise = utils
447
+ .get("https://www.facebook.com/", null, null, globalOptions, { noRef: true })
448
+ .then(utils.saveCookies(jar))
449
+ .then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
450
+ .then(function () {
451
+ return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(utils.saveCookies(jar));
452
+ });
453
+ }
454
+
455
+ var ctx = null;
456
+ var _defaultFuncs = null;
457
+ var api = null;
458
+
459
+ mainPromise = mainPromise
460
+ .then(function (res) {
461
+ // Hacky check for the redirection that happens on some ISPs, which doesn't return statusCode 3xx
462
+ var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
463
+ var redirect = reg.exec(res.body);
464
+ if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
465
+ return res;
466
+ })
467
+ .then(function (res) {
468
+ var html = res.body;
469
+ var stuff = buildAPI(globalOptions, html, jar);
470
+ ctx = stuff[0];
471
+ _defaultFuncs = stuff[1];
472
+ api = stuff[2];
473
+ return res;
474
+ });
475
+
476
+ // given a pageID we log in as a page
477
+ if (globalOptions.pageID) {
478
+ mainPromise = mainPromise
479
+ .then(function () {
480
+ return utils.get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
481
+ })
482
+ .then(function (resData) {
483
+ var url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
484
+ url = url.substring(0, url.length - 1);
485
+ return utils.get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
486
+ });
487
+ }
488
+
489
+ // At the end we call the callback or catch an exception
490
+ mainPromise
491
+ .then(function () {
492
+ console.log(chalk.bold.yellow('┣➤ [ LOGIN ] » [ RaidenBot ] » Đăng Nhập Thành Công 👑'));
493
+ return callback(null, api);
494
+ })
495
+ .catch(function (e) {
496
+ log.error("login", e.error || e);
497
+ callback(e);
498
+ });
499
+ }
500
+
501
+ function login(loginData, options, callback) {
502
+ if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
503
+ callback = options;
504
+ options = {};
505
+ }
506
+
507
+ var globalOptions = {
508
+ selfListen: false,
509
+ listenEvents: true,
510
+ listenTyping: false,
511
+ updatePresence: false,
512
+ forceLogin: false,
513
+ autoMarkDelivery: true,
514
+ autoMarkRead: false,
515
+ autoReconnect: true,
516
+ logRecordSize: defaultLogRecordSize,
517
+ online: true,
518
+ emitReady: false,
519
+ userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/8.0.3 Safari/600.3.18"
520
+ };
521
+
522
+ setOptions(globalOptions, options);
523
+
524
+ var prCallback = null;
525
+ if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
526
+ var rejectFunc = null;
527
+ var resolveFunc = null;
528
+ var returnPromise = new Promise(function (resolve, reject) {
529
+ resolveFunc = resolve;
530
+ rejectFunc = reject;
531
+ });
532
+ prCallback = function (error, api) {
533
+ if (error) return rejectFunc(error);
534
+ return resolveFunc(api);
535
+ };
536
+ callback = prCallback;
537
+ }
538
+ loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
539
+ return returnPromise;
540
+ }
541
+
542
+ module.exports = login;
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "raidenbot",
3
+ "version": "1.1.2",
4
+ "description": "Fca được reup lại nhằm mục đích cá nhân",
5
+ "scripts": {
6
+ "test": "mocha",
7
+ "lint": "eslint **.js",
8
+ "prettier": "prettier utils.js src/* --write"
9
+ },
10
+ "keywords": [
11
+ "facebook",
12
+ "chat",
13
+ "api",
14
+ "fca"
15
+ ],
16
+ "author": "TuanDz",
17
+ "license": "TuanDz",
18
+ "dependencies": {
19
+ "bluebird": "^2.11.0",
20
+ "cheerio": "^1.0.0-rc.10",
21
+ "https-proxy-agent": "^4.0.0",
22
+ "mqtt": "^4.2.8",
23
+ "npmlog": "^1.2.0",
24
+ "request": "^2.53.0",
25
+ "websocket-stream": "^5.5.0"
26
+ },
27
+ "engines": {
28
+ "node": ">=10.x"
29
+ },
30
+ "devDependencies": {
31
+ "eslint": "^7.5.0",
32
+ "mocha": "^7.0.1",
33
+ "prettier": "^1.11.1"
34
+ },
35
+ "eslintConfig": {
36
+ "env": {
37
+ "es6": true,
38
+ "es2017": true,
39
+ "node": true
40
+ },
41
+ "extends": "eslint:recommended",
42
+ "parserOptions": {
43
+ "sourceType": "module"
44
+ },
45
+ "rules": {
46
+ "linebreak-style": [
47
+ "error",
48
+ "unix"
49
+ ],
50
+ "semi": [
51
+ "error",
52
+ "always"
53
+ ],
54
+ "no-unused-vars": [
55
+ 1,
56
+ {
57
+ "argsIgnorePattern": "^_",
58
+ "varsIgnorePattern": "^_"
59
+ }
60
+ ],
61
+ "no-empty": [
62
+ "error",
63
+ {
64
+ "allowEmptyCatch": true
65
+ }
66
+ ]
67
+ }
68
+ },
69
+ "main": "index.js",
70
+ "directories": {
71
+ "test": "test"
72
+ }
73
+ }
package/replit.nix ADDED
@@ -0,0 +1,5 @@
1
+ {pkgs}: {
2
+ deps = [
3
+ pkgs.unzipNLS
4
+ ];
5
+ }