fca-mod99 31.40.22

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fca-mod99 might be problematic. Click here for more details.

Files changed (107) hide show
  1. package/.config/configstore/update-notifier-npm.json +4 -0
  2. package/.gitattributes +2 -0
  3. package/.github/FUNDING.yml +4 -0
  4. package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
  5. package/.github/ISSUE_TEMPLATE/config.yml +8 -0
  6. package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  7. package/.github/dependabot.yml +11 -0
  8. package/.replit +77 -0
  9. package/.upm/store.json +1 -0
  10. package/DOCS.md +1738 -0
  11. package/Extra/ExtraAddons.js +78 -0
  12. package/Extra/ExtraFindUID.js +60 -0
  13. package/Extra/ExtraGetThread.js +118 -0
  14. package/Extra/ExtraScreenShot.js +673 -0
  15. package/Extra/ExtraTranslate.js +62 -0
  16. package/Extra/ExtraUptimeRobot.js +59 -0
  17. package/Extra/Html/Classic/script.js +231 -0
  18. package/Extra/Html/Classic/style.css +8 -0
  19. package/Extra/PM2/ecosystem.config.js +23 -0
  20. package/Extra/Security/Index.js +174 -0
  21. package/Extra/Security/Step_1.js +15 -0
  22. package/Extra/Security/Step_2.js +23 -0
  23. package/Extra/Security/Step_3.js +23 -0
  24. package/Extra/Src/History.js +115 -0
  25. package/Extra/Src/Last-Run.js +65 -0
  26. package/Extra/Src/Premium.js +84 -0
  27. package/Extra/Src/SecurityCheck.js +2 -0
  28. package/Func/AcceptAgreement.js +32 -0
  29. package/Func/ClearCache.js +64 -0
  30. package/Func/ReportV1.js +54 -0
  31. package/LICENSE.md +23 -0
  32. package/Language/index.json +176 -0
  33. package/OldSecurity.js +100 -0
  34. package/README.md +128 -0
  35. package/SECURITY.md +21 -0
  36. package/Settings/Database.js +21 -0
  37. package/Settings/Location.js +59 -0
  38. package/Settings/Location.json +24 -0
  39. package/Settings/Settings.js +59 -0
  40. package/StateCrypt.js +98 -0
  41. package/broadcast.js +38 -0
  42. package/index.js +1333 -0
  43. package/logger.js +65 -0
  44. package/package.json +98 -0
  45. package/replit.nix +8 -0
  46. package/src/K2IMG.js +8 -0
  47. package/src/Premium.js +30 -0
  48. package/src/Screenshot.js +77 -0
  49. package/src/T2S.js +8 -0
  50. package/src/addExternalModule.js +16 -0
  51. package/src/addUserToGroup.js +79 -0
  52. package/src/changeAdminStatus.js +79 -0
  53. package/src/changeArchivedStatus.js +41 -0
  54. package/src/changeAvt.js +85 -0
  55. package/src/changeBio.js +65 -0
  56. package/src/changeBlockedStatus.js +36 -0
  57. package/src/changeGroupImage.js +106 -0
  58. package/src/changeNickname.js +45 -0
  59. package/src/changeThreadColor.js +62 -0
  60. package/src/changeThreadEmoji.js +42 -0
  61. package/src/createNewGroup.js +70 -0
  62. package/src/createPoll.js +60 -0
  63. package/src/deleteMessage.js +45 -0
  64. package/src/deleteThread.js +43 -0
  65. package/src/forwardAttachment.js +48 -0
  66. package/src/getAccessToken.js +32 -0
  67. package/src/getCurrentUserID.js +7 -0
  68. package/src/getEmojiUrl.js +27 -0
  69. package/src/getFriendsList.js +73 -0
  70. package/src/getMessage.js +80 -0
  71. package/src/getThreadHistory.js +537 -0
  72. package/src/getThreadInfo.js +346 -0
  73. package/src/getThreadList.js +213 -0
  74. package/src/getThreadMain.js +219 -0
  75. package/src/getThreadPictures.js +59 -0
  76. package/src/getUID.js +59 -0
  77. package/src/getUserID.js +62 -0
  78. package/src/getUserInfo.js +129 -0
  79. package/src/getUserInfoMain.js +65 -0
  80. package/src/getUserInfoV2.js +35 -0
  81. package/src/getUserInfoV3.js +63 -0
  82. package/src/getUserInfoV4.js +55 -0
  83. package/src/getUserInfoV5.js +61 -0
  84. package/src/handleFriendRequest.js +46 -0
  85. package/src/handleMessageRequest.js +49 -0
  86. package/src/httpGet.js +49 -0
  87. package/src/httpPost.js +48 -0
  88. package/src/httpPostFormData.js +41 -0
  89. package/src/listenMqtt.js +725 -0
  90. package/src/logout.js +68 -0
  91. package/src/markAsDelivered.js +48 -0
  92. package/src/markAsRead.js +70 -0
  93. package/src/markAsReadAll.js +43 -0
  94. package/src/markAsSeen.js +51 -0
  95. package/src/muteThread.js +47 -0
  96. package/src/removeUserFromGroup.js +49 -0
  97. package/src/resolvePhotoUrl.js +37 -0
  98. package/src/searchForThread.js +43 -0
  99. package/src/sendMessage.js +334 -0
  100. package/src/sendTypingIndicator.js +80 -0
  101. package/src/setMessageReaction.js +109 -0
  102. package/src/setPostReaction.js +102 -0
  103. package/src/setTitle.js +74 -0
  104. package/src/threadColors.js +39 -0
  105. package/src/unfriend.js +43 -0
  106. package/src/unsendMessage.js +40 -0
  107. package/utils.js +1648 -0
