alicezetion 1.7.1 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -1
  2. package/.cache/replit/nix/env.json +1 -1
  3. package/Extra/Database/index.js +399 -0
  4. package/Extra/Database/methods.js +286 -0
  5. package/Extra/ExtraAddons.js +213 -0
  6. package/Extra/ExtraGetThread.js +1 -0
  7. package/Extra/ExtraUptimeRobot.js +59 -0
  8. package/Extra/PM2/ecosystem.config.js +23 -0
  9. package/Extra/Src/Last-Run.js +48 -0
  10. package/Language/index.json +151 -0
  11. package/StateCrypt.js +22 -0
  12. package/broadcast.js +42 -0
  13. package/index.js +654 -119
  14. package/logger.js +21 -0
  15. package/package.json +37 -25
  16. package/replit.nix +3 -4
  17. package/src/addExternalModule.js +13 -5
  18. package/src/addUserToGroup.js +36 -12
  19. package/src/changeAdminStatus.js +85 -37
  20. package/src/changeArchivedStatus.js +15 -9
  21. package/src/changeAvt.js +91 -0
  22. package/src/changeBio.js +13 -8
  23. package/src/changeBlockedStatus.js +14 -8
  24. package/src/changeGroupImage.js +28 -13
  25. package/src/changeNickname.js +22 -11
  26. package/src/changeThreadColor.js +16 -10
  27. package/src/changeThreadEmoji.js +18 -9
  28. package/src/chat.js +401 -280
  29. package/src/createNewGroup.js +18 -10
  30. package/src/createPoll.js +17 -11
  31. package/src/deleteMessage.js +17 -10
  32. package/src/deleteThread.js +17 -10
  33. package/src/forwardAttachment.js +15 -9
  34. package/src/getAccessToken.js +32 -0
  35. package/src/getCurrentUserID.js +1 -1
  36. package/src/getEmojiUrl.js +3 -2
  37. package/src/getFriendsList.js +18 -10
  38. package/src/getMessage.js +84 -0
  39. package/src/getThreadHistory.js +156 -59
  40. package/src/getThreadHistoryDeprecated.js +26 -15
  41. package/src/getThreadInfo.js +68 -42
  42. package/src/getThreadInfoDeprecated.js +25 -13
  43. package/src/getThreadList.js +112 -53
  44. package/src/getThreadListDeprecated.js +30 -12
  45. package/src/getThreadPictures.js +25 -13
  46. package/src/getUserID.js +9 -7
  47. package/src/getUserInfo.js +12 -10
  48. package/src/getUserInfoV2.js +35 -0
  49. package/src/handleFriendRequest.js +36 -35
  50. package/src/handleMessageRequest.js +18 -10
  51. package/src/httpGet.js +20 -13
  52. package/src/httpPost.js +19 -13
  53. package/src/httpPostFormData.js +46 -0
  54. package/src/listenMqtt.js +1224 -621
  55. package/src/logout.js +18 -13
  56. package/src/markAsDelivered.js +17 -10
  57. package/src/markAsRead.js +36 -24
  58. package/src/markAsSeen.js +22 -12
  59. package/src/muteThread.js +15 -9
  60. package/src/{setMessageReaction.js → react.js} +20 -9
  61. package/src/removeUserFromGroup.js +38 -11
  62. package/src/resolvePhotoUrl.js +9 -6
  63. package/src/searchForThread.js +14 -8
  64. package/src/{markAsReadAll.js → seen.js} +17 -10
  65. package/src/sendTypingIndicator.js +44 -19
  66. package/src/setPostReaction.js +63 -22
  67. package/src/setTitle.js +22 -12
  68. package/src/threadColors.js +17 -19
  69. package/src/unfriend.js +15 -9
  70. package/src/{unsendMessage.js → unsend.js} +9 -8
  71. package/utils.js +120 -27
  72. package/.travis.yml +0 -6
  73. package/src/forwardMessage.js +0 -0
  74. package/src/listen.js +0 -553
  75. package/src/listenMqtt-Test.js +0 -687
  76. package/src/sendMessage.js +0 -315
  77. package/test/data/shareAttach.js +0 -146
  78. package/test/data/something.mov +0 -0
  79. package/test/data/test.png +0 -0
  80. package/test/data/test.txt +0 -7
  81. package/test/example-config.json +0 -18
  82. package/test/test-page.js +0 -140
  83. package/test/test.js +0 -385
