alicezetion 1.1.0 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -1
  2. package/.cache/replit/nix/env.json +1 -1
  3. package/index.js +556 -490
  4. package/leiamnash/addExternalModule.js +19 -0
  5. package/{src → leiamnash}/addUserToGroup.js +52 -16
  6. package/leiamnash/changeAdminStatus.js +79 -0
  7. package/leiamnash/changeArchivedStatus.js +55 -0
  8. package/{src → leiamnash}/changeBio.js +19 -6
  9. package/{src → leiamnash}/changeBlockedStatus.js +14 -3
  10. package/{src → leiamnash}/changeGroupImage.js +40 -16
  11. package/leiamnash/changeNickname.js +59 -0
  12. package/{src → leiamnash}/changeThreadColor.js +20 -10
  13. package/leiamnash/changeThreadEmoji.js +55 -0
  14. package/leiamnash/chat.js +459 -0
  15. package/{src → leiamnash}/createNewGroup.js +28 -12
  16. package/{src → leiamnash}/createPoll.js +25 -13
  17. package/leiamnash/deleteMessage.js +56 -0
  18. package/leiamnash/deleteThread.js +56 -0
  19. package/leiamnash/forwardAttachment.js +60 -0
  20. package/{src → leiamnash}/getCurrentUserID.js +1 -1
  21. package/{src → leiamnash}/getEmojiUrl.js +4 -2
  22. package/{src → leiamnash}/getFriendsList.js +21 -10
  23. package/{src → leiamnash}/getThreadHistory.js +166 -58
  24. package/{src → leiamnash}/getThreadHistoryDeprecated.js +42 -20
  25. package/{src → leiamnash}/getThreadInfo.js +60 -25
  26. package/leiamnash/getThreadInfoDeprecated.js +80 -0
  27. package/{src → leiamnash}/getThreadList.js +66 -41
  28. package/leiamnash/getThreadListDeprecated.js +75 -0
  29. package/leiamnash/getThreadPictures.js +79 -0
  30. package/{src → leiamnash}/getUserID.js +14 -9
  31. package/{src → leiamnash}/getUserInfo.js +1 -1
  32. package/leiamnash/handleFriendRequest.js +61 -0
  33. package/leiamnash/handleMessageRequest.js +65 -0
  34. package/{src → leiamnash}/httpGet.js +17 -12
  35. package/{src → leiamnash}/httpPost.js +17 -12
  36. package/leiamnash/listenMqtt.js +687 -0
  37. package/{src → leiamnash}/logout.js +20 -13
  38. package/{src → leiamnash}/markAsDelivered.js +22 -11
  39. package/{src → leiamnash}/markAsRead.js +21 -11
  40. package/{src → leiamnash}/markAsReadAll.js +20 -10
  41. package/{src → leiamnash}/markAsSeen.js +18 -7
  42. package/{src → leiamnash}/muteThread.js +18 -11
  43. package/leiamnash/removeUserFromGroup.js +79 -0
  44. package/{src → leiamnash}/resolvePhotoUrl.js +17 -8
  45. package/{src → leiamnash}/searchForThread.js +21 -10
  46. package/{src → leiamnash}/sendTypingIndicator.js +47 -14
  47. package/{src → leiamnash}/setMessageReaction.js +26 -12
  48. package/{src → leiamnash}/setPostReaction.js +26 -13
  49. package/{src → leiamnash}/setTitle.js +29 -13
  50. package/leiamnash/threadColors.js +57 -0
  51. package/{src → leiamnash}/unfriend.js +19 -9
  52. package/{src → leiamnash}/unsendMessage.js +19 -9
  53. package/package.json +9 -14
  54. package/replit.nix +0 -1
  55. package/utils.js +1193 -1023
  56. package/src/addExternalModule.js +0 -15
  57. package/src/changeAdminStatus.js +0 -47
  58. package/src/changeArchivedStatus.js +0 -41
  59. package/src/changeNickname.js +0 -43
  60. package/src/changeThreadEmoji.js +0 -41
  61. package/src/chat.js +0 -315
  62. package/src/deleteMessage.js +0 -44
  63. package/src/deleteThread.js +0 -42
  64. package/src/forwardAttachment.js +0 -47
  65. package/src/forwardMessage.js +0 -0
  66. package/src/getThreadInfoDeprecated.js +0 -56
  67. package/src/getThreadListDeprecated.js +0 -46
  68. package/src/getThreadPictures.js +0 -59
  69. package/src/handleFriendRequest.js +0 -46
  70. package/src/handleMessageRequest.js +0 -47
  71. package/src/listen.js +0 -553
  72. package/src/listenMqtt-Test.js +0 -687
  73. package/src/listenMqtt.js +0 -677
  74. package/src/removeUserFromGroup.js +0 -45
  75. package/src/threadColors.js +0 -41
