alicezetion 1.8.3 → 1.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) 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 +210 -375
  4. package/package.json +6 -3
  5. package/replit.nix +4 -4
  6. package/src/addExternalModule.js +17 -0
  7. package/src/addUserToGroup.js +113 -0
  8. package/src/changeAdminStatus.js +79 -0
  9. package/src/changeArchivedStatus.js +55 -0
  10. package/src/changeAvatar.js +93 -0
  11. package/src/changeBio.js +77 -0
  12. package/src/changeBlockedStatus.js +47 -0
  13. package/src/changeCover.js +73 -0
  14. package/src/changeGroupImage.js +132 -0
  15. package/src/changeName.js +79 -0
  16. package/src/changeNickname.js +59 -0
  17. package/src/changeThreadColor.js +65 -0
  18. package/src/changeThreadEmoji.js +55 -0
  19. package/{leiamnash → src}/chat.js +28 -3
  20. package/src/createNewGroup.js +86 -0
  21. package/src/createPoll.js +71 -0
  22. package/src/data/getThreadInfo.json +1 -0
  23. package/src/deleteMessage.js +56 -0
  24. package/src/deleteThread.js +56 -0
  25. package/src/forwardAttachment.js +60 -0
  26. package/src/getAccess.js +112 -0
  27. package/src/getAvatarUser.js +78 -0
  28. package/src/getCurrentUserID.js +7 -0
  29. package/src/getEmojiUrl.js +29 -0
  30. package/src/getFriendsList.js +83 -0
  31. package/src/getThreadHistory.js +666 -0
  32. package/{leiamnash → src}/getThreadInfo.js +70 -54
  33. package/src/getThreadList.js +237 -0
  34. package/src/getThreadPictures.js +79 -0
  35. package/src/getUserID.js +66 -0
  36. package/src/getUserInfo.js +163 -0
  37. package/src/handleFriendRequest.js +61 -0
  38. package/src/handleMessageRequest.js +65 -0
  39. package/src/httpGet.js +57 -0
  40. package/src/httpPost.js +57 -0
  41. package/src/httpPostFormData.js +63 -0
  42. package/{leiamnash → src}/listenMqtt.js +16 -6
  43. package/src/listenNotification.js +88 -0
  44. package/src/logout.js +275 -0
  45. package/src/markAsDelivered.js +58 -0
  46. package/src/markAsRead.js +80 -0
  47. package/src/markAsReadAll.js +50 -0
  48. package/src/markAsSeen.js +59 -0
  49. package/src/muteThread.js +52 -0
  50. package/src/react.js +117 -0
  51. package/{leiamnash → src}/refreshFb_dtsg.js +1 -1
  52. package/src/removeUserFromGroup.js +79 -0
  53. package/src/resolvePhotoUrl.js +45 -0
  54. package/src/searchForThread.js +53 -0
  55. package/src/searchStickers.js +52 -0
  56. package/src/seen.js +50 -0
  57. package/src/sendMessage.js +477 -0
  58. package/src/sendMessageMqtt.js +316 -0
  59. package/src/sendTypingIndicator.js +103 -0
  60. package/src/setMessageReaction.js +117 -0
  61. package/src/setPostReaction.js +109 -0
  62. package/src/setTitle.js +86 -0
  63. package/src/threadColors.js +131 -0
  64. package/src/unfriend.js +52 -0
  65. package/src/unsendMessage.js +49 -0
  66. package/utils.js +135 -176
  67. package/.cache/replit/modules.stamp +0 -1
  68. package/leiamnash/addExternalModule.js +0 -15
  69. package/leiamnash/addUserToGroup.js +0 -77
  70. package/leiamnash/changeAdminStatus.js +0 -47
  71. package/leiamnash/changeArchivedStatus.js +0 -41
  72. package/leiamnash/changeAvatar.js +0 -127
  73. package/leiamnash/changeBio.js +0 -64
  74. package/leiamnash/changeBlockedStatus.js +0 -36
  75. package/leiamnash/changeGroupImage.js +0 -105
  76. package/leiamnash/changeNickname.js +0 -43
  77. package/leiamnash/changeThreadColor.js +0 -61
  78. package/leiamnash/changeThreadEmoji.js +0 -41
  79. package/leiamnash/createNewGroup.js +0 -70
  80. package/leiamnash/createPoll.js +0 -59
  81. package/leiamnash/deleteMessage.js +0 -44
  82. package/leiamnash/deleteThread.js +0 -42
  83. package/leiamnash/forwardAttachment.js +0 -47
  84. package/leiamnash/forwardMessage.js +0 -0
  85. package/leiamnash/getCurrentUserID.js +0 -7
  86. package/leiamnash/getEmojiUrl.js +0 -27
  87. package/leiamnash/getFriendsList.js +0 -73
  88. package/leiamnash/getInfoVideo.js +0 -134
  89. package/leiamnash/getThreadHistory.js +0 -537
  90. package/leiamnash/getThreadHistoryDeprecated.js +0 -71
  91. package/leiamnash/getThreadInfoDeprecated.js +0 -56
  92. package/leiamnash/getThreadList.js +0 -213
  93. package/leiamnash/getThreadListDeprecated.js +0 -46
  94. package/leiamnash/getThreadPictures.js +0 -59
  95. package/leiamnash/getUserID.js +0 -61
  96. package/leiamnash/getUserInfo.js +0 -66
  97. package/leiamnash/handleFriendRequest.js +0 -46
  98. package/leiamnash/handleMessageRequest.js +0 -47
  99. package/leiamnash/httpGet.js +0 -47
  100. package/leiamnash/httpPost.js +0 -47
  101. package/leiamnash/httpPostFormData.js +0 -42
  102. package/leiamnash/logout.js +0 -68
  103. package/leiamnash/markAsDelivered.js +0 -47
  104. package/leiamnash/markAsRead.js +0 -70
  105. package/leiamnash/markAsReadAll.js +0 -40
  106. package/leiamnash/markAsSeen.js +0 -48
  107. package/leiamnash/muteThread.js +0 -45
  108. package/leiamnash/react.js +0 -109
  109. package/leiamnash/removeUserFromGroup.js +0 -45
  110. package/leiamnash/resolvePhotoUrl.js +0 -36
  111. package/leiamnash/searchForThread.js +0 -42
  112. package/leiamnash/seen.js +0 -40
  113. package/leiamnash/sendMessage.js +0 -315
  114. package/leiamnash/sendTypingIndicator.js +0 -70
  115. package/leiamnash/setMessageReaction.js +0 -103
  116. package/leiamnash/setPostReaction.js +0 -63
  117. package/leiamnash/setTitle.js +0 -70
  118. package/leiamnash/threadColors.js +0 -41
  119. package/leiamnash/unfriend.js +0 -42
  120. package/leiamnash/unsendMessage.js +0 -39
  121. package/leiamnash/uploadAttachment.js +0 -96
  122. /package/{leiamnash → src}/getMessage.js +0 -0
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ const 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
+ let resolveFunc = function () { };
15
+ let rejectFunc = function () { };
16
+ const 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
+ const form = {
31
+ viewer_id: ctx.i_userID || 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
+ const utils = require("../utils");
4
+ const 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
+ let resolveFunc = function () { };
15
+ let rejectFunc = function () { };
16
+ const 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
+ const form = {
31
+ client: "mercury"
32
+ };
33
+
34
+ if (utils.getType(threadID) !== "Array") {
35
+ threadID = [threadID];
36
+ }
37
+
38
+ const messageBox = accept ? "inbox" : "other";
39
+
40
+ for (let 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
+ };
package/src/httpGet.js ADDED
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ const log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ return function httpGet(url, form, customHeader, callback, notAPI) {
8
+ let resolveFunc = function () { };
9
+ let rejectFunc = function () { };
10
+
11
+ const returnPromise = new Promise(function (resolve, reject) {
12
+ resolveFunc = resolve;
13
+ rejectFunc = reject;
14
+ });
15
+
16
+ if (utils.getType(form) == "Function" || utils.getType(form) == "AsyncFunction") {
17
+ callback = form;
18
+ form = {};
19
+ }
20
+
21
+ if (utils.getType(customHeader) == "Function" || utils.getType(customHeader) == "AsyncFunction") {
22
+ callback = customHeader;
23
+ customHeader = {};
24
+ }
25
+
26
+ customHeader = customHeader || {};
27
+
28
+ callback = callback || function (err, data) {
29
+ if (err) return rejectFunc(err);
30
+ resolveFunc(data);
31
+ };
32
+
33
+ if (notAPI) {
34
+ utils
35
+ .get(url, ctx.jar, form, ctx.globalOptions, ctx, customHeader)
36
+ .then(function (resData) {
37
+ callback(null, resData.body.toString());
38
+ })
39
+ .catch(function (err) {
40
+ log.error("httpGet", err);
41
+ return callback(err);
42
+ });
43
+ } else {
44
+ defaultFuncs
45
+ .get(url, ctx.jar, form, null, customHeader)
46
+ .then(function (resData) {
47
+ callback(null, resData.body.toString());
48
+ })
49
+ .catch(function (err) {
50
+ log.error("httpGet", err);
51
+ return callback(err);
52
+ });
53
+ }
54
+
55
+ return returnPromise;
56
+ };
57
+ };
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ const log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ return function httpPost(url, form, customHeader, callback, notAPI) {
8
+ let resolveFunc = function () { };
9
+ let rejectFunc = function () { };
10
+
11
+ const returnPromise = new Promise(function (resolve, reject) {
12
+ resolveFunc = resolve;
13
+ rejectFunc = reject;
14
+ });
15
+
16
+ if (utils.getType(form) == "Function" || utils.getType(form) == "AsyncFunction") {
17
+ callback = form;
18
+ form = {};
19
+ }
20
+
21
+ if (utils.getType(customHeader) == "Function" || utils.getType(customHeader) == "AsyncFunction") {
22
+ callback = customHeader;
23
+ customHeader = {};
24
+ }
25
+
26
+ customHeader = customHeader || {};
27
+
28
+ callback = callback || function (err, data) {
29
+ if (err) return rejectFunc(err);
30
+ resolveFunc(data);
31
+ };
32
+
33
+ if (notAPI) {
34
+ utils
35
+ .post(url, ctx.jar, form, ctx.globalOptions, ctx, customHeader)
36
+ .then(function (resData) {
37
+ callback(null, resData.body.toString());
38
+ })
39
+ .catch(function (err) {
40
+ log.error("httpPost", err);
41
+ return callback(err);
42
+ });
43
+ } else {
44
+ defaultFuncs
45
+ .post(url, ctx.jar, form, {}, customHeader)
46
+ .then(function (resData) {
47
+ callback(null, resData.body.toString());
48
+ })
49
+ .catch(function (err) {
50
+ log.error("httpPost", err);
51
+ return callback(err);
52
+ });
53
+ }
54
+
55
+ return returnPromise;
56
+ };
57
+ };
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ const log = require("npmlog");
5
+
6
+
7
+ module.exports = function (defaultFuncs, api, ctx) {
8
+ return function httpPostFormData(url, form, customHeader, callback, notAPI) {
9
+ let resolveFunc = function () { };
10
+ let rejectFunc = function () { };
11
+
12
+ const returnPromise = new Promise(function (resolve, reject) {
13
+ resolveFunc = resolve;
14
+ rejectFunc = reject;
15
+ });
16
+
17
+ if (utils.getType(form) == "Function" || utils.getType(form) == "AsyncFunction") {
18
+ callback = form;
19
+ form = {};
20
+ }
21
+
22
+ if (utils.getType(customHeader) == "Function" || utils.getType(customHeader) == "AsyncFunction") {
23
+ callback = customHeader;
24
+ customHeader = {};
25
+ }
26
+
27
+ customHeader = customHeader || {};
28
+
29
+ if (utils.getType(callback) == "Boolean") {
30
+ notAPI = callback;
31
+ callback = null;
32
+ }
33
+
34
+ callback = callback || function (err, data) {
35
+ if (err) return rejectFunc(err);
36
+ resolveFunc(data);
37
+ };
38
+
39
+ if (notAPI) {
40
+ utils
41
+ .postFormData(url, ctx.jar, form, ctx.globalOptions, ctx, customHeader)
42
+ .then(function (resData) {
43
+ callback(null, resData.body.toString());
44
+ })
45
+ .catch(function (err) {
46
+ log.error("httpPostFormData", err);
47
+ return callback(err);
48
+ });
49
+ } else {
50
+ defaultFuncs
51
+ .postFormData(url, ctx.jar, form, null, customHeader)
52
+ .then(function (resData) {
53
+ callback(null, resData.body.toString());
54
+ })
55
+ .catch(function (err) {
56
+ log.error("httpPostFormData", err);
57
+ return callback(err);
58
+ });
59
+ }
60
+
61
+ return returnPromise;
62
+ };
63
+ };
@@ -109,10 +109,19 @@ function listenMqtt(defaultFuncs, api, ctx, globalCallback) {
109
109
  if (ctx.globalOptions.autoReconnect) {
110
110
  listenMqtt(defaultFuncs, api, ctx, globalCallback);
111
111
  } else {
112
- globalCallback({
113
- type: "stop_listen",
114
- error: "Connection refused: Server unavailable"
115
- }, null);
112
+ utils.checkLiveCookie(ctx, defaultFuncs)
113
+ .then(res => {
114
+ globalCallback({
115
+ type: "stop_listen",
116
+ error: "Connection refused: Server unavailable"
117
+ }, null);
118
+ })
119
+ .catch(err => {
120
+ globalCallback({
121
+ type: "account_inactive",
122
+ error: "Maybe your account is blocked by facebook, please login and check at https://facebook.com"
123
+ }, null);
124
+ });
116
125
  }
117
126
  });