@@ -3,26 +3,30 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function createNewGroup(participantIDs, groupTitle, callback) {
8
8
  if (utils.getType(groupTitle) == "Function") {
9
9
  callback = groupTitle;
10
10
  groupTitle = null;
11
11
  }
12
12
 
13
- if (utils.getType(participantIDs) !== "Array") throw { error: "createNewGroup: participantIDs should be an array." };
13
+ if (utils.getType(participantIDs) !== "Array")
14
+ throw { error: "createNewGroup: participantIDs should be an array." };
14
15
 
15
- if (participantIDs.length < 2) throw { error: "createNewGroup: participantIDs should have at least 2 IDs." };
16
+ if (participantIDs.length < 2)
17
+ throw {
18
+ error: "createNewGroup: participantIDs should have at least 2 IDs."
19
+ };
16
20
 
17
- var resolveFunc = function () { };
18
- var rejectFunc = function () { };
19
- var returnPromise = new Promise(function (resolve, reject) {
21
+ var resolveFunc = function() {};
22
+ var rejectFunc = function() {};
23
+ var returnPromise = new Promise(function(resolve, reject) {
20
24
  resolveFunc = resolve;
21
25
  rejectFunc = reject;
22
26
  });
23
27
 
24
28
  if (!callback) {
25
- callback = function (err, threadID) {
29
+ callback = function(err, threadID) {
26
30
  if (err) return rejectFunc(err);
27
31
  resolveFunc(threadID);
28
32
  };
@@ -56,11 +60,15 @@ module.exports = function (defaultFuncs, api, ctx) {
56
60
  defaultFuncs
57
61
  .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
58
62
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
59
- .then(function (resData) {
63
+ .then(function(resData) {
60
64
  if (resData.errors) throw resData;
61
- return callback(null, resData.data.messenger_group_thread_create.thread.thread_key.thread_fbid);
65
+ return callback(
66
+ null,
67
+ resData.data.messenger_group_thread_create.thread.thread_key
68
+ .thread_fbid
69
+ );
62
70
  })
63
- .catch(function (err) {
71
+ .catch(function(err) {
64
72
  log.error("createNewGroup", err);
65
73
  return callback(err);
66
74
  });
package/src/createPoll.js CHANGED
@@ -3,11 +3,11 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function createPoll(title, threadID, options, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
8
+ var resolveFunc = function() {};
9
+ var rejectFunc = function() {};
10
+ var returnPromise = new Promise(function(resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
13
13
  });
@@ -16,9 +16,8 @@ module.exports = function (defaultFuncs, api, ctx) {
16
16
  if (utils.getType(options) == "Function") {
17
17
  callback = options;
18
18
  options = null;
19
- }
20
- else {
21
- callback = function (err) {
19
+ } else {
20
+ callback = function(err) {
22
21
  if (err) return rejectFunc(err);
23
22
  resolveFunc();
24
23
  };
@@ -37,19 +36,26 @@ module.exports = function (defaultFuncs, api, ctx) {
37
36
  // eslint-disable-next-line no-prototype-builtins
38
37
  if (options.hasOwnProperty(opt)) {
39
38
  form["option_text_array[" + ind + "]"] = opt;
40
- form["option_is_selected_array[" + ind + "]"] = options[opt] ? "1" : "0";
39
+ form["option_is_selected_array[" + ind + "]"] = options[opt]
40
+ ? "1"
41
+ : "0";
41
42
  ind++;
42
43
  }
43
44
  }
44
45
 
45
46
  defaultFuncs
46
- .post("https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1", ctx.jar, form)
47
+ .post(
48
+ "https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1",
49
+ ctx.jar,
50
+ form
51
+ )
47
52
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
48
- .then(function (resData) {
53
+ .then(function(resData) {
49
54
  if (resData.payload.status != "success") throw resData;
55
+
50
56
  return callback();
51
57
  })
52
- .catch(function (err) {
58
+ .catch(function(err) {
53
59
  log.error("createPoll", err);
54
60
  return callback(err);
55
61
  });
@@ -3,16 +3,16 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function deleteMessage(messageOrMessages, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
8
+ var resolveFunc = function() {};
9
+ var rejectFunc = function() {};
10
+ var returnPromise = new Promise(function(resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
13
13
  });
14
14
  if (!callback) {
15
- callback = function (err) {
15
+ callback = function(err) {
16
16
  if (err) return rejectFunc(err);
17
17
 
18
18
  resolveFunc();
@@ -23,18 +23,25 @@ module.exports = function (defaultFuncs, api, ctx) {
23
23
  client: "mercury"
24
24
  };
25
25
 
26
- if (utils.getType(messageOrMessages) !== "Array") messageOrMessages = [messageOrMessages];
26
+ if (utils.getType(messageOrMessages) !== "Array")
27
+ messageOrMessages = [messageOrMessages];
27
28
 
28
- for (var i = 0; i < messageOrMessages.length; i++) form["message_ids[" + i + "]"] = messageOrMessages[i];
29
+ for (var i = 0; i < messageOrMessages.length; i++)
30
+ form["message_ids[" + i + "]"] = messageOrMessages[i];
29
31
 
30
32
  defaultFuncs
31
- .post("https://www.facebook.com/ajax/mercury/delete_messages.php", ctx.jar, form)
33
+ .post(
34
+ "https://www.facebook.com/ajax/mercury/delete_messages.php",
35
+ ctx.jar,
36
+ form
37
+ )
32
38
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
33
- .then(function (resData) {
39
+ .then(function(resData) {
34
40
  if (resData.error) throw resData;
41
+
35
42
  return callback();
36
43
  })
37
- .catch(function (err) {
44
+ .catch(function(err) {
38
45
  log.error("deleteMessage", err);
39
46
  return callback(err);
40
47
  });
@@ -3,16 +3,16 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function deleteThread(threadOrThreads, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
8
+ var resolveFunc = function() {};
9
+ var rejectFunc = function() {};
10
+ var returnPromise = new Promise(function(resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
13
13
  });
14
14
  if (!callback) {
15
- callback = function (err) {
15
+ callback = function(err) {
16
16
  if (err) return rejectFunc(err);
17
17
  resolveFunc();
18
18
  };
@@ -22,17 +22,24 @@ module.exports = function (defaultFuncs, api, ctx) {
22
22
  client: "mercury"
23
23
  };
24
24
 
25
- if (utils.getType(threadOrThreads) !== "Array") threadOrThreads = [threadOrThreads];
26
- for (var i = 0; i < threadOrThreads.length; i++) form["ids[" + i + "]"] = threadOrThreads[i];
25
+ if (utils.getType(threadOrThreads) !== "Array")
26
+ threadOrThreads = [threadOrThreads];
27
+ for (var i = 0; i < threadOrThreads.length; i++)
28
+ form["ids[" + i + "]"] = threadOrThreads[i];
27
29
 
28
30
  defaultFuncs
29
- .post("https://www.facebook.com/ajax/mercury/delete_thread.php", ctx.jar, form)
31
+ .post(
32
+ "https://www.facebook.com/ajax/mercury/delete_thread.php",
33
+ ctx.jar,
34
+ form
35
+ )
30
36
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
31
- .then(function (resData) {
37
+ .then(function(resData) {
32
38
  if (resData.error) throw resData;
39
+
33
40
  return callback();
34
41
  })
35
- .catch(function (err) {
42
+ .catch(function(err) {
36
43
  log.error("deleteThread", err);
37
44
  return callback(err);
38
45
  });
@@ -3,16 +3,16 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function forwardAttachment(attachmentID, userOrUsers, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
8
+ var resolveFunc = function() {};
9
+ var rejectFunc = function() {};
10
+ var returnPromise = new Promise(function(resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
13
13
  });
14
14
  if (!callback) {
15
- callback = function (err) {
15
+ callback = function(err) {
16
16
  if (err) return rejectFunc(err);
17
17
  resolveFunc();
18
18
  };
@@ -28,16 +28,22 @@ module.exports = function (defaultFuncs, api, ctx) {
28
28
 
29
29
  //That's good, the key of the array is really timestmap in seconds + index
30
30
  //Probably time when the attachment will be sent?
31
- for (var i = 0; i < userOrUsers.length; i++) form["recipient_map[" + (timestamp + i) + "]"] = userOrUsers[i];
31
+ for (var i = 0; i < userOrUsers.length; i++)
32
+ form["recipient_map[" + (timestamp + i) + "]"] = userOrUsers[i];
32
33
 
33
34
  defaultFuncs
34
- .post("https://www.facebook.com/mercury/attachments/forward/", ctx.jar, form)
35
+ .post(
36
+ "https://www.facebook.com/mercury/attachments/forward/",
37
+ ctx.jar,
38
+ form
39
+ )
35
40
  .then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
36
- .then(function (resData) {
41
+ .then(function(resData) {
37
42
  if (resData.error) throw resData;
43
+
38
44
  return callback();
39
45
  })
40
- .catch(function (err) {
46
+ .catch(function(err) {
41
47
  log.error("forwardAttachment", err);
42
48
  return callback(err);
43
49
  });
@@ -0,0 +1,32 @@
1
+ /* eslint-disable linebreak-style */
2
+ "use strict";
3
+
4
+ var utils = require("../utils");
5
+ var log = require("npmlog");
6
+
7
+
8
+ module.exports = function (defaultFuncs, api, ctx) {
9
+ return function getAccessToken(callback) {
10
+ var resolveFunc = function () { };
11
+ var rejectFunc = function () { };
12
+ var returnPromise = new Promise(function (resolve, reject) {
13
+ resolveFunc = resolve;
14
+ rejectFunc = reject;
15
+ });
16
+
17
+ if (!callback) {
18
+ callback = function (err, userInfo) {
19
+ if (err) return rejectFunc(err);
20
+ resolveFunc(userInfo);
21
+ };
22
+ }
23
+ try {
24
+ var { getAccessToken } = require('../Extra/ExtraAddons');
25
+ getAccessToken(ctx.jar,ctx,defaultFuncs).then(data => callback(null,data));
26
+ }
27
+ catch (e) {
28
+ callback(null, e);
29
+ }
30
+ return returnPromise;
31
+ };
32
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- module.exports = function (defaultFuncs, api, ctx) {
3
+ module.exports = function(defaultFuncs, api, ctx) {
4
4
  return function getCurrentUserID() {
5
5
  return ctx.userID;
6
6
  };
@@ -2,7 +2,7 @@
2
2
 
3
3
  const util = require("util");
4
4
 
5
- module.exports = function () {
5
+ module.exports = function() {
6
6
  return function getEmojiUrl(c, size, pixelRatio) {
7
7
  /*
8
8
  Resolves Facebook Messenger emoji image asset URL for an emoji character.
@@ -19,7 +19,8 @@ module.exports = function () {
19
19
  c.codePointAt(0).toString(16)
20
20
  );
21
21
  let base = 317426846;
22
- for (let i = 0; i < ending.length; i++) base = (base << 5) - base + ending.charCodeAt(i);
22
+ for (let i = 0; i < ending.length; i++)
23
+ base = (base << 5) - base + ending.charCodeAt(i);
23
24
 
24
25
  let hashed = (base & 255).toString(16);
25
26
  return util.format(baseUrl, hashed, ending);
@@ -21,7 +21,7 @@ var GENDERS = {
21
21
  };
22
22
 
23
23
  function formatData(obj) {
24
- return Object.keys(obj).map(function (key) {
24
+ return Object.keys(obj).map(function(key) {
25
25
  var user = obj[key];
26
26
  return {
27
27
  alternateName: user.alternateName,
@@ -39,32 +39,40 @@ function formatData(obj) {
39
39
  });
40
40
  }
41
41
 
42
- module.exports = function (defaultFuncs, api, ctx) {
42
+ module.exports = function(defaultFuncs, api, ctx) {
43
43
  return function getFriendsList(callback) {
44
- var resolveFunc = function () { };
45
- var rejectFunc = function () { };
46
- var returnPromise = new Promise(function (resolve, reject) {
44
+ var resolveFunc = function() {};
45
+ var rejectFunc = function() {};
46
+ var returnPromise = new Promise(function(resolve, reject) {
47
47
  resolveFunc = resolve;
48
48
  rejectFunc = reject;
49
49
  });
50
50
 
51
51
  if (!callback) {
52
- callback = function (err, friendList) {
52
+ callback = function(err, friendList) {
53
53
  if (err) return rejectFunc(err);
54
54
  resolveFunc(friendList);
55
55
  };
56
56
  }
57
57
 
58
58
  defaultFuncs
59
- .postFormData("https://www.facebook.com/chat/user_info_all", ctx.jar, {}, { viewer: ctx.userID })
59
+ .postFormData(
60
+ "https://www.facebook.com/chat/user_info_all",
61
+ ctx.jar,
62
+ {},
63
+ { viewer: ctx.userID }
64
+ )
60
65
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
61
- .then(function (resData) {
66
+ .then(function(resData) {
62
67
  if (!resData) throw { error: "getFriendsList returned empty object." };
63
68
  if (resData.error) throw resData;
64
69
  callback(null, formatData(resData.payload));
65
70
  })
66
- .catch(function (err) {
67
- log.error("getFriendsList", err);
71
+ .catch(function(err) {
72
+ log.error(
73
+ "getFriendsList",
74
+ "Lỗi getFriendsList Có Thể Do Bạn Spam Quá Nhiều ! Hãy Hạn Chế !"
75
+ );
68
76
  return callback(err);
69
77
  });
70
78
 
@@ -0,0 +1,84 @@
1
+ /* eslint-disable linebreak-style */
2
+ "use strict";
3
+
4
+ var utils = require("../utils");
5
+ var log = require("npmlog");
6
+
7
+ module.exports = function(defaultFuncs, api, ctx) {
8
+ return function getMessage(threadID, messageID, callback) {
9
+ if (!callback) {
10
+ return callback({ error: "getMessage: need callback" });
11
+ }
12
+
13
+ if (!threadID || !messageID) {
14
+ return callback({ error: "getMessage: need threadID and messageID" });
15
+ }
16
+
17
+ const form = {
18
+ av: ctx.globalOptions.pageID,
19
+ queries: JSON.stringify({
20
+ o0: {
21
+ //This doc_id is valid as of ? (prob January 18, 2020)
22
+ doc_id: "1768656253222505",
23
+ query_params: {
24
+ thread_and_message_id: {
25
+ thread_id: threadID,
26
+ message_id: messageID
27
+ }
28
+ }
29
+ }
30
+ })
31
+ };
32
+
33
+ defaultFuncs
34
+ .post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
35
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
36
+ .then(resData => {
37
+ if (resData[resData.length - 1].error_results > 0) {
38
+ throw resData[0].o0.errors;
39
+ }
40
+
41
+ if (resData[resData.length - 1].successful_results === 0) {
42
+ throw {
43
+ error: "getMessage: there was no successful_results",
44
+ res: resData
45
+ };
46
+ }
47
+
48
+ var fetchData = resData[0].o0.data.message;
49
+ if (fetchData) {
50
+ (!ctx.globalOptions.selfListen &&
51
+ fetchData.message_sender.id.toString() === ctx.userID) ||
52
+ !ctx.loggedIn
53
+ ? undefined
54
+ : (function() {
55
+ callback(null, {
56
+ threadID: threadID,
57
+ messageID: fetchData.message_id,
58
+ senderID: fetchData.message_sender.id,
59
+ attachments: fetchData.blob_attachments.map(att => {
60
+ var x;
61
+ try {
62
+ x = utils._formatAttachment(att);
63
+ } catch (ex) {
64
+ x = att;
65
+ x.error = ex;
66
+ x.type = "unknown";
67
+ }
68
+ return x;
69
+ }),
70
+ body: fetchData.message.text,
71
+ mentions: fetchData.message.ranges,
72
+ timestamp: fetchData.timestamp_precise,
73
+ messageReply: fetchData.replied_to_message,
74
+ raw: fetchData
75
+ });
76
+ })();
77
+ }
78
+ })
79
+ .catch(err => {
80
+ log.error("getMessage", err);
81
+ callback(err);
82
+ });
83
+ };
84
+ };