@@ -0,0 +1,79 @@
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 getThreadPictures(threadID, offset, limit, 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) {
16
+ callback = function (err, friendList) {
17
+ if (err) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc(friendList);
21
+ };
22
+ }
23
+
24
+ var form = {
25
+ thread_id: threadID,
26
+ offset: offset,
27
+ limit: limit
28
+ };
29
+
30
+ defaultFuncs
31
+ .post(
32
+ "https://www.facebook.com/ajax/messaging/attachments/sharedphotos.php",
33
+ ctx.jar,
34
+ form
35
+ )
36
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
37
+ .then(function(resData) {
38
+ if (resData.error) {
39
+ throw resData;
40
+ }
41
+ return Promise.all(
42
+ resData.payload.imagesData.map(function(image) {
43
+ form = {
44
+ thread_id: threadID,
45
+ image_id: image.fbid
46
+ };
47
+ return defaultFuncs
48
+ .post(
49
+ "https://www.facebook.com/ajax/messaging/attachments/sharedphotos.php",
50
+ ctx.jar,
51
+ form
52
+ )
53
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
54
+ .then(function(resData) {
55
+ if (resData.error) {
56
+ throw resData;
57
+ }
58
+ // the response is pretty messy
59
+ var queryThreadID =
60
+ resData.jsmods.require[0][3][1].query_metadata.query_path[0]
61
+ .message_thread;
62
+ var imageData =
63
+ resData.jsmods.require[0][3][1].query_results[queryThreadID]
64
+ .message_images.edges[0].node.image2;
65
+ return imageData;
66
+ });
67
+ })
68
+ );
69
+ })
70
+ .then(function(resData) {
71
+ callback(null, resData);
72
+ })
73
+ .catch(function(err) {
74
+ log.error("Error in getThreadPictures", err);
75
+ callback(err);
76
+ });
77
+ return returnPromise;
78
+ };
79
+ };
@@ -17,19 +17,21 @@ function formatData(data) {
17
17
  };
18
18
  }
19
19
 
