fca-arif-babu 1.0.21 → 8.0.0

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 (152) hide show
  1. package/Extra/Balancer.js +49 -0
  2. package/Extra/Bypass/956/index.js +234 -0
  3. package/Extra/Bypass/test/aaaa.json +169 -0
  4. package/Extra/Bypass/test/index.js +188 -0
  5. package/Extra/Database/index.js +469 -0
  6. package/Extra/ExtraAddons.js +82 -0
  7. package/Extra/ExtraFindUID.js +62 -0
  8. package/Extra/ExtraGetThread.js +365 -0
  9. package/Extra/ExtraScreenShot.js +430 -0
  10. package/Extra/ExtraUptimeRobot.js +38 -0
  11. package/Extra/Html/Classic/script.js +119 -0
  12. package/Extra/Html/Classic/style.css +8 -0
  13. package/Extra/Security/AES_256_GCM/index.js +1 -0
  14. package/Extra/Security/Base/Step_1.js +6 -0
  15. package/Extra/Security/Base/Step_2.js +22 -0
  16. package/Extra/Security/Base/Step_3.js +22 -0
  17. package/Extra/Security/Base/index.js +191 -0
  18. package/Extra/Security/Step_1.js +6 -0
  19. package/Extra/Security/Step_2.js +22 -0
  20. package/Extra/Security/Step_3.js +22 -0
  21. package/Extra/Security/index.js +5 -0
  22. package/Extra/Src/Change_Environment.js +24 -0
  23. package/Extra/Src/Check_Update.js +67 -0
  24. package/Extra/Src/History.js +115 -0
  25. package/Extra/Src/Instant_Update.js +65 -0
  26. package/Extra/Src/Last-Run.js +65 -0
  27. package/Extra/Src/Premium.js +81 -0
  28. package/Extra/Src/Release_Memory.js +160 -0
  29. package/Extra/Src/Websocket.js +213 -0
  30. package/Extra/Src/image/62518eafb0670b697788ce4f9a4f71d1.jpg +0 -0
  31. package/Extra/Src/test.js +28 -0
  32. package/Extra/Src/uuid.js +137 -0
  33. package/Func/AcceptAgreement.js +31 -0
  34. package/Func/ClearCache.js +64 -0
  35. package/Func/ReportV1.js +54 -0
  36. package/{LICENSE-MIT → LICENSE.txt} +6 -6
  37. package/Language/index.json +228 -0
  38. package/Main.js +1290 -0
  39. package/README.md +8 -6
  40. package/SECURITY.md +17 -0
  41. package/broadcast.js +44 -0
  42. package/index.js +424 -465
  43. package/logger.js +66 -0
  44. package/package.json +91 -42
  45. package/src/Dev_Horizon_Data.js +125 -0
  46. package/src/Dev_getThreadInfoOLD.js +422 -0
  47. package/src/Dev_shareTest2.js +68 -0
  48. package/src/Dev_shareTest3.js +71 -0
  49. package/src/Premium.js +25 -0
  50. package/src/Screenshot.js +83 -0
  51. package/src/addExternalModule.js +5 -14
  52. package/src/addUserToGroup.js +21 -57
  53. package/src/changeAdminStatus.js +22 -46
  54. package/src/changeArchivedStatus.js +12 -26
  55. package/src/{changeAvatarV2.js → changeAvt.js} +2 -3
  56. package/src/changeBio.js +15 -26
  57. package/src/changeBlockedStatus.js +9 -22
  58. package/src/changeGroupImage.js +26 -55
  59. package/src/changeNickname.js +14 -28
  60. package/src/changeThreadColor.js +19 -22
  61. package/src/changeThreadEmoji.js +12 -25
  62. package/src/createNewGroup.js +18 -36
  63. package/src/createPoll.js +17 -28
  64. package/src/deleteMessage.js +14 -25
  65. package/src/deleteThread.js +13 -26
  66. package/src/editMessage.js +50 -56
  67. package/src/forwardAttachment.js +16 -28
  68. package/src/getAccessToken.js +28 -0
  69. package/src/getCurrentUserID.js +3 -3
  70. package/src/getEmojiUrl.js +8 -10
  71. package/src/getFriendsList.js +15 -25
  72. package/src/getMessage.js +81 -813
  73. package/src/getThreadHistory.js +98 -241
  74. package/src/getThreadInfo.js +286 -89
  75. package/src/getThreadInfoOLD.js +422 -0
  76. package/src/getThreadList.js +158 -215
  77. package/src/getThreadMain.js +220 -0
  78. package/src/getThreadPictures.js +20 -40
  79. package/src/getUID.js +49 -112
  80. package/src/getUserID.js +14 -18
  81. package/src/getUserInfo.js +75 -34
  82. package/src/getUserInfoMain.js +65 -0
  83. package/src/getUserInfoV2.js +32 -0
  84. package/src/getUserInfoV3.js +63 -0
  85. package/src/getUserInfoV4.js +55 -0
  86. package/src/getUserInfoV5.js +61 -0
  87. package/src/handleFriendRequest.js +14 -25
  88. package/src/handleMessageRequest.js +21 -37
  89. package/src/httpGet.js +22 -37
  90. package/src/httpPost.js +20 -36
  91. package/src/httpPostFormData.js +23 -52
  92. package/src/listenMqtt.js +667 -414
  93. package/src/listenMqttV1.js +846 -0
  94. package/src/logout.js +17 -24
  95. package/src/markAsDelivered.js +16 -23
  96. package/src/markAsRead.js +28 -43
  97. package/src/markAsReadAll.js +14 -21
  98. package/src/markAsSeen.js +19 -29
  99. package/src/muteThread.js +13 -18
  100. package/src/removeUserFromGroup.js +18 -48
  101. package/src/resolvePhotoUrl.js +14 -22
  102. package/src/searchForThread.js +13 -23
  103. package/src/sendMessage.js +125 -181
  104. package/src/sendMqttMessage.js +71 -0
  105. package/src/sendTypingIndicator.js +80 -28
  106. package/src/setMessageReaction.js +20 -33
  107. package/src/setPostReaction.js +95 -105
  108. package/src/setTitle.js +19 -35
  109. package/src/shareContact.js +37 -92
  110. package/src/shareLink.js +5 -6
  111. package/src/threadColors.js +17 -109
  112. package/src/unfriend.js +11 -20
  113. package/src/unsendMessage.js +33 -30
  114. package/src/unsendMqttMessage.js +66 -0
  115. package/test/data/shareAttach.js +146 -0
  116. package/test/data/something.mov +1 -0
  117. package/test/data/test.png +1 -0
  118. package/test/data/test.txt +1 -0
  119. package/test/env/.env +1 -0
  120. package/test/example-config.json +18 -0
  121. package/test/test-page.js +140 -0
  122. package/test/test.js +385 -0
  123. package/test/testv2.js +3 -0
  124. package/utils.js +2908 -1247
  125. package/replit.nix +0 -3
  126. package/src/changeAvatar.js +0 -136
  127. package/src/changeBlockedStatusMqtt.js +0 -80
  128. package/src/changeCover.js +0 -72
  129. package/src/changeName.js +0 -78
  130. package/src/changeUsername.js +0 -58
  131. package/src/createCommentPost.js +0 -229
  132. package/src/createPost.js +0 -275
  133. package/src/data/getThreadInfo.json +0 -1
  134. package/src/editMessageOld.js +0 -67
  135. package/src/follow.js +0 -74
  136. package/src/getAccess.js +0 -112
  137. package/src/getAvatarUser.js +0 -78
  138. package/src/getBotInitialData.js +0 -42
  139. package/src/getRegion.js +0 -7
  140. package/src/getThreadHistoryDeprecated.js +0 -93
  141. package/src/getThreadInfoDeprecated.js +0 -80
  142. package/src/getThreadListDeprecated.js +0 -75
  143. package/src/listenNotification.js +0 -85
  144. package/src/pinMessage.js +0 -59
  145. package/src/refreshFb_dtsg.js +0 -89
  146. package/src/searchStickers.js +0 -53
  147. package/src/sendMessageMqtt.js +0 -316
  148. package/src/setMessageReactionMqtt.js +0 -62
  149. package/src/setProfileGuard.js +0 -44
  150. package/src/setStoryReaction.js +0 -64
  151. package/src/stopListenMqtt.js +0 -23
  152. package/src/uploadAttachment.js +0 -94