118
127
 
@@ -363,7 +372,7 @@ function parseDelta(defaultFuncs, api, ctx, globalCallback, v) {
363
372
  .otherUserFbId).toString(),
364
373
  messageID: delta.deltaMessageReply.message.messageMetadata.messageId,
365
374
  senderID: delta.deltaMessageReply.message.messageMetadata.actorFbId.toString(),
366
- attachments: delta.deltaMessageReply.message.attachments.map(function (att) {
375
+ attachments: (delta.deltaMessageReply.message.attachments || []).map(function (att) {
367
376
  const mercury = JSON.parse(att.mercuryJSON);
368
377
  Object.assign(att, mercury);
369
378
  return att;
@@ -382,7 +391,7 @@ function parseDelta(defaultFuncs, api, ctx, globalCallback, v) {
382
391
  isGroup: !!delta.deltaMessageReply.message.messageMetadata.threadKey.threadFbId,
383
392
  mentions: mentions,
384
393
  timestamp: delta.deltaMessageReply.message.messageMetadata.timestamp,
385
- participantIDs: (delta.deltaMessageReply.message.messageMetadata.cid.canonicalParticipantFbids || []).map(e => e.toString())
394
+ participantIDs: (delta.deltaMessageReply.message.messageMetadata.cid.canonicalParticipantFbids || delta.deltaMessageReply.message.participants || []).map(e => e.toString())
386
395
  };
387
396
 
388
397
  if (delta.deltaMessageReply.repliedToMessage) {
@@ -543,6 +552,7 @@ function parseDelta(defaultFuncs, api, ctx, globalCallback, v) {
543
552
  case "change_thread_theme":
544
553
  case "change_thread_nickname":
545
554
  case "change_thread_icon":
555
+ case "change_thread_quick_reaction":
546
556
  case "change_thread_admins":
547
557
  case "group_poll":
548
558
  case "joinable_group_link_mode_change":
@@ -0,0 +1,88 @@
1
+ 'use strict';
2
+
3
+ var utils = require('../utils.js');
4
+ var log = require('npmlog');
5
+
6
+ function formatGraphResponse(data) {
7
+ var Obj = [];
8
+ var convertMS = function (ms, date) {
9
+ var time = (date - ms) / 1000;
10
+ return time;
11
+ };
12
+ var edges = data.viewer.notifications_page.edges;
13
+
14
+ for (let res of edges) {
15
+ res = res.node;
16
+ if (res.row_type !== 'NOTIFICATION') continue;
17
+ var timestamp = res.notif.creation_time.timestamp * 1000;
18
+ if (convertMS(timestamp, Date.now()) > 60) break;
19
+ var data = {
20
+ id: res.notif.id,
21
+ noti_id: res.notif.notif_id,
22
+ type: res.notif.notif_type,
23
+ body: res.notif.body,
24
+ url: res.notif.url,
25
+ timestamp
26
+ }
27
+ Obj.push(data);
28
+ }
29
+
30
+ return Obj;
31
+ }
32
+
33
+ module.exports = function (http, api, ctx) {
34
+ function listen(callback) {
35
+ var interval = setInterval(function (form) {
36
+ return http
37
+ .post('https://www.facebook.com/api/graphql/', ctx.jar, form)
38
+ .then(utils.parseAndCheckLogin(ctx, http))
39
+ .then(function (res) {
40
+ if (res.error) throw res;
41
+ return http
42
+ .post('https://www.facebook.com/ajax/navigation/', ctx.jar, {
43
+ client_previous_actor_id: '',
44
+ route_url: '/notifications',
45
+ routing_namespace: 'fb_comet'
46
+ })
47
+ .then(utils.parseAndCheckLogin(ctx, http))
48
+ .then(function () {
49
+ return callback(null, formatGraphResponse(res.data));
50
+ });
51
+ })
52
+ .catch(function (err) {
53
+ log.error('listenNotification', err);
54
+ return callback(err);
55
+ });
56
+ }, 60000, {
57
+ fb_api_req_friendly_name: "CometNotificationsRootQuery",
58
+ doc_id: "6663491207045267",
59
+ variables: JSON.stringify({
60
+ count: 15,
61
+ environment: "MAIN_SURFACE",
62
+ filter_tokens: ["Cg8CZnQPA2FsbAE="],
63
+ scale: 1
64
+ }),
65
+ server_timestamps: !0
66
+ });
67
+
68
+ return function stopListen() {
69
+ return clearInterval(interval);
70
+ }
71
+ }
72
+
73
+ return function GraphNoti(callback) {
74
+ if (typeof callback != 'function') {
75
+ var error = new Error('callback is not a function');
76
+ log.error('listenNotification', error);
77
+ return error;
78
+ }
79
+
80
+ try {
81
+ var rCb = listen(callback);
82
+ return rCb;
83
+ } catch (err) {
84
+ log.error('listenNotification', err);
85
+ return err;
86
+ }
87
+ }
88
+ }