alicezetion 1.7.1 → 1.7.3

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 +655 -120
  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,7 +3,7 @@
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
  function makeTypingIndicator(typ, threadID, callback, isGroup) {
8
8
  var form = {
9
9
  typ: +typ,
@@ -15,36 +15,46 @@ module.exports = function (defaultFuncs, api, ctx) {
15
15
  // Check if thread is a single person chat or a group chat
16
16
  // More info on this is in api.sendMessage
17
17
  if (utils.getType(isGroup) == "Boolean") {
18
- if (!isGroup) form.to = threadID;
19
-
18
+ if (!isGroup) {
19
+ form.to = threadID;
20
+ }
20
21
  defaultFuncs
21
22
  .post("https://www.facebook.com/ajax/messaging/typ.php", ctx.jar, form)
22
23
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
23
- .then(function (resData) {
24
+ .then(function(resData) {
24
25
  if (resData.error) throw resData;
25
26
  return callback();
26
27
  })
27
- .catch(function (err) {
28
+ .catch(function(err) {
28
29
  log.error("sendTypingIndicator", err);
29
- if (utils.getType(err) == "Object" && err.error === "Not logged in") ctx.loggedIn = false;
30
+ if (utils.getType(err) == "Object" && err.error === "Not logged in") {
31
+ ctx.loggedIn = false;
32
+ }
30
33
  return callback(err);
31
34
  });
32
- }
33
- else {
34
- api.getUserInfo(threadID, function (err, res) {
35
+ } else {
36
+ api.getUserInfo(threadID, function(err, res) {
35
37
  if (err) return callback(err);
36
38
  // If id is single person chat
37
39
  if (Object.keys(res).length > 0) form.to = threadID;
38
40
  defaultFuncs
39
- .post("https://www.facebook.com/ajax/messaging/typ.php", ctx.jar, form)
41
+ .post(
42
+ "https://www.facebook.com/ajax/messaging/typ.php",
43
+ ctx.jar,
44
+ form
45
+ )
40
46
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
41
- .then(function (resData) {
47
+ .then(function(resData) {
42
48
  if (resData.error) throw resData;
43
49
  return callback();
44
50
  })
45
- .catch(function (err) {
51
+ .catch(function(err) {
46
52
  log.error("sendTypingIndicator", err);
47
- if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
53
+ if (
54
+ utils.getType(err) == "Object" &&
55
+ err.error === "Not logged in."
56
+ )
57
+ ctx.loggedIn = false;
48
58
  return callback(err);
49
59
  });
50
60
  });
@@ -52,18 +62,33 @@ module.exports = function (defaultFuncs, api, ctx) {
52
62
  }
53
63
 
54
64
  return function sendTypingIndicator(threadID, callback, isGroup) {
55
- if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
56
- if (callback) log.warn("sendTypingIndicator", "callback is not a function - ignoring.");
57
- callback = () => { };
65
+ if (
66
+ utils.getType(callback) !== "Function" &&
67
+ utils.getType(callback) !== "AsyncFunction"
68
+ ) {
69
+ if (callback)
70
+ log.warn(
71
+ "sendTypingIndicator",
72
+ "callback is not a function - ignoring."
73
+ );
74
+ callback = () => {};
58
75
  }
59
76
 
60
77
  makeTypingIndicator(true, threadID, callback, isGroup);
61
78
 
62
79
  return function end(cb) {
63
- if (utils.getType(cb) !== "Function" && utils.getType(cb) !== "AsyncFunction") {
64
- if (cb) log.warn("sendTypingIndicator", "callback is not a function - ignoring.");
65
- cb = () => { };
80
+ if (
81
+ utils.getType(cb) !== "Function" &&
82
+ utils.getType(cb) !== "AsyncFunction"
83
+ ) {
84
+ if (cb)
85
+ log.warn(
86
+ "sendTypingIndicator",
87
+ "callback is not a function - ignoring."
88
+ );
89
+ cb = () => {};
66
90
  }
91
+
67
92
  makeTypingIndicator(false, threadID, cb, isGroup);
68
93
  };
69
94
  };
@@ -1,63 +1,104 @@
1
+ /**
2
+ * @fix by NTKhang
3
+ * update as Thursday, 10 February 2022
4
+ * do not remove the author name to get more updates
5
+ */
6
+
1
7
  "use strict";
2
8
 
3
9
  var utils = require("../utils");
4
10
  var log = require("npmlog");
5
11
 
6
- module.exports = function (defaultFuncs, api, ctx) {
12
+ function formatData(resData) {
13
+ return {
14
+ viewer_feedback_reaction_info:
15
+ resData.feedback_react.feedback.viewer_feedback_reaction_info,
16
+ supported_reactions: resData.feedback_react.feedback.supported_reactions,
17
+ top_reactions: resData.feedback_react.feedback.top_reactions.edges,
18
+ reaction_count: resData.feedback_react.feedback.reaction_count
19
+ };
20
+ }
21
+
22
+ module.exports = function(defaultFuncs, api, ctx) {
7
23
  return function setPostReaction(postID, type, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
24
+ var resolveFunc = function() {};
25
+ var rejectFunc = function() {};
26
+ var returnPromise = new Promise(function(resolve, reject) {
11
27
  resolveFunc = resolve;
12
28
  rejectFunc = reject;
13
29
  });
14
30
 
15
31
  if (!callback) {
16
- callback = function (err, data) {
17
- if (err) return rejectFunc(err);
18
- resolveFunc(data);
19
- };
32
+ if (
33
+ utils.getType(type) === "Function" ||
34
+ utils.getType(type) === "AsyncFunction"
35
+ ) {
36
+ callback = type;
37
+ type = 0;
38
+ } else {
39
+ callback = function(err, data) {
40
+ if (err) {
41
+ return rejectFunc(err);
42
+ }
43
+ resolveFunc(data);
44
+ };
45
+ }
20
46
  }
21
47
 
22
48
  var map = {
49
+ unlike: 0,
23
50
  like: 1,
24
51
  heart: 2,
25
- wow: 3,
52
+ love: 16,
26
53
  haha: 4,
54
+ wow: 3,
27
55
  sad: 7,
28
56
  angry: 8
29
57
  };
30
- if (typeof type != "number") {
31
- type = map[type.toLocaleLowerCase()];
32
- if (!type) type = 1;
58
+
59
+ if (utils.getType(type) !== "Number" && utils.getType(type) === "String") {
60
+ type = map[type.toLowerCase()];
61
+ } else {
62
+ throw {
63
+ error: "setPostReaction: Invalid reaction type"
64
+ };
33
65
  }
66
+
34
67
  var form = {
35
68
  av: ctx.userID,
36
69
  fb_api_caller_class: "RelayModern",
37
- fb_api_req_friendly_name: "UFI2FeedbackReactMutation",
38
- //This doc_id is valid as of January 17th, 2020
39
- doc_id: "2580813318646067",
70
+ fb_api_req_friendly_name: "CometUFIFeedbackReactMutation",
71
+ doc_id: "4769042373179384",
40
72
  variables: JSON.stringify({
41
73
  input: {
42
- client_mutation_id: "7",
43
74
  actor_id: ctx.userID,
44
- feedback_reaction: type
75
+ feedback_id: new Buffer.from("feedback:" + postID).toString("base64"),
76
+ feedback_reaction: type,
77
+ feedback_source: "OBJECT",
78
+ is_tracking_encrypted: true,
79
+ tracking: [],
80
+ session_id: "f7dd50dd-db6e-4598-8cd9-561d5002b423",
81
+ client_mutation_id: Math.round(Math.random() * 19).toString()
45
82
  },
46
- useDefaultActor: true
83
+ useDefaultActor: false,
84
+ scale: 3
47
85
  })
48
86
  };
49
87
 
50
88
  defaultFuncs
51
89
  .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
52
90
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
53
- .then(function (resData) {
54
- if (resData.error) throw resData;
55
- return callback();
91
+ .then(function(resData) {
92
+ if (resData.errors) {
93
+ throw resData;
94
+ }
95
+ return callback(null, formatData(resData.data));
56
96
  })
57
- .catch(function (err) {
97
+ .catch(function(err) {
58
98
  log.error("setPostReaction", err);
59
99
  return callback(err);
60
100
  });
101
+
61
102
  return returnPromise;
62
103
  };
63
104
  };
package/src/setTitle.js CHANGED
@@ -3,21 +3,24 @@
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 setTitle(newTitle, threadID, callback) {
8
- if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction"))
8
+ if (
9
+ !callback &&
10
+ (utils.getType(threadID) === "Function" ||
11
+ utils.getType(threadID) === "AsyncFunction")
12
+ )
9
13
  throw { error: "please pass a threadID as a second argument." };
10
14
 
11
-
12
- var resolveFunc = function () { };
13
- var rejectFunc = function () { };
14
- var returnPromise = new Promise(function (resolve, reject) {
15
+ var resolveFunc = function() {};
16
+ var rejectFunc = function() {};
17
+ var returnPromise = new Promise(function(resolve, reject) {
15
18
  resolveFunc = resolve;
16
19
  rejectFunc = reject;
17
20
  });
18
21
 
19
22
  if (!callback) {
20
- callback = function (err, data) {
23
+ callback = function(err, data) {
21
24
  if (err) return rejectFunc(err);
22
25
  resolveFunc(data);
23
26
  };
@@ -53,18 +56,25 @@ module.exports = function (defaultFuncs, api, ctx) {
53
56
  };
54
57
 
55
58
  defaultFuncs
56
- .post("https://www.facebook.com/messaging/set_thread_name/", ctx.jar, form)
59
+ .post(
60
+ "https://www.facebook.com/messaging/set_thread_name/",
61
+ ctx.jar,
62
+ form
63
+ )
57
64
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
58
- .then(function (resData) {
59
- if (resData.error && resData.error === 1545012) throw { error: "Cannot change chat title: Not member of chat." };
60
- if (resData.error && resData.error === 1545003) throw { error: "Cannot set title of single-user chat." };
65
+ .then(function(resData) {
66
+ if (resData.error && resData.error === 1545012)
67
+ throw { error: "Cannot change chat title: Not member of chat." };
68
+ if (resData.error && resData.error === 1545003)
69
+ throw { error: "Cannot set title of single-user chat." };
61
70
  if (resData.error) throw resData;
62
71
  return callback();
63
72
  })
64
- .catch(function (err) {
73
+ .catch(function(err) {
65
74
  log.error("setTitle", err);
66
75
  return callback(err);
67
76
  });
77
+
68
78
  return returnPromise;
69
79
  };
70
80
  };
@@ -1,25 +1,23 @@
1
1
  "use strict";
2
2
 
3
- module.exports = function (_defaultFuncs, _api, _ctx) {
3
+ module.exports = function(_defaultFuncs, _api, _ctx) {
4
4
  // Currently the only colors that can be passed to api.changeThreadColor(); may change if Facebook adds more
5
5
  return {
6
-
7
- //#region This part is for backward compatibly
8
- //trying to match the color one-by-one. kill me plz
9
- MessengerBlue: "196241301102133", //DefaultBlue
10
- Viking: "1928399724138152", //TealBlue
11
- GoldenPoppy: "174636906462322", //Yellow
12
- RadicalRed: "2129984390566328", //Red
13
- Shocking: "2058653964378557", //LavenderPurple
14
- FreeSpeechGreen: "2136751179887052", //Green
15
- Pumpkin: "175615189761153", //Orange
16
- LightCoral: "980963458735625", //CoralPink
17
- MediumSlateBlue: "234137870477637", //BrightPurple
18
- DeepSkyBlue: "2442142322678320", //AquaBlue
19
- BrilliantRose: "169463077092846", //HotPink
20
- //i've tried my best, everything else can't be mapped. (or is it?) -UIRI 2020
21
- //#endregion
22
-
6
+ ////MessengerBlue: null,
7
+ ////Viking: "#44bec7",
8
+ ////GoldenPoppy: "#ffc300",
9
+ ////RadicalRed: "#fa3c4c",
10
+ ////Shocking: "#d696bb",
11
+ ////PictonBlue: "#6699cc",
12
+ ////FreeSpeechGreen: "#13cf13",
13
+ ////Pumpkin: "#ff7e29",
14
+ ////LightCoral: "#e68585",
15
+ ////MediumSlateBlue: "#7646ff",
16
+ ////DeepSkyBlue: "#20cef5",
17
+ ////Fern: "#67b868",
18
+ ////Cameo: "#d4a88c",
19
+ ////BrilliantRose: "#ff5ca1",
20
+ ////BilobaFlower: "#a695c7"
23
21
  DefaultBlue: "196241301102133",
24
22
  HotPink: "169463077092846",
25
23
  AquaBlue: "2442142322678320",
@@ -36,6 +34,6 @@ module.exports = function (_defaultFuncs, _api, _ctx) {
36
34
  Berry: "164535220883264",
37
35
  Citrus: "370940413392601",
38
36
  Candy: "205488546921017",
39
- //StarWars: "809305022860427" Removed.
37
+ StarWars: "809305022860427"
40
38
  };
41
39
  };
package/src/unfriend.js CHANGED
@@ -3,17 +3,17 @@
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 unfriend(userID, 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
 
15
15
  if (!callback) {
16
- callback = function (err, friendList) {
16
+ callback = function(err, friendList) {
17
17
  if (err) return rejectFunc(err);
18
18
  resolveFunc(friendList);
19
19
  };
@@ -23,20 +23,26 @@ module.exports = function (defaultFuncs, api, ctx) {
23
23
  uid: userID,
24
24
  unref: "bd_friends_tab",
25
25
  floc: "friends_tab",
26
- "nctr[_mod]": "pagelet_timeline_app_collection_" + ctx.userID + ":2356318349:2"
26
+ "nctr[_mod]":
27
+ "pagelet_timeline_app_collection_" + ctx.userID + ":2356318349:2"
27
28
  };
28
29
 
29
30
  defaultFuncs
30
- .post("https://www.facebook.com/ajax/profile/removefriendconfirm.php", ctx.jar, form)
31
+ .post(
32
+ "https://www.facebook.com/ajax/profile/removefriendconfirm.php",
33
+ ctx.jar,
34
+ form
35
+ )
31
36
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
32
- .then(function (resData) {
37
+ .then(function(resData) {
33
38
  if (resData.error) throw resData;
34
39
  return callback();
35
40
  })
36
- .catch(function (err) {
41
+ .catch(function(err) {
37
42
  log.error("unfriend", err);
38
43
  return callback(err);
39
44
  });
45
+
40
46
  return returnPromise;
41
47
  };
42
48
  };
@@ -3,17 +3,17 @@
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 unsendMessage(messageID, 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
 
15
15
  if (!callback) {
16
- callback = function (err, friendList) {
16
+ callback = function(err, friendList) {
17
17
  if (err) return rejectFunc(err);
18
18
  resolveFunc(friendList);
19
19
  };
@@ -26,14 +26,15 @@ module.exports = function (defaultFuncs, api, ctx) {
26
26
  defaultFuncs
27
27
  .post("https://www.facebook.com/messaging/unsend_message/", ctx.jar, form)
28
28
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
29
- .then(function (resData) {
29
+ .then(function(resData) {
30
30
  if (resData.error) throw resData;
31
31
  return callback();
32
32
  })
33
- .catch(function (err) {
34
- log.error("unsendMessage", "» ParseAndCheckLogin got status code: 404. Bailing out of trying to parse response.");
33
+ .catch(function(err) {
34
+ log.error("unsendMessage", err);
35
35
  return callback(err);
36
36
  });
37
+
37
38
  return returnPromise;
38
39
  };
39
40
  };