@@ -1,56 +1,42 @@
1
1
  "use strict";
2
2
 
3
- const utils = require("../utils");
4
- // @NethWs3Dev
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
7
  return function changeNickname(nickname, threadID, participantID, callback) {
8
- let resolveFunc = function () {};
9
- let rejectFunc = function () {};
10
- const 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
15
  callback = function (err) {
16
- if (err) {
17
- return rejectFunc(err);
18
- }
16
+ if (err) return rejectFunc(err);
19
17
  resolveFunc();
20
18
  };
21
19
  }
22
20
 
23
- const form = {
21
+ var form = {
24
22
  nickname: nickname,
25
23
  participant_id: participantID,
26
- thread_or_other_fbid: threadID,
24
+ thread_or_other_fbid: threadID
27
25
  };
28
26
 
29
27
  defaultFuncs
30
- .post(
31
- "https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1",
32
- ctx.jar,
33
- form,
34
- )
28
+ .post("https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1", ctx.jar, form)
35
29
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
36
30
  .then(function (resData) {
37
- if (resData.error === 1545014) {
38
- throw { error: "Trying to change nickname of user isn't in thread" };
39
- }
40
- if (resData.error === 1357031) {
41
- throw {
42
- error:
43
- "Trying to change user nickname of a thread that doesn't exist. Have at least one message in the thread before trying to change the user nickname.",
44
- };
45
- }
46
- if (resData.error) {
47
- throw resData;
48
- }
31
+ if (resData.error === 1545014) throw { error: "Trying to change nickname of user isn't in thread" };
32
+ if (resData.error === 1357031) throw { error: "Trying to change user nickname of a thread that doesn't exist. Have at least one message in the thread before trying to change the user nickname." };
33
+
34
+ if (resData.error) throw resData;
49
35
 
50
36
  return callback();
51
37
  })
52
38
  .catch(function (err) {
53
- console.error("changeNickname", err);
39
+ log.error("changeNickname", err);
54
40
  return callback(err);
55
41
  });
56
42
 
@@ -1,32 +1,31 @@
1
1
  "use strict";
2
2
 
3
- const utils = require("../utils");
4
- // @NethWs3Dev
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
7
  return function changeThreadColor(color, threadID, callback) {
8
- let resolveFunc = function () {};
9
- let rejectFunc = function () {};
10
- const 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
16
  callback = function (err) {
17
- if (err) {
18
- return rejectFunc(err);
19
- }
17
+ if (err) return rejectFunc(err);
20
18
  resolveFunc(err);
21
19
  };
22
20
  }
23
21
 
24
- if (!isNaN(color)) {
25
- color = color.toString();
26
- }
27
- const validatedColor = color !== null ? color.toLowerCase() : color; // API only accepts lowercase letters in hex string
22
+ var validatedColor = color !== null ? color.toLowerCase() : color; // API only accepts lowercase letters in hex string
23
+ var colorList = Object.keys(api.threadColors).map(function (name) {
24
+ return api.threadColors[name];
25
+ });
26
+ if (!colorList.includes(validatedColor)) throw { error: "The color you are trying to use is not a valid thread color. Use api.threadColors to find acceptable values." };
28
27
 
29
- const form = {
28
+ var form = {
30
29
  dpr: 1,
31
30
  queries: JSON.stringify({
32
31
  o0: {
@@ -38,25 +37,23 @@ module.exports = function (defaultFuncs, api, ctx) {
38
37
  client_mutation_id: "0",
39
38
  source: "SETTINGS",
40
39
  theme_id: validatedColor,
41
- thread_id: threadID,
42
- },
43
- },
44
- },
45
- }),
40
+ thread_id: threadID
41
+ }
42
+ }
43
+ }
44
+ })
46
45
  };