20
- module.exports = function (defaultFuncs, api, ctx) {
20
+ module.exports = function(defaultFuncs, api, ctx) {
21
21
  return function getUserID(name, callback) {
22
- var resolveFunc = function () { };
23
- var rejectFunc = function () { };
22
+ var resolveFunc = function(){};
23
+ var rejectFunc = function(){};
24
24
  var returnPromise = new Promise(function (resolve, reject) {
25
25
  resolveFunc = resolve;
26
26
  rejectFunc = reject;
27
27
  });
28
28
 
29
29
  if (!callback) {
30
- callback = function (err, data) {
31
- if (err) return rejectFunc(err);
32
- resolveFunc(data);
30
+ callback = function (err, friendList) {
31
+ if (err) {
32
+ return rejectFunc(err);
33
+ }
34
+ resolveFunc(friendList);
33
35
  };
34
36
  }
35
37
 
@@ -45,13 +47,16 @@ module.exports = function (defaultFuncs, api, ctx) {
45
47
  defaultFuncs
46
48
  .get("https://www.facebook.com/ajax/typeahead/search.php", ctx.jar, form)
47
49
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
48
- .then(function (resData) {
49
- if (resData.error) throw resData;
50
+ .then(function(resData) {
51
+ if (resData.error) {
52
+ throw resData;
53
+ }
50
54
 
51
55
  var data = resData.payload.entries;
56
+
52
57
  callback(null, data.map(formatData));
53
58
  })
54
- .catch(function (err) {
59
+ .catch(function(err) {
55
60
  log.error("getUserID", err);
56
61
  return callback(err);
57
62
  });
@@ -69,4 +69,4 @@ module.exports = function(defaultFuncs, api, ctx) {
69
69
 
70
70
  return returnPromise;
71
71
  };
72
- };
72
+ };
@@ -0,0 +1,61 @@
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 handleFriendRequest(userID, accept, callback) {
8
+ if (utils.getType(accept) !== "Boolean") {
9
+ throw {
10
+ error: "Please pass a boolean as a second argument."
11
+ };
12
+ }
13
+
14
+ var resolveFunc = function(){};
15
+ var rejectFunc = function(){};
16
+ var returnPromise = new Promise(function (resolve, reject) {
17
+ resolveFunc = resolve;
18
+ rejectFunc = reject;
19
+ });
20
+
21
+ if (!callback) {
22
+ callback = function (err, friendList) {
23
+ if (err) {
24
+ return rejectFunc(err);
25
+ }
26
+ resolveFunc(friendList);
27
+ };
28
+ }
29
+
30
+ var form = {
31
+ viewer_id: ctx.userID,
32
+ "frefs[0]": "jwl",
33
+ floc: "friend_center_requests",
34
+ ref: "/reqs.php",
35
+ action: (accept ? "confirm" : "reject")
36
+ };
37
+
38
+ defaultFuncs
39
+ .post(
40
+ "https://www.facebook.com/requests/friends/ajax/",
41
+ ctx.jar,
42
+ form
43
+ )
44
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
45
+ .then(function(resData) {
46
+ if (resData.payload.err) {
47
+ throw {
48
+ err: resData.payload.err
49
+ };
50
+ }
51
+
52
+ return callback();
53
+ })
54
+ .catch(function(err) {
55
+ log.error("handleFriendRequest", err);
56
+ return callback(err);
57
+ });
58
+
59
+ return returnPromise;
60
+ };
61
+ };
@@ -0,0 +1,65 @@
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 handleMessageRequest(threadID, accept, callback) {
8
+ if (utils.getType(accept) !== "Boolean") {
9
+ throw {
10
+ error: "Please pass a boolean as a second argument."
11
+ };
12
+ }
13
+
14
+ var resolveFunc = function(){};
15
+ var rejectFunc = function(){};
16
+ var returnPromise = new Promise(function (resolve, reject) {
17
+ resolveFunc = resolve;
18
+ rejectFunc = reject;
19
+ });
20
+
21
+ if (!callback) {
22
+ callback = function (err, friendList) {
23
+ if (err) {
24
+ return rejectFunc(err);
25
+ }
26
+ resolveFunc(friendList);
27
+ };
28
+ }
29
+
30
+ var form = {
31
+ client: "mercury"
32
+ };
33
+
34
+ if (utils.getType(threadID) !== "Array") {
35
+ threadID = [threadID];
36
+ }
37
+
38
+ var messageBox = accept ? "inbox" : "other";
39
+
40
+ for (var i = 0; i < threadID.length; i++) {
41
+ form[messageBox + "[" + i + "]"] = threadID[i];
42
+ }
43
+
44
+ defaultFuncs
45
+ .post(
46
+ "https://www.facebook.com/ajax/mercury/move_thread.php",
47
+ ctx.jar,
48
+ form
49
+ )
50
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
51
+ .then(function(resData) {
52
+ if (resData.error) {
53
+ throw resData;
54
+ }
55
+
56
+ return callback();
57
+ })
58
+ .catch(function(err) {
59
+ log.error("handleMessageRequest", err);
60
+ return callback(err);
61
+ });
62
+
63
+ return returnPromise;
64
+ };
65
+ };
@@ -3,10 +3,10 @@
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 httpGet(url, form, callback, notAPI) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
10
 
11
11
  var returnPromise = new Promise(function (resolve, reject) {
12
12
  resolveFunc = resolve;
@@ -17,31 +17,36 @@ module.exports = function (defaultFuncs, api, ctx) {
17
17
  callback = form;
18
18
  form = {};
19
19
  }
20
+
20
21
  form = form || {};
21
22
 
22
- callback = callback || function (err, data) {
23
- if (err) return rejectFunc(err);
24
- resolveFunc(data);
23
+ callback = callback || function(err, data) {
24
+ if (err) return rejectFunc(err);
25
+ resolveFunc(data);
25
26
  };
26
27
 
27
28
  if (notAPI) {
28
29
  utils
29
30
  .get(url, ctx.jar, form, ctx.globalOptions)
30
- .then(resData => callback(null, resData.body.toString()))
31
- .catch(function (err) {
31
+ .then(function(resData) {
32
+ callback(null, resData.body.toString());
33
+ })
34
+ .catch(function(err) {
32
35
  log.error("httpGet", err);
33
36
  return callback(err);
34
37
  });
35
- }
36
- else {
38
+ } else {
37
39
  defaultFuncs
38
40
  .get(url, ctx.jar, form)
39
- .then(resData => callback(null, resData.body.toString()))
40
- .catch(function (err) {
41
+ .then(function(resData) {
42
+ callback(null, resData.body.toString());
43
+ })
44
+ .catch(function(err) {
41
45
  log.error("httpGet", err);
42
46
  return callback(err);
43
47
  });
44
48
  }
49
+
45
50
  return returnPromise;
46
51
  };
47
52
  };
@@ -3,10 +3,10 @@
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 httpGet(url, form, callback, notAPI) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
10
 
11
11
  var returnPromise = new Promise(function (resolve, reject) {
12
12
  resolveFunc = resolve;
@@ -17,31 +17,36 @@ module.exports = function (defaultFuncs, api, ctx) {
17
17
  callback = form;
18
18
  form = {};
19
19
  }
20
+
20
21
  form = form || {};
21
22
 
22
- callback = callback || function (err, data) {
23
- if (err) return rejectFunc(err);
24
- resolveFunc(data);
23
+ callback = callback || function(err, data) {
24
+ if (err) return rejectFunc(err);
25
+ resolveFunc(data);
25
26
  };
26
27
 
27
28
  if (notAPI) {
28
29
  utils
29
30
  .post(url, ctx.jar, form, ctx.globalOptions)
30
- .then(resData => callback(null, resData.body.toString()))
31
- .catch(function (err) {
31
+ .then(function(resData) {
32
+ callback(null, resData.body.toString());
33
+ })
34
+ .catch(function(err) {
32
35
  log.error("httpPost", err);
33
36
  return callback(err);
34
37
  });
35
- }
36
- else {
38
+ } else {
37
39
  defaultFuncs
38
40
  .post(url, ctx.jar, form, {})
39
- .then(resData => callback(null, resData.body.toString()))
40
- .catch(function (err) {
41
+ .then(function(resData) {
42
+ callback(null, resData.body.toString());
43
+ })
44
+ .catch(function(err) {
41
45
  log.error("httpPost", err);
42
46
  return callback(err);
43
47
  });
44
48
  }
49
+
45
50
  return returnPromise;
46
51
  };
47
52
  };