@@ -0,0 +1,36 @@
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 changeBlockedStatus(userID, block, 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) {
17
+ if (err) return rejectFunc(err);
18
+ resolveFunc();
19
+ };
20
+ }
21
+
22
+ defaultFuncs
23
+ .post(`https://www.facebook.com/messaging/${block ? "" : "un"}block_messages/`, ctx.jar, { fbid: userID })
24
+ .then(utils.saveCookies(ctx.jar))
25
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
26
+ .then(function (resData) {
27
+ if (resData.error) throw resData;
28
+ return callback();
29
+ })
30
+ .catch(function (err) {
31
+ log.error("changeBlockedStatus", err);
32
+ return callback(err);
33
+ });
34
+ return returnPromise;
35
+ };
36
+ };
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+ var bluebird = require("bluebird");
6
+
7
+ module.exports = function (defaultFuncs, api, ctx) {
8
+ function handleUpload(image, callback) {
9
+ var uploads = [];
10
+
11
+ var form = {
12
+ images_only: "true",
13
+ "attachment[]": image
14
+ };
15
+
16
+ uploads.push(
17
+ defaultFuncs
18
+ .postFormData("https://upload.facebook.com/ajax/mercury/upload.php", ctx.jar, form, {})
19
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
20
+ .then(function (resData) {
21
+ if (resData.error) throw resData;
22
+
23
+ return resData.payload.metadata[0];
24
+ })
25
+ );
26
+
27
+ // resolve all promises
28
+ bluebird
29
+ .all(uploads)
30
+ .then(resData => callback(null, resData))
31
+ .catch(function (err) {
32
+ log.error("handleUpload", err);
33
+ return callback(err);
34
+ });
35
+ }
36
+
37
+ return function changeGroupImage(image, threadID, callback) {
38
+ if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
39
+
40
+ var resolveFunc = function () { };
41
+ var rejectFunc = function () { };
42
+ var returnPromise = new Promise(function (resolve, reject) {
43
+ resolveFunc = resolve;
44
+ rejectFunc = reject;
45
+ });
46
+
47
+ if (!callback) {
48
+ callback = function (err) {
49
+ if (err) return rejectFunc(err);
50
+ resolveFunc();
51
+ };
52
+ }
53
+
54
+ var messageAndOTID = utils.generateOfflineThreadingID();
55
+ var form = {
56
+ client: "mercury",
57
+ action_type: "ma-type:log-message",
58
+ author: "fbid:" + ctx.userID,
59
+ author_email: "",
60
+ ephemeral_ttl_mode: "0",
61
+ is_filtered_content: false,
62
+ is_filtered_content_account: false,
63
+ is_filtered_content_bh: false,
64
+ is_filtered_content_invalid_app: false,
65
+ is_filtered_content_quasar: false,
66
+ is_forward: false,
67
+ is_spoof_warning: false,
68
+ is_unread: false,
69
+ log_message_type: "log:thread-image",
70
+ manual_retry_cnt: "0",
71
+ message_id: messageAndOTID,
72
+ offline_threading_id: messageAndOTID,
73
+ source: "source:chat:web",
74
+ "source_tags[0]": "source:chat",
75
+ status: "0",
76
+ thread_fbid: threadID,
77
+ thread_id: "",
78
+ timestamp: Date.now(),
79
+ timestamp_absolute: "Today",
80
+ timestamp_relative: utils.generateTimestampRelative(),
81
+ timestamp_time_passed: "0"
82
+ };
83
+
84
+ handleUpload(image, function (err, payload) {
85
+ if (err) return callback(err);
86
+
87
+ form["thread_image_id"] = payload[0]["image_id"];
88
+ form["thread_id"] = threadID;
89
+
90
+ defaultFuncs
91
+ .post("https://www.facebook.com/messaging/set_thread_image/", ctx.jar, form)
92
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
93
+ .then(function (resData) {
94
+ // check for errors here
95
+ if (resData.error) throw resData;
96
+ return callback();
97
+ })
98
+ .catch(function (err) {
99
+ log.error("changeGroupImage", err);
100
+ return callback(err);
101
+ });
102
+ });
103
+
104
+ return returnPromise;
105
+ };
106
+ };
@@ -0,0 +1,45 @@
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 changeNickname(nickname, threadID, participantID, 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
+ if (!callback) {
15
+ callback = function (err) {
16
+ if (err) return rejectFunc(err);
17
+ resolveFunc();
18
+ };
19
+ }
20
+
21
+ var form = {
22
+ nickname: nickname,
23
+ participant_id: participantID,
24
+ thread_or_other_fbid: threadID
25
+ };
26
+
27
+ defaultFuncs
28
+ .post("https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1", ctx.jar, form)
29
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
30
+ .then(function (resData) {
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;
35
+
36
+ return callback();
37
+ })
38
+ .catch(function (err) {
39
+ log.error("changeNickname", err);
40
+ return callback(err);
41
+ });
42
+
43
+ return returnPromise;
44
+ };
45
+ };
@@ -0,0 +1,62 @@
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 changeThreadColor(color, threadID, 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) {
17
+ if (err) return rejectFunc(err);
18
+ resolveFunc(err);
19
+ };
20
+ }
21
+
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." };
27
+
28
+ var form = {
29
+ dpr: 1,
30
+ queries: JSON.stringify({
31
+ o0: {
32
+ //This doc_id is valid as of January 31, 2020
33
+ doc_id: "1727493033983591",
34
+ query_params: {
35
+ data: {
36
+ actor_id: ctx.userID,
37
+ client_mutation_id: "0",
38
+ source: "SETTINGS",
39
+ theme_id: validatedColor,
40
+ thread_id: threadID
41
+ }
42
+ }
43
+ }
44
+ })
45
+ };
46
+
47
+ defaultFuncs
48
+ .post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
49
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
50
+ .then(function (resData) {
51
+ if (resData[resData.length - 1].error_results > 0) throw resData[0].o0.errors;
52
+
53
+ return callback();
54
+ })
55
+ .catch(function (err) {
56
+ log.error("changeThreadColor", err);
57
+ return callback(err);
58
+ });
59
+
60
+ return returnPromise;
61
+ };
62
+ };
@@ -0,0 +1,42 @@
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 changeThreadEmoji(emoji, threadID, 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) {
17
+ if (err) return rejectFunc(err);
18
+ resolveFunc();
19
+ };
20
+ }
21
+ var form = {
22
+ emoji_choice: emoji,
23
+ thread_or_other_fbid: threadID
24
+ };
25
+
26
+ defaultFuncs
27
+ .post("https://www.facebook.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg", ctx.jar, form)
28
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
29
+ .then(function (resData) {
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;
32
+
33
+ return callback();
34
+ })
35
+ .catch(function (err) {
36
+ log.error("changeThreadEmoji", err);
37
+ return callback(err);
38
+ });
39
+
40
+ return returnPromise;
41
+ };
42
+ };
@@ -0,0 +1,70 @@
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 createNewGroup(participantIDs, groupTitle, callback) {
8
+ if (utils.getType(groupTitle) == "Function") {
9
+ callback = groupTitle;
10
+ groupTitle = null;
11
+ }
12
+
13
+ if (utils.getType(participantIDs) !== "Array") throw { error: "createNewGroup: participantIDs should be an array." };
14
+
15
+ if (participantIDs.length < 2) throw { error: "createNewGroup: participantIDs should have at least 2 IDs." };
16
+
17
+ var resolveFunc = function () { };
18
+ var rejectFunc = function () { };
19
+ var returnPromise = new Promise(function (resolve, reject) {
20
+ resolveFunc = resolve;
21
+ rejectFunc = reject;
22
+ });
23
+
24
+ if (!callback) {
25
+ callback = function (err, threadID) {
26
+ if (err) return rejectFunc(err);
27
+ resolveFunc(threadID);
28
+ };
29
+ }
30
+
31
+ var pids = [];
32
+ for (var n in participantIDs) pids.push({ fbid: participantIDs[n] });
33
+ pids.push({ fbid: ctx.userID });
34
+
35
+ var form = {
36
+ fb_api_caller_class: "RelayModern",
37
+ fb_api_req_friendly_name: "MessengerGroupCreateMutation",
38
+ av: ctx.userID,
39
+ //This doc_id is valid as of January 11th, 2020
40
+ doc_id: "577041672419534",
41
+ variables: JSON.stringify({
42
+ input: {
43
+ entry_point: "jewel_new_group",
44
+ actor_id: ctx.userID,
45
+ participants: pids,
46
+ client_mutation_id: Math.round(Math.random() * 1024).toString(),
47
+ thread_settings: {
48
+ name: groupTitle,
49
+ joinable_mode: "PRIVATE",
50
+ thread_image_fbid: null
51
+ }
52
+ }
53
+ })
54
+ };
55
+
56
+ defaultFuncs
57
+ .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
58
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
59
+ .then(function (resData) {
60
+ if (resData.errors) throw resData;
61
+ return callback(null, resData.data.messenger_group_thread_create.thread.thread_key.thread_fbid);
62
+ })
63
+ .catch(function (err) {
64
+ log.error("createNewGroup", err);
65
+ return callback(err);
66
+ });
67
+
68
+ return returnPromise;
69
+ };
70
+ };
@@ -0,0 +1,60 @@
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 createPoll(title, threadID, options, 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
+ if (utils.getType(options) == "Function") {
17
+ callback = options;
18
+ options = null;
19
+ }
20
+ else {
21
+ callback = function (err) {
22
+ if (err) return rejectFunc(err);
23
+ resolveFunc();
24
+ };
25
+ }
26
+ }
27
+ if (!options) options = {}; // Initial poll options are optional
28
+
29
+ var form = {
30
+ target_id: threadID,
31
+ question_text: title
32
+ };
33
+
34
+ // Set fields for options (and whether they are selected initially by the posting user)
35
+ var ind = 0;
36
+ for (var opt in options) {
37
+ // eslint-disable-next-line no-prototype-builtins
38
+ if (options.hasOwnProperty(opt)) {
39
+ form["option_text_array[" + ind + "]"] = opt;
40
+ form["option_is_selected_array[" + ind + "]"] = options[opt] ? "1" : "0";
41
+ ind++;
42
+ }
43
+ }
44
+
45
+ defaultFuncs
46
+ .post("https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1", ctx.jar, form)
47
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
48
+ .then(function (resData) {
49
+ if (resData.payload.status != "success") throw resData;
50
+
51
+ return callback();
52
+ })
53
+ .catch(function (err) {
54
+ log.error("createPoll", err);
55
+ return callback(err);
56
+ });
57
+
58
+ return returnPromise;
59
+ };
60
+ };
@@ -0,0 +1,45 @@
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 deleteMessage(messageOrMessages, 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
+ if (!callback) {
15
+ callback = function (err) {
16
+ if (err) return rejectFunc(err);
17
+
18
+ resolveFunc();
19
+ };
20
+ }
21
+
22
+ var form = {
23
+ client: "mercury"
24
+ };
25
+
26
+ if (utils.getType(messageOrMessages) !== "Array") messageOrMessages = [messageOrMessages];
27
+
28
+ for (var i = 0; i < messageOrMessages.length; i++) form["message_ids[" + i + "]"] = messageOrMessages[i];
29
+
30
+ defaultFuncs
31
+ .post("https://www.facebook.com/ajax/mercury/delete_messages.php", ctx.jar, form)
32
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
33
+ .then(function (resData) {
34
+ if (resData.error) throw resData;
35
+
36
+ return callback();
37
+ })
38
+ .catch(function (err) {
39
+ log.error("deleteMessage", err);
40
+ return callback(err);
41
+ });
42
+
43
+ return returnPromise;
44
+ };
45
+ };
@@ -0,0 +1,43 @@
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 deleteThread(threadOrThreads, 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
+ if (!callback) {
15
+ callback = function (err) {
16
+ if (err) return rejectFunc(err);
17
+ resolveFunc();
18
+ };
19
+ }
20
+
21
+ var form = {
22
+ client: "mercury"
23
+ };
24
+
25
+ if (utils.getType(threadOrThreads) !== "Array") threadOrThreads = [threadOrThreads];
26
+ for (var i = 0; i < threadOrThreads.length; i++) form["ids[" + i + "]"] = threadOrThreads[i];
27
+
28
+ defaultFuncs
29
+ .post("https://www.facebook.com/ajax/mercury/delete_thread.php", ctx.jar, form)
30
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
31
+ .then(function (resData) {
32
+ if (resData.error) throw resData;
33
+
34
+ return callback();
35
+ })
36
+ .catch(function (err) {
37
+ log.error("deleteThread", err);
38
+ return callback(err);
39
+ });
40
+
41
+ return returnPromise;
42
+ };
43
+ };
@@ -0,0 +1,48 @@
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 forwardAttachment(attachmentID, userOrUsers, 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
+ if (!callback) {
15
+ callback = function (err) {
16
+ if (err) return rejectFunc(err);
17
+ resolveFunc();
18
+ };
19
+ }
20
+
21
+ var form = {
22
+ attachment_id: attachmentID
23
+ };
24
+
25
+ if (utils.getType(userOrUsers) !== "Array") userOrUsers = [userOrUsers];
26
+
27
+ var timestamp = Math.floor(Date.now() / 1000);
28
+
29
+ //That's good, the key of the array is really timestmap in seconds + index
30
+ //Probably time when the attachment will be sent?
31
+ for (var i = 0; i < userOrUsers.length; i++) form["recipient_map[" + (timestamp + i) + "]"] = userOrUsers[i];
32
+
33
+ defaultFuncs
34
+ .post("https://www.facebook.com/mercury/attachments/forward/", ctx.jar, form)
35
+ .then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
36
+ .then(function (resData) {
37
+ if (resData.error) throw resData;
38
+
39
+ return callback();
40
+ })
41
+ .catch(function (err) {
42
+ log.error("forwardAttachment", err);
43
+ return callback(err);
44
+ });
45
+
46
+ return returnPromise;
47
+ };
48
+ };
@@ -0,0 +1,32 @@
1
+ /* eslint-disable linebreak-style */
2
+ "use strict";
3
+
4
+ var utils = require("../utils");
5
+ var log = require("npmlog");
6
+
7
+
8
+ module.exports = function (defaultFuncs, api, ctx) {
9
+ return function getAccessToken(callback) {
10
+ var resolveFunc = function () { };
11
+ var rejectFunc = function () { };
12
+ var returnPromise = new Promise(function (resolve, reject) {
13
+ resolveFunc = resolve;
14
+ rejectFunc = reject;
15
+ });
16
+
17
+ if (!callback) {
18
+ callback = function (err, userInfo) {
19
+ if (err) return rejectFunc(err);
20
+ resolveFunc(userInfo);
21
+ };
22
+ }
23
+ try {
24
+ var { getAccessToken } = require('../Extra/ExtraAddons');
25
+ getAccessToken(ctx.jar,ctx,defaultFuncs).then(data => callback(null,data));
26
+ }
27
+ catch (e) {
28
+ callback(null, e);
29
+ }
30
+ return returnPromise;
31
+ };
32
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ module.exports = function (defaultFuncs, api, ctx) {
4
+ return function getCurrentUserID() {
5
+ return ctx.userID;
6
+ };
7
+ };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ const util = require("util");
4
+
5
+ module.exports = function () {
6
+ return function getEmojiUrl(c, size, pixelRatio) {
7
+ /*
8
+ Resolves Facebook Messenger emoji image asset URL for an emoji character.
9
+ Supported sizes are 32, 64, and 128.
10
+ Supported pixel ratios are '1.0' and '1.5' (possibly more; haven't tested)
11
+ */
12
+ const baseUrl = "https://static.xx.fbcdn.net/images/emoji.php/v8/z%s/%s";
13
+ pixelRatio = pixelRatio || "1.0";
14
+
15
+ let ending = util.format(
16
+ "%s/%s/%s.png",
17
+ pixelRatio,
18
+ size,
19
+ c.codePointAt(0).toString(16)
20
+ );
21
+ let base = 317426846;
22
+ for (let i = 0; i < ending.length; i++) base = (base << 5) - base + ending.charCodeAt(i);
23
+
24
+ let hashed = (base & 255).toString(16);
25
+ return util.format(baseUrl, hashed, ending);
26
+ };
27
+ };