47
46
 
48
47
  defaultFuncs
49
48
  .post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
50
49
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
51
50
  .then(function (resData) {
52
- if (resData[resData.length - 1].error_results > 0) {
53
- throw new utils.CustomError(resData[0].o0.errors);
54
- }
51
+ if (resData[resData.length - 1].error_results > 0) throw resData[0].o0.errors;
55
52
 
56
53
  return callback();
57
54
  })
58
55
  .catch(function (err) {
59
- console.error("changeThreadColor", err);
56
+ log.error("changeThreadColor", err);
60
57
  return callback(err);
61
58
  });
62
59
 
@@ -1,52 +1,39 @@
1
1
  "use strict";
2
2
 
3
- const utils = require("../utils");
4
- // @NethWs3Dev
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
7
  return function changeThreadEmoji(emoji, threadID, callback) {
8
- let resolveFunc = function () {};
9
- let rejectFunc = function () {};
10
- const 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
16
  callback = function (err) {
17
- if (err) {
18
- return rejectFunc(err);
19
- }
17
+ if (err) return rejectFunc(err);
20
18
  resolveFunc();
21
19
  };
22
20
  }
23
- const form = {
21
+ var form = {
24
22
  emoji_choice: emoji,
25
- thread_or_other_fbid: threadID,
23
+ thread_or_other_fbid: threadID
26
24
  };
27
25
 
28
26
  defaultFuncs
29
- .post(
30
- "https://www.facebook.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg",
31
- ctx.jar,
32
- form,
33
- )
27
+ .post("https://www.facebook.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg", ctx.jar, form)
34
28
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
35
29
  .then(function (resData) {
36
- if (resData.error === 1357031) {
37
- throw {
38
- error:
39
- "Trying to change emoji of a chat that doesn't exist. Have at least one message in the thread before trying to change the emoji.",
40
- };
41
- }
42
- if (resData.error) {
43
- throw resData;
44
- }
30
+ if (resData.error === 1357031) throw { error: "Trying to change emoji of a chat that doesn't exist. Have at least one message in the thread before trying to change the emoji." };
31
+ if (resData.error) throw resData;
45
32
 
46
33
  return callback();
47
34
  })
48
35
  .catch(function (err) {
49
- console.error("changeThreadEmoji", err);
36
+ log.error("changeThreadEmoji", err);
50
37
  return callback(err);
51
38
  });
52
39
 
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
- const utils = require("../utils");
4
- // @NethWs3Dev
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
7
  return function createNewGroup(participantIDs, groupTitle, callback) {
@@ -10,41 +10,29 @@ module.exports = function (defaultFuncs, api, ctx) {
10
10
  groupTitle = null;
11
11
  }
12
12
 
13
- if (utils.getType(participantIDs) !== "Array") {
14
- throw { error: "createNewGroup: participantIDs should be an array." };//
15
- }
13
+ if (utils.getType(participantIDs) !== "Array") throw { error: "createNewGroup: participantIDs should be an array." };
16
14
 
17
- if (participantIDs.length < 2) {
18
- throw {
19
- error: "createNewGroup: participantIDs should have at least 2 IDs.",
20
- };
21
- }
15
+ if (participantIDs.length < 2) throw { error: "createNewGroup: participantIDs should have at least 2 IDs." };
22
16
 
23
- let resolveFunc = function () {};
24
- let rejectFunc = function () {};
25
- const returnPromise = new Promise(function (resolve, reject) {
17
+ var resolveFunc = function () { };
18
+ var rejectFunc = function () { };
19
+ var returnPromise = new Promise(function (resolve, reject) {
26
20
  resolveFunc = resolve;
27
21
  rejectFunc = reject;
28
22
  });
29
23
 
30
24
  if (!callback) {
31
25
  callback = function (err, threadID) {
32
- if (err) {
33
- return rejectFunc(err);
34
- }
26
+ if (err) return rejectFunc(err);
35
27
  resolveFunc(threadID);
36
28
  };
37
29
  }
38
30
 
39
- const pids = [];
40
- for (const n in participantIDs) {
41
- pids.push({
42
- fbid: participantIDs[n],
43
- });
44
- }
31
+ var pids = [];
32
+ for (var n in participantIDs) pids.push({ fbid: participantIDs[n] });
45
33
  pids.push({ fbid: ctx.userID });
46
34
 
47
- const form = {
35
+ var form = {
48
36
  fb_api_caller_class: "RelayModern",
49
37
  fb_api_req_friendly_name: "MessengerGroupCreateMutation",
50
38
  av: ctx.userID,
@@ -59,27 +47,21 @@ module.exports = function (defaultFuncs, api, ctx) {
59
47
  thread_settings: {
60
48
  name: groupTitle,
61
49
  joinable_mode: "PRIVATE",
62
- thread_image_fbid: null,
63
- },
64
- },
65
- }),
50
+ thread_image_fbid: null
51
+ }
52
+ }
53
+ })
66
54
  };
