fca-smart-shankar 13.0.0 → 16.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 (169) hide show
  1. package/.cache/replit/env/latest +56 -0
  2. package/.cache/replit/env/latest.json +1 -0
  3. package/.cache/replit/modules/nodejs-14.res +1 -0
  4. package/.cache/replit/modules/replit.res +1 -0
  5. package/.cache/replit/modules/web.res +1 -0
  6. package/.cache/replit/modules.stamp +0 -0
  7. package/.cache/typescript/5.5/package.json +1 -0
  8. package/.config/configstore/update-notifier-npm.json +4 -0
  9. package/.gitattributes +2 -0
  10. package/.replit +3 -12
  11. package/.upm/store.json +1 -1
  12. package/Extra/Balancer.js +49 -0
  13. package/Extra/Bypass/956/index.js +234 -0
  14. package/Extra/Bypass/test/aaaa.json +170 -0
  15. package/Extra/Bypass/test/index.js +188 -0
  16. package/Extra/Database/index.js +469 -0
  17. package/Extra/ExtraAddons.js +82 -0
  18. package/Extra/ExtraFindUID.js +62 -0
  19. package/Extra/ExtraGetThread.js +365 -0
  20. package/Extra/ExtraScreenShot.js +430 -0
  21. package/Extra/ExtraUptimeRobot.js +38 -0
  22. package/Extra/Html/Classic/script.js +119 -0
  23. package/Extra/Html/Classic/style.css +8 -0
  24. package/Extra/Security/AES_256_GCM/index.js +0 -0
  25. package/Extra/Security/Base/Step_1.js +6 -0
  26. package/Extra/Security/Base/Step_2.js +22 -0
  27. package/Extra/Security/Base/Step_3.js +22 -0
  28. package/Extra/Security/Base/index.js +191 -0
  29. package/Extra/Security/Index.js +5 -0
  30. package/Extra/Security/Step_1.js +6 -0
  31. package/Extra/Security/Step_2.js +22 -0
  32. package/Extra/Security/Step_3.js +22 -0
  33. package/Extra/Src/Change_Environment.js +24 -0
  34. package/Extra/Src/Check_Update.js +67 -0
  35. package/Extra/Src/History.js +115 -0
  36. package/Extra/Src/Instant_Update.js +65 -0
  37. package/Extra/Src/Last-Run.js +65 -0
  38. package/Extra/Src/Premium.js +81 -0
  39. package/Extra/Src/Release_Memory.js +160 -0
  40. package/Extra/Src/Websocket.js +213 -0
  41. package/Extra/Src/image/checkmate.jpg +0 -0
  42. package/Extra/Src/test.js +28 -0
  43. package/Extra/Src/uuid.js +137 -0
  44. package/Func/AcceptAgreement.js +31 -0
  45. package/Func/ClearCache.js +64 -0
  46. package/Func/ReportV1.js +54 -0
  47. package/LICENSE +678 -0
  48. package/Language/index.json +228 -0
  49. package/Main.js +1444 -0
  50. package/README.md +30 -175
  51. package/SECURITY.md +18 -0
  52. package/broadcast.js +44 -0
  53. package/index.js +414 -511
  54. package/logger.js +66 -0
  55. package/package.json +85 -370
  56. package/src/Dev_Horizon_Data.js +125 -0
  57. package/src/Dev_getThreadInfoOLD.js +422 -0
  58. package/src/Dev_shareTest2.js +68 -0
  59. package/src/Dev_shareTest3.js +71 -0
  60. package/src/Premium.js +25 -0
  61. package/src/Screenshot.js +83 -0
  62. package/src/addExternalModule.js +5 -14
  63. package/src/addUserToGroup.js +20 -56
  64. package/src/changeAdminStatus.js +20 -44
  65. package/src/changeArchivedStatus.js +11 -25
  66. package/src/{changeAvatarV2.js → changeAvt.js} +2 -3
  67. package/src/changeBio.js +15 -26
  68. package/src/changeBlockedStatus.js +8 -21
  69. package/src/changeGroupImage.js +24 -53
  70. package/src/changeNickname.js +13 -27
  71. package/src/changeThreadColor.js +19 -22
  72. package/src/changeThreadEmoji.js +11 -24
  73. package/src/createNewGroup.js +20 -38
  74. package/src/createPoll.js +16 -27
  75. package/src/deleteMessage.js +13 -24
  76. package/src/deleteThread.js +12 -25
  77. package/src/editMessage.js +53 -71
  78. package/src/forwardAttachment.js +15 -27
  79. package/src/getAccessToken.js +28 -0
  80. package/src/getCurrentUserID.js +1 -1
  81. package/src/getEmojiUrl.js +8 -10
  82. package/src/getFriendsList.js +15 -25
  83. package/src/getMessage.js +81 -813
  84. package/src/getThreadHistory.js +98 -241
  85. package/src/getThreadInfo.js +287 -90
  86. package/src/getThreadInfoOLD.js +422 -0
  87. package/src/getThreadList.js +157 -214
  88. package/src/getThreadMain.js +220 -0
  89. package/src/getThreadPictures.js +19 -39
  90. package/src/getUID.js +50 -113
  91. package/src/getUserID.js +14 -18
  92. package/src/getUserInfo.js +71 -65
  93. package/src/getUserInfoMain.js +65 -0
  94. package/src/getUserInfoV2.js +32 -0
  95. package/src/getUserInfoV3.js +63 -0
  96. package/src/getUserInfoV4.js +55 -0
  97. package/src/getUserInfoV5.js +61 -0
  98. package/src/handleFriendRequest.js +13 -24
  99. package/src/handleMessageRequest.js +20 -36
  100. package/src/httpGet.js +18 -34
  101. package/src/httpPost.js +18 -35
  102. package/src/httpPostFormData.js +24 -53
  103. package/src/listenMqtt.js +944 -680
  104. package/src/listenMqttV1.js +846 -0
  105. package/src/logout.js +15 -22
  106. package/src/markAsDelivered.js +15 -25
  107. package/src/markAsRead.js +27 -45
  108. package/src/markAsReadAll.js +14 -21
  109. package/src/markAsSeen.js +18 -28
  110. package/src/muteThread.js +12 -17
  111. package/src/removeUserFromGroup.js +17 -47
  112. package/src/resolvePhotoUrl.js +13 -21
  113. package/src/searchForThread.js +13 -23
  114. package/src/sendMessage.js +117 -178
  115. package/src/sendMqttMessage.js +71 -0
  116. package/src/sendTypingIndicator.js +16 -46
  117. package/src/setMessageReaction.js +20 -33
  118. package/src/setPostReaction.js +95 -105
  119. package/src/setTitle.js +18 -34
  120. package/src/shareContact.js +37 -92
  121. package/src/shareLink.js +4 -5
  122. package/src/threadColors.js +18 -110
  123. package/src/unfriend.js +9 -18
  124. package/src/unsendMessage.js +34 -31
  125. package/src/unsendMqttMessage.js +66 -0
  126. package/test/Database_Test.js +4 -0
  127. package/test/Db2.js +530 -0
  128. package/test/Shankar_Database/A_README.md +1 -0
  129. package/test/Shankar_Database/Database.db +0 -0
  130. package/test/data/shareAttach.js +1 -1
  131. package/test/env/.env +0 -0
  132. package/test/example-db.db +0 -0
  133. package/test/memoryleak.js +18 -0
  134. package/test/test.js +1 -1
  135. package/test/testname.js +1342 -0
  136. package/test/testv2.js +3 -0
  137. package/utils.js +2918 -1393
  138. package/CHANGELOG.md +0 -2
  139. package/LICENSE-MIT +0 -21
  140. package/generated-icon.png +0 -0
  141. package/replit.nix +0 -5
  142. package/shankar-fca.json +0 -4
  143. package/src/changeAvatar.js +0 -136
  144. package/src/changeBlockedStatusMqtt.js +0 -80
  145. package/src/changeCover.js +0 -73
  146. package/src/changeName.js +0 -79
  147. package/src/changeUsername.js +0 -59
  148. package/src/createCommentPost.js +0 -230
  149. package/src/createPost.js +0 -277
  150. package/src/data/getThreadInfo.json +0 -1
  151. package/src/editMessageOld.js +0 -67
  152. package/src/follow.js +0 -74
  153. package/src/getAccess.js +0 -112
  154. package/src/getAvatarUser.js +0 -78
  155. package/src/getRegion.js +0 -7
  156. package/src/getThreadHistoryDeprecated.js +0 -93
  157. package/src/getThreadInfoDeprecated.js +0 -80
  158. package/src/getThreadListDeprecated.js +0 -75
  159. package/src/listenNotification.js +0 -85
  160. package/src/pinMessage.js +0 -59
  161. package/src/refreshFb_dtsg.js +0 -89
  162. package/src/searchStickers.js +0 -53
  163. package/src/sendMessageMqtt.js +0 -322
  164. package/src/sendTypingIndicatorV2.js +0 -28
  165. package/src/setMessageReactionMqtt.js +0 -62
  166. package/src/setProfileGuard.js +0 -45
  167. package/src/setStoryReaction.js +0 -64
  168. package/src/stopListenMqtt.js +0 -26
  169. package/src/uploadAttachment.js +0 -94