67
55
 
68
56
  defaultFuncs
69
57
  .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
70
58
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
71
59
  .then(function (resData) {
72
- if (resData.errors) {
73
- throw resData;
74
- }
75
- return callback(
76
- null,
77
- resData.data.messenger_group_thread_create.thread.thread_key
78
- .thread_fbid,
79
- );
60
+ if (resData.errors) throw resData;
61
+ return callback(null, resData.data.messenger_group_thread_create.thread.thread_key.thread_fbid);
80
62
  })
81
63
  .catch(function (err) {
82
- console.error("createNewGroup", err);
64
+ log.error("createNewGroup", err);
83
65
  return callback(err);
84
66
  });
85
67
 
package/src/createPoll.js CHANGED
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
 
3
- const utils = require("../utils");
4
- // @NethWs3Dev
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
7
  return function createPoll(title, threadID, options, callback) {
8
- let resolveFunc = function () {};
9
- let rejectFunc = function () {};
10
- const 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,53 +16,42 @@ module.exports = function (defaultFuncs, api, ctx) {
16
16
  if (utils.getType(options) == "Function") {
17
17
  callback = options;
18
18
  options = null;
19
- } else {
19
+ }
20
+ else {
20
21
  callback = function (err) {
21
- if (err) {
22
- return rejectFunc(err);
23
- }
22
+ if (err) return rejectFunc(err);
24
23
  resolveFunc();
25
24
  };
26
25
  }
27
26
  }
28
- if (!options) {
29
- options = {}; // Initial poll options are optional
30
- }
27
+ if (!options) options = {}; // Initial poll options are optional
31
28
 
32
- const form = {
29
+ var form = {
33
30
  target_id: threadID,
34
- question_text: title,
31
+ question_text: title
35
32
  };
36
33
 
37
34
  // Set fields for options (and whether they are selected initially by the posting user)
38
- let ind = 0;
39
- for (const opt in options) {
35
+ var ind = 0;
36
+ for (var opt in options) {
40
37
  // eslint-disable-next-line no-prototype-builtins
41
38
  if (options.hasOwnProperty(opt)) {
42
39
  form["option_text_array[" + ind + "]"] = opt;
43
- form["option_is_selected_array[" + ind + "]"] = options[opt]
44
- ? "1"
45
- : "0";
40
+ form["option_is_selected_array[" + ind + "]"] = options[opt] ? "1" : "0";
46
41
  ind++;
47
42
  }
48
43
  }
49
44
 
50
45
  defaultFuncs
51
- .post(
52
- "https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1",
53
- ctx.jar,
54
- form,
55
- )
46
+ .post("https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1", ctx.jar, form)
56
47
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
57
48
  .then(function (resData) {
58
- if (resData.payload.status != "success") {
59
- throw resData;
60
- }
49
+ if (resData.payload.status != "success") throw resData;
61
50
 
62
51
  return callback();
63
52
  })
64
53
  .catch(function (err) {
65
- console.error("createPoll", err);
54
+ log.error("createPoll", err);
66
55
  return callback(err);
67
56
  });
68
57
 
@@ -1,53 +1,42 @@
1
1
  "use strict";
2
2
 
3
- const utils = require("../utils");
4
- // @NethWs3Dev
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
7
  return function deleteMessage(messageOrMessages, callback) {
8
- let resolveFunc = function () {};
9
- let rejectFunc = function () {};
10
- const 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
15
  callback = function (err) {
16
- if (err) {
17
- return rejectFunc(err);
18
- }
16
+ if (err) return rejectFunc(err);
17
+
19
18
  resolveFunc();
20
19
  };
21
20
  }
22
21
 
23
- const form = {
24
- client: "mercury",
22
+ var form = {
23
+ client: "mercury"
25
24
  };
26
25
 
27
- if (utils.getType(messageOrMessages) !== "Array") {
28
- messageOrMessages = [messageOrMessages];
29
- }
26
+ if (utils.getType(messageOrMessages) !== "Array") messageOrMessages = [messageOrMessages];
30
27
 
31
- for (let i = 0; i < messageOrMessages.length; i++) {
32
- form["message_ids[" + i + "]"] = messageOrMessages[i];
33
- }
28
+ for (var i = 0; i < messageOrMessages.length; i++) form["message_ids[" + i + "]"] = messageOrMessages[i];
34
29
 
35
30
  defaultFuncs
36
- .post(
37
- "https://www.facebook.com/ajax/mercury/delete_messages.php",
38
- ctx.jar,
39
- form,
40
- )
31
+ .post("https://www.facebook.com/ajax/mercury/delete_messages.php", ctx.jar, form)
41
32
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
42
33
  .then(function (resData) {
43
- if (resData.error) {
44
- throw resData;
45
- }
34
+ if (resData.error) throw resData;
46
35
 
47
36
  return callback();
48
37
  })
49
38
  .catch(function (err) {
50
- console.error("deleteMessage", err);
39
+ log.error("deleteMessage", err);
51
40
  return callback(err);
52
41
  });
53
42
 
@@ -1,53 +1,40 @@
1
1
  "use strict";
2
2
 
3
- const utils = require("../utils");
4
- // @NethWs3Dev
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
7
  return function deleteThread(threadOrThreads, callback) {
8
- let resolveFunc = function () {};
9
- let rejectFunc = function () {};
10
- const 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
15
  callback = function (err) {
16
- if (err) {
17
- return rejectFunc(err);
18
- }
16
+ if (err) return rejectFunc(err);
19
17
  resolveFunc();
20
18
  };
21
19
  }
22
20
 
23
- const form = {
24
- client: "mercury",
21
+ var form = {
22
+ client: "mercury"
25
23
  };
26
24
 
27
- if (utils.getType(threadOrThreads) !== "Array") {
28
- threadOrThreads = [threadOrThreads];
29
- }
30
-
31
- for (let i = 0; i < threadOrThreads.length; i++) {
32
- form["ids[" + i + "]"] = threadOrThreads[i];
33
- }
25
+ if (utils.getType(threadOrThreads) !== "Array") threadOrThreads = [threadOrThreads];
26
+ for (var i = 0; i < threadOrThreads.length; i++) form["ids[" + i + "]"] = threadOrThreads[i];
34
27
 
35
28
  defaultFuncs
36
- .post(
37
- "https://www.facebook.com/ajax/mercury/delete_thread.php",
38
- ctx.jar,
39
- form,
40
- )
29
+ .post("https://www.facebook.com/ajax/mercury/delete_thread.php", ctx.jar, form)
41
30
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
42
31
  .then(function (resData) {
43
- if (resData.error) {
44
- throw resData;
45
- }
32
+ if (resData.error) throw resData;
46
33
 
47
34
  return callback();
48
35
  })
49
36
  .catch(function (err) {
50
- console.error("deleteThread", err);
37
+ log.error("deleteThread", err);
51
38
  return callback(err);
52
39
  });
53
40
 
@@ -1,59 +1,53 @@
1
- "use_strict";
1
+ /* eslint-disable linebreak-style */
2
+ "use strict";
2
3
 
3
- const { generateOfflineThreadingID } = require('../utils');
4
-
5
- function isCallable(func) {
6
- try {
7
- Reflect.apply(func, null, []);
8
- return true;
9
- } catch (error) {
10
- return false;
11
- }
12
- }
4
+ var utils = require("../utils");
13
5
 
14
6
  module.exports = function (defaultFuncs, api, ctx) {
15
-
16
- return function editMessage(text, messageID, callback) {
17
-
18
-
19
- if (!ctx.mqttClient) {
20
- throw new Error('Not connected to MQTT');
21
- }
22
-
23
- ctx.wsReqNumber ??= 0;
24
- ctx.wsTaskNumber ??= 0;
25
- ctx.wsReqNumber += 1;
26
- ctx.wsTaskNumber += 1;
27
-
28
- const taskPayload = {
29
- message_id: messageID,
30
- text: text,
31
- };
32
-
33
- const task = {
34
- failure_count: null,
35
- label: '742',
36
- payload: JSON.stringify(taskPayload),
37
- queue_name: 'edit_message',
38
- task_id: ctx.wsTaskNumber,
39
- };
40
-
41
- const content = {
42
- app_id: '2220391788200892',
43
- payload: {
44
- data_trace_id: null,
45
- epoch_id: parseInt(generateOfflineThreadingID()),
46
- tasks: [],
47
- version_id: '6903494529735864',
48
- },
49
- request_id: ctx.wsReqNumber,
50
- type: 3,
51
- };
52
-
53
- content.payload.tasks.push(task);
54
- content.payload = JSON.stringify(content.payload);
55
-
56
- /* if (isCallable(callback)) ctx.reqCallbacks[ctx.wsReqNumber] = callback; */
57
- ctx.mqttClient.publish('/ls_req', JSON.stringify(content), { qos: 1, retain: false });
58
- };
59
- }
7
+ return function editMessage(messageID, changedText, callback) {
8
+ var resolveFunc = function () { };
9
+ var rejectFunc = function () { };
10
+
11
+ var returnPromise = new Promise(function (resolve, reject) {
12
+ resolveFunc = resolve;
13
+ rejectFunc = reject;
14
+ });
15
+
16
+ if (!callback) {
17
+ callback = function (err, data) {
18
+ if (err) return rejectFunc(err);
19
+ resolveFunc(data);
20
+ };
21
+ }
22
+ ctx.mqttClient.publish('/ls_req',
23
+ JSON.stringify({
24
+ app_id: "2220391788200892",
25
+ payload: JSON.stringify({
26
+ tasks: [{
27
+ label: 742,
28
+ payload: JSON.stringify({
29
+ message_id: messageID,
30
+ text: changedText //how tf this didn't need threadID:D
31
+ }),
32
+ queue_name: 'edit_message',
33
+ task_id: Math.random() * 1001 << 0,
34
+ failure_count: null,
35
+ }],
36
+ epoch_id: utils.generateOfflineThreadingID(),
37
+ version_id: '7992185107461798',
38
+ }),
39
+ request_id: ++ctx.req_ID,
40
+ type: 3
41
+ }),
42
+ {
43
+ qos: 1,
44
+ retain: false,
45
+ }
46
+ );
47
+ ctx.callback_Task[ctx.req_ID] = new Object({
48
+ callback,
49
+ type: "editMessage"
50
+ });
51
+ return returnPromise;
52
+ };
53
+ };