@@ -1,57 +1,36 @@
1
1
  "use strict";
2
2
 
3
- const utils = require("../utils");
4
- const log = require("npmlog");
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
7
  return function addUserToGroup(userID, 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
- if (
16
- !callback &&
17
- (utils.getType(threadID) === "Function" ||
18
- utils.getType(threadID) === "AsyncFunction")
19
- ) {
20
- throw new utils.CustomError({
21
- error: "please pass a threadID as a second argument.",
22
- });
23
- }
15
+ if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
24
16
 
25
17
  if (!callback) {
26
18
  callback = function (err) {
27
- if (err) {
28
- return rejectFunc(err);
29
- }
19
+ if (err) return rejectFunc(err);
30
20
  resolveFunc();
31
21
  };
32
22
  }
23
+
24
+ if (utils.getType(threadID) !== "Number" && utils.getType(threadID) !== "String") throw { error: "ThreadID should be of type Number or String and not " + utils.getType(threadID) + "." };
33
25
 
34
- if (
35
- utils.getType(threadID) !== "Number" &&
36
- utils.getType(threadID) !== "String"
37
- ) {
38
- throw new utils.CustomError({
39
- error:
40
- "ThreadID should be of type Number or String and not " +
41
- utils.getType(threadID) +
42
- ".",
43
- });
44
- }
45
26
 
46
- if (utils.getType(userID) !== "Array") {
47
- userID = [userID];
48
- }
27
+ if (utils.getType(userID) !== "Array") userID = [userID];
49
28
 
50
- const messageAndOTID = utils.generateOfflineThreadingID();
51
- const form = {
29
+ var messageAndOTID = utils.generateOfflineThreadingID();
30
+ var form = {
52
31
  client: "mercury",
53
32
  action_type: "ma-type:log-message",
54
- author: "fbid:" + (ctx.i_userID || ctx.userID),
33
+ author: "fbid:" + ctx.userID,
55
34
  thread_id: "",
56
35
  timestamp: Date.now(),
57
36
  timestamp_absolute: "Today",
@@ -72,36 +51,21 @@ module.exports = function (defaultFuncs, api, ctx) {
72
51
  message_id: messageAndOTID,
73
52
  threading_id: utils.generateThreadingID(ctx.clientID),
74
53
  manual_retry_cnt: "0",
75
- thread_fbid: threadID,
54
+ thread_fbid: threadID
76
55
  };
77
56
 
78
- for (let i = 0; i < userID.length; i++) {
79
- if (
80
- utils.getType(userID[i]) !== "Number" &&
81
- utils.getType(userID[i]) !== "String"
82
- ) {
83
- throw new utils.CustomError({
84
- error:
85
- "Elements of userID should be of type Number or String and not " +
86
- utils.getType(userID[i]) +
87
- ".",
88
- });
89
- }
90
-
91
- form["log_message_data[added_participants][" + i + "]"] =
92
- "fbid:" + userID[i];
57
+ for (var i = 0; i < userID.length; i++) {
58
+ if (utils.getType(userID[i]) !== "Number" && utils.getType(userID[i]) !== "String") throw { error: "Elements of userID should be of type Number or String and not " + utils.getType(userID[i]) + "." };
59
+ form["log_message_data[added_participants][" + i + "]"] = "fbid:" + userID[i];
93
60
  }
94
61
 
95
62
  defaultFuncs
96
63
  .post("https://www.facebook.com/messaging/send/", ctx.jar, form)
97
64
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
98
65
  .then(function (resData) {
99
- if (!resData) {
100
- throw new utils.CustomError({ error: "Add to group failed." });
101
- }
102
- if (resData.error) {
103
- throw new utils.CustomError(resData);
104
- }
66
+ if (!resData) throw { error: "Add to group failed." };
67
+ if (resData.error) throw resData;
68
+
105
69
 
106
70
  return callback();
107
71
  })
@@ -3,12 +3,10 @@
3
3
  const utils = require("../utils");
4
4
  const log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function changeAdminStatus(threadID, adminIDs, adminStatus, callback) {
8
8
  if (utils.getType(threadID) !== "String") {
9
- throw new utils.CustomError({
10
- error: "changeAdminStatus: threadID must be a string",
11
- });
9
+ throw {error: "changeAdminStatus: threadID must be a string"};
12
10
  }
13
11
 
14
12
  if (utils.getType(adminIDs) === "String") {
@@ -16,20 +14,16 @@ module.exports = function (defaultFuncs, api, ctx) {
16
14
  }
17
15
 
18
16
  if (utils.getType(adminIDs) !== "Array") {
19
- throw new utils.CustomError({
20
- error: "changeAdminStatus: adminIDs must be an array or string",
21
- });
17
+ throw {error: "changeAdminStatus: adminIDs must be an array or string"};
22
18
  }
23
19
 
24
20
  if (utils.getType(adminStatus) !== "Boolean") {
25
- throw new utils.CustomError({
26
- error: "changeAdminStatus: adminStatus must be a string",
27
- });
21
+ throw {error: "changeAdminStatus: adminStatus must be a string"};
28
22
  }
29
23
 
30
- let resolveFunc = function () {};
31
- let rejectFunc = function () {};
32
- const returnPromise = new Promise(function (resolve, reject) {
24
+ var resolveFunc = function(){};
25
+ var rejectFunc = function(){};
26
+ var returnPromise = new Promise(function (resolve, reject) {
33
27
  resolveFunc = resolve;
34
28
  rejectFunc = reject;
35
29
  });
@@ -43,61 +37,43 @@ module.exports = function (defaultFuncs, api, ctx) {
43
37
  };
44
38
  }
45
39
 
46
- if (
47
- utils.getType(callback) !== "Function" &&
48
- utils.getType(callback) !== "AsyncFunction"
49
- ) {
50
- throw new utils.CustomError({
51
- error: "changeAdminStatus: callback is not a function",
52
- });
40
+ if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
41
+ throw {error: "changeAdminStatus: callback is not a function"};
53
42
  }
54
43
 
55
- const form = {
56
- thread_fbid: threadID,
44
+ let form = {
45
+ "thread_fbid": threadID,
57
46
  };
58
47
 
59
48
  let i = 0;
60
- for (const u of adminIDs) {
49
+ for (let u of adminIDs) {
61
50
  form[`admin_ids[${i++}]`] = u;
62
51
  }
63
52
  form["add"] = adminStatus;
64
53
 
65
54
  defaultFuncs
66
- .post(
67
- "https://www.facebook.com/messaging/save_admins/?dpr=1",
68
- ctx.jar,
69
- form,
70
- )
55
+ .post("https://www.facebook.com/messaging/save_admins/?dpr=1", ctx.jar, form)
71
56
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
72
- .then(function (resData) {
57
+ .then(function(resData) {
73
58
  if (resData.error) {
74
59
  switch (resData.error) {
75
60
  case 1976004:
76
- throw new utils.CustomError({
77
- error: "Cannot alter admin status: you are not an admin.",
78
- rawResponse: resData,
79
- });
61
+ throw { error: "Cannot alter admin status: you are not an admin.", rawResponse: resData };
80
62
  case 1357031:
81
- throw new utils.CustomError({
82
- error:
83
- "Cannot alter admin status: this thread is not a group chat.",
84
- rawResponse: resData,
85
- });
63
+ throw { error: "Cannot alter admin status: this thread is not a group chat.", rawResponse: resData };
86
64
  default:
87
- throw new utils.CustomError({
88
- error: "Cannot alter admin status: unknown error.",
89
- rawResponse: resData,
90
- });
65
+ throw { error: "Cannot alter admin status: unknown error.", rawResponse: resData };
91
66
  }
92
67
  }
93
68
 
94
69
  callback();
95
70
  })
96
- .catch(function (err) {
71
+ .catch(function(err) {
97
72
  log.error("changeAdminStatus", err);
98
73
  return callback(err);
99
74
  });
100
-
75
+
101
76
  return returnPromise;
102
77
  };
103
78
  };
79
+
@@ -1,48 +1,34 @@
1
1
  "use strict";
2
2
 
3
- const utils = require("../utils");
4
- const log = require("npmlog");
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
7
  return function changeArchivedStatus(threadOrThreads, archive, 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
21
 
24
- const form = {};
22
+ var form = {};
25
23
 
26
- if (utils.getType(threadOrThreads) === "Array") {
27
- for (let i = 0; i < threadOrThreads.length; i++) {
28
- form["ids[" + threadOrThreads[i] + "]"] = archive;
29
- }
30
- } else {
31
- form["ids[" + threadOrThreads + "]"] = archive;
32
- }
24
+ if (utils.getType(threadOrThreads) === "Array") for (var i = 0; i < threadOrThreads.length; i++) form["ids[" + threadOrThreads[i] + "]"] = archive;
25
+ else form["ids[" + threadOrThreads + "]"] = archive;
33
26
 
34
27
  defaultFuncs
35
- .post(
36
- "https://www.facebook.com/ajax/mercury/change_archived_status.php",
37
- ctx.jar,
38
- form,
39
- )
28
+ .post("https://www.facebook.com/ajax/mercury/change_archived_status.php", ctx.jar, form)
40
29
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
41
30
  .then(function (resData) {
42
- if (resData.error) {
43
- throw resData;
44
- }
45
-
31
+ if (resData.error) throw resData;
46
32
  return callback();
47
33
  })
48
34
  .catch(function (err) {
@@ -1,4 +1,3 @@
1
-
2
1
  "use strict";
3
2
 
4
3
  var utils = require("../utils");
@@ -11,7 +10,7 @@ var log = require("npmlog");
11
10
  * @returns The JSON.parse(Data.split("for (;;);")[1]); is returning the following:
12
11
  * {"__ar":1,"payload":null,"jsmods":{"require":[["ImageUploader","uploadPhoto",[{"__m":"__elem_0"},{"__m":"__elem_1"},{"__m":"__elem_2"},{"__m":"__
13
12
  */
14
- async function postImage(Api, BotID, form) {
13
+ async function postImage(Api,BotID,form) {
15
14
  var Data = await Api.httpPostFormData(`https://www.facebook.com/profile/picture/upload/?profile_id=${BotID}&photo_source=57&av=${BotID}`, form);
16
15
  return JSON.parse(Data.split("for (;;);")[1]);
17
16
  }
@@ -83,4 +82,4 @@ module.exports = function(defaultFuncs, api, ctx) {
83
82
  }
84
83
  return returnPromise;
85
84
  };
86
- };
85
+ };
package/src/changeBio.js CHANGED
@@ -1,43 +1,34 @@
1
1
  "use strict";
2
2
 
3
- const utils = require("../utils");
4
- const log = require("npmlog");
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
7
  return function changeBio(bio, publish, 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
- if (
17
- utils.getType(publish) == "Function" ||
18
- utils.getType(publish) == "AsyncFunction"
19
- ) {
20
- callback = publish;
21
- } else {
16
+ if (utils.getType(publish) == "Function" || utils.getType(publish) == "AsyncFunction") callback = publish;
17
+ else {
22
18
  callback = function (err) {
23
- if (err) {
24
- return rejectFunc(err);
25
- }
19
+ if (err) return rejectFunc(err);
26
20
  resolveFunc();
27
21
  };
28
22
  }
29
23
  }
30
24
 
31
- if (utils.getType(publish) != "Boolean") {
32
- publish = false;
33
- }
34
-
25
+ if (utils.getType(publish) != "Boolean") publish = false;
35
26
  if (utils.getType(bio) != "String") {
36
27
  bio = "";
37
28
  publish = false;
38
29
  }
39
30
 
40
- const form = {
31
+ var form = {
41
32
  fb_api_caller_class: "RelayModern",
42
33
  fb_api_req_friendly_name: "ProfileCometSetBioMutation",
43
34
  // This doc_is is valid as of May 23, 2020
@@ -46,23 +37,21 @@ module.exports = function (defaultFuncs, api, ctx) {
46
37
  input: {
47
38
  bio: bio,
48
39
  publish_bio_feed_story: publish,
49
- actor_id: ctx.i_userID || ctx.userID,
50
- client_mutation_id: Math.round(Math.random() * 1024).toString(),
40
+ actor_id: ctx.userID,
41
+ client_mutation_id: Math.round(Math.random() * 1024).toString()
51
42
  },
52
43
  hasProfileTileViewID: false,
53
44
  profileTileViewID: null,
54
- scale: 1,
45
+ scale: 1
55
46
  }),
56
- av: ctx.i_userID || ctx.userID,
47
+ av: ctx.userID
57
48
  };
58
49
 
59
50
  defaultFuncs
60
51
  .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
61
52
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
62
53
  .then(function (resData) {
63
- if (resData.errors) {
64
- throw resData;
65
- }
54
+ if (resData.errors) throw resData;
66
55
 
67
56
  return callback();
68
57
  })
@@ -1,43 +1,30 @@
1
1
  "use strict";
2
2
 
3
- const utils = require("../utils");
4
- const log = require("npmlog");
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
7
  return function changeBlockedStatus(userID, block, 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
21
 
24
22
  defaultFuncs
25
- .post(
26
- `https://www.facebook.com/messaging/${
27
- block ? "" : "un"
28
- }block_messages/`,
29
- ctx.jar,
30
- {
31
- fbid: userID,
32
- },
33
- )
23
+ .post(`https://www.facebook.com/messaging/${block ? "" : "un"}block_messages/`, ctx.jar, { fbid: userID })
34
24
  .then(utils.saveCookies(ctx.jar))
35
25
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
36
26
  .then(function (resData) {
37
- if (resData.error) {
38
- throw resData;
39
- }
40
-
27
+ if (resData.error) throw resData;
41
28
  return callback();
42
29
  })
43
30
  .catch(function (err) {
@@ -1,40 +1,33 @@
1
1
  "use strict";
2
2
 
3
- const utils = require("../utils");
4
- const log = require("npmlog");
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+ var bluebird = require("bluebird");
5
6
 
6
7
  module.exports = function (defaultFuncs, api, ctx) {
7
8
  function handleUpload(image, callback) {
8
- const uploads = [];
9
+ var uploads = [];
9
10
 
10
- const form = {
11
+ var form = {
11
12
  images_only: "true",
12
- "attachment[]": image,
13
+ "attachment[]": image
13
14
  };
14
15
 
15
16
  uploads.push(
16
17
  defaultFuncs
17
- .postFormData(
18
- "https://upload.facebook.com/ajax/mercury/upload.php",
19
- ctx.jar,
20
- form,
21
- {},
22
- )
18
+ .postFormData("https://upload.facebook.com/ajax/mercury/upload.php", ctx.jar, form, {})
23
19
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
24
20
  .then(function (resData) {
25
- if (resData.error) {
26
- throw resData;
27
- }
21
+ if (resData.error) throw resData;
28
22
 
29
23
  return resData.payload.metadata[0];
30
- }),
24
+ })
31
25
  );
32
26
 
33
27
  // resolve all promises
34
- Promise.all(uploads)
35
- .then(function (resData) {
36
- callback(null, resData);
37
- })
28
+ bluebird
29
+ .all(uploads)
30
+ .then(resData => callback(null, resData))
38
31
  .catch(function (err) {
39
32
  log.error("handleUpload", err);
40
33
  return callback(err);
@@ -42,39 +35,27 @@ module.exports = function (defaultFuncs, api, ctx) {
42
35
  }
43
36
 
44
37
  return function changeGroupImage(image, threadID, callback) {
45
- if (
46
- !callback &&
47
- (utils.getType(threadID) === "Function" ||
48
- utils.getType(threadID) === "AsyncFunction")
49
- ) {
50
- throw { error: "please pass a threadID as a second argument." };
51
- }
52
-
53
- if (!utils.isReadableStream(image)) {
54
- throw { error: "please pass a readable stream as a first argument." };
55
- }
38
+ if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
56
39
 
57
- let resolveFunc = function () {};
58
- let rejectFunc = function () {};
59
- const returnPromise = new Promise(function (resolve, reject) {
40
+ var resolveFunc = function () { };
41
+ var rejectFunc = function () { };
42
+ var returnPromise = new Promise(function (resolve, reject) {
60
43
  resolveFunc = resolve;
61
44
  rejectFunc = reject;
62
45
  });
63
46
 
64
47
  if (!callback) {
65
48
  callback = function (err) {
66
- if (err) {
67
- return rejectFunc(err);
68
- }
49
+ if (err) return rejectFunc(err);
69
50
  resolveFunc();
70
51
  };
71
52
  }
72
53
 
73
- const messageAndOTID = utils.generateOfflineThreadingID();
74
- const form = {
54
+ var messageAndOTID = utils.generateOfflineThreadingID();
55
+ var form = {
75
56
  client: "mercury",
76
57
  action_type: "ma-type:log-message",
77
- author: "fbid:" + (ctx.i_userID || ctx.userID),
58
+ author: "fbid:" + ctx.userID,
78
59
  author_email: "",
79
60
  ephemeral_ttl_mode: "0",
80
61
  is_filtered_content: false,
@@ -97,31 +78,21 @@ module.exports = function (defaultFuncs, api, ctx) {
97
78
  timestamp: Date.now(),
98
79
  timestamp_absolute: "Today",
99
80
  timestamp_relative: utils.generateTimestampRelative(),
100
- timestamp_time_passed: "0",
81
+ timestamp_time_passed: "0"
101
82
  };
102
83
 
103
84
  handleUpload(image, function (err, payload) {
104
- if (err) {
105
- return callback(err);
106
- }
85
+ if (err) return callback(err);
107
86
 
108
87
  form["thread_image_id"] = payload[0]["image_id"];
109
88
  form["thread_id"] = threadID;
110
89
 
111
90
  defaultFuncs
112
- .post(
113
- "https://www.facebook.com/messaging/set_thread_image/",
114
- ctx.jar,
115
- form,
116
- )
91
+ .post("https://www.facebook.com/messaging/set_thread_image/", ctx.jar, form)
117
92
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
118
93
  .then(function (resData) {
119
94
  // check for errors here
120
-
121
- if (resData.error) {
122
- throw resData;
123
- }
124
-
95
+ if (resData.error) throw resData;
125
96
  return callback();
126
97
  })
127
98
  .catch(function (err) {
@@ -1,51 +1,37 @@
1
1
  "use strict";
2
2
 
3
- const utils = require("../utils");
4
- const log = require("npmlog");
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
  })