fca-zoebakaaa 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. package/.eslintrc.js +35 -0
  2. package/CHANGELOG.md +2 -0
  3. package/Controllers/Remote.js +4 -0
  4. package/DOCS.md +1738 -0
  5. package/Extra/ExtraAddons.js +80 -0
  6. package/Extra/ExtraFindUID.js +62 -0
  7. package/Extra/ExtraGetThread.js +118 -0
  8. package/Extra/ExtraTranslate.js +62 -0
  9. package/Extra/ExtraUptimeRobot.js +62 -0
  10. package/Extra/Html/Classic/script.js +233 -0
  11. package/Extra/Html/Classic/style.css +8 -0
  12. package/Extra/PM2/ecosystem.config.js +23 -0
  13. package/Extra/Security/Index.js +174 -0
  14. package/Extra/Security/Step_1.js +15 -0
  15. package/Extra/Security/Step_2.js +23 -0
  16. package/Extra/Security/Step_3.js +23 -0
  17. package/Extra/Src/History.js +117 -0
  18. package/Extra/Src/Last-Run.js +65 -0
  19. package/Extra/Src/Premium.js +88 -0
  20. package/Extra/Src/SecurityCheck.js +7 -0
  21. package/Extra/database/SyntheticDatabase.sqlite +0 -0
  22. package/Extra/database/index.js +360 -0
  23. package/Extra/logger.js +74 -0
  24. package/Func/AcceptAgreement.js +36 -0
  25. package/Func/ClearCache.js +68 -0
  26. package/Func/ReportV1.js +55 -0
  27. package/README.md +112 -0
  28. package/Settings/Database.js +21 -0
  29. package/Settings/Location.js +59 -0
  30. package/broadcast.js +40 -0
  31. package/index.js +1353 -0
  32. package/logger.js +75 -0
  33. package/package.json +56 -0
  34. package/src/Premium.js +39 -0
  35. package/src/addExternalModule.js +23 -0
  36. package/src/addUserToGroup.js +101 -0
  37. package/src/appstate.json +0 -0
  38. package/src/changeAdminStatus.js +95 -0
  39. package/src/changeArchivedStatus.js +47 -0
  40. package/src/changeAvt.js +95 -0
  41. package/src/changeBio.js +66 -0
  42. package/src/changeBlockedStatus.js +42 -0
  43. package/src/changeGroupImage.js +124 -0
  44. package/src/changeNickname.js +54 -0
  45. package/src/changeThreadColor.js +67 -0
  46. package/src/changeThreadEmoji.js +50 -0
  47. package/src/createNewGroup.js +78 -0
  48. package/src/createPoll.js +66 -0
  49. package/src/deleteMessage.js +51 -0
  50. package/src/deleteThread.js +49 -0
  51. package/src/forwardAttachment.js +53 -0
  52. package/src/getAccessToken.js +36 -0
  53. package/src/getCurrentUserID.js +8 -0
  54. package/src/getEmojiUrl.js +29 -0
  55. package/src/getFriendsList.js +81 -0
  56. package/src/getMessage.js +85 -0
  57. package/src/getThreadHistory.js +633 -0
  58. package/src/getThreadInfo.js +248 -0
  59. package/src/getThreadList.js +276 -0
  60. package/src/getThreadPictures.js +71 -0
  61. package/src/getUID.js +61 -0
  62. package/src/getUserID.js +62 -0
  63. package/src/getUserInfo.js +68 -0
  64. package/src/getUserInfoV2.js +32 -0
  65. package/src/getUserInfoV3.js +72 -0
  66. package/src/getUserInfoV4.js +57 -0
  67. package/src/getUserInfoV5.js +68 -0
  68. package/src/handleFriendRequest.js +47 -0
  69. package/src/handleMessageRequest.js +63 -0
  70. package/src/httpGet.js +54 -0
  71. package/src/httpPost.js +53 -0
  72. package/src/httpPostFormData.js +46 -0
  73. package/src/listenMqtt.js +1056 -0
  74. package/src/logout.js +73 -0
  75. package/src/markAsDelivered.js +54 -0
  76. package/src/markAsRead.js +82 -0
  77. package/src/markAsReadAll.js +47 -0
  78. package/src/markAsSeen.js +58 -0
  79. package/src/muteThread.js +51 -0
  80. package/src/removeUserFromGroup.js +72 -0
  81. package/src/resolvePhotoUrl.js +39 -0
  82. package/src/searchForThread.js +48 -0
  83. package/src/sendMessage.js +429 -0
  84. package/src/sendTypingIndicator.js +83 -0
  85. package/src/setMessageReaction.js +114 -0
  86. package/src/setPostReaction.js +103 -0
  87. package/src/setTitle.js +86 -0
  88. package/src/threadColors.js +40 -0
  89. package/src/toolspincoinmaster +89 -0
  90. package/src/unfriend.js +48 -0
  91. package/src/unsendMessage.js +40 -0
  92. package/utils.js +2244 -0
  93. package/zoebaka.code-workspace +8 -0
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+
3
+ import {
4
+ parseAndCheckLogin,
5
+ getType,
6
+ generateOfflineThreadingID,
7
+ generateTimestampRelative,
8
+ } from "../utils";
9
+ import { error as _error } from "npmlog";
10
+ import { all } from "bluebird";
11
+
12
+ export default function (defaultFuncs, api, ctx) {
13
+ function handleUpload(image, callback) {
14
+ var uploads = [];
15
+
16
+ var form = {
17
+ images_only: "true",
18
+ "attachment[]": image,
19
+ };
20
+
21
+ uploads.push(
22
+ defaultFuncs
23
+ .postFormData(
24
+ "https://upload.facebook.com/ajax/mercury/upload.php",
25
+ ctx.jar,
26
+ form,
27
+ {},
28
+ )
29
+ .then(parseAndCheckLogin(ctx, defaultFuncs))
30
+ .then(function (resData) {
31
+ if (resData.error) throw resData;
32
+
33
+ return resData.payload.metadata[0];
34
+ }),
35
+ );
36
+
37
+ // resolve all promises
38
+ all(uploads)
39
+ .then((resData) => callback(null, resData))
40
+ .catch(function (err) {
41
+ _error("handleUpload", err);
42
+ return callback(err);
43
+ });
44
+ }
45
+
46
+ return function changeGroupImage(image, threadID, callback) {
47
+ if (
48
+ !callback &&
49
+ (getType(threadID) === "Function" ||
50
+ getType(threadID) === "AsyncFunction")
51
+ )
52
+ throw { error: "please pass a threadID as a second argument." };
53
+
54
+ var resolveFunc = function () {};
55
+ var rejectFunc = function () {};
56
+ var returnPromise = new Promise(function (resolve, reject) {
57
+ resolveFunc = resolve;
58
+ rejectFunc = reject;
59
+ });
60
+
61
+ if (!callback) {
62
+ callback = function (err) {
63
+ if (err) return rejectFunc(err);
64
+ resolveFunc();
65
+ };
66
+ }
67
+
68
+ var messageAndOTID = generateOfflineThreadingID();
69
+ var form = {
70
+ client: "mercury",
71
+ action_type: "ma-type:log-message",
72
+ author: "fbid:" + ctx.userID,
73
+ author_email: "",
74
+ ephemeral_ttl_mode: "0",
75
+ is_filtered_content: false,
76
+ is_filtered_content_account: false,
77
+ is_filtered_content_bh: false,
78
+ is_filtered_content_invalid_app: false,
79
+ is_filtered_content_quasar: false,
80
+ is_forward: false,
81
+ is_spoof_warning: false,
82
+ is_unread: false,
83
+ log_message_type: "log:thread-image",
84
+ manual_retry_cnt: "0",
85
+ message_id: messageAndOTID,
86
+ offline_threading_id: messageAndOTID,
87
+ source: "source:chat:web",
88
+ "source_tags[0]": "source:chat",
89
+ status: "0",
90
+ thread_fbid: threadID,
91
+ thread_id: "",
92
+ timestamp: Date.now(),
93
+ timestamp_absolute: "Today",
94
+ timestamp_relative: generateTimestampRelative(),
95
+ timestamp_time_passed: "0",
96
+ };
97
+
98
+ handleUpload(image, function (err, payload) {
99
+ if (err) return callback(err);
100
+
101
+ form["thread_image_id"] = payload[0]["image_id"];
102
+ form["thread_id"] = threadID;
103
+
104
+ defaultFuncs
105
+ .post(
106
+ "https://www.facebook.com/messaging/set_thread_image/",
107
+ ctx.jar,
108
+ form,
109
+ )
110
+ .then(parseAndCheckLogin(ctx, defaultFuncs))
111
+ .then(function (resData) {
112
+ // check for errors here
113
+ if (resData.error) throw resData;
114
+ return callback();
115
+ })
116
+ .catch(function (err) {
117
+ _error("changeGroupImage", err);
118
+ return callback(err);
119
+ });
120
+ });
121
+
122
+ return returnPromise;
123
+ };
124
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ import { parseAndCheckLogin } from "../utils";
4
+ import { error as _error } from "npmlog";
5
+
6
+ export default 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(
29
+ "https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1",
30
+ ctx.jar,
31
+ form,
32
+ )
33
+ .then(parseAndCheckLogin(ctx, defaultFuncs))
34
+ .then(function (resData) {
35
+ if (resData.error === 1545014)
36
+ throw { error: "Trying to change nickname of user isn't in thread" };
37
+ if (resData.error === 1357031)
38
+ throw {
39
+ error:
40
+ "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.",
41
+ };
42
+
43
+ if (resData.error) throw resData;
44
+
45
+ return callback();
46
+ })
47
+ .catch(function (err) {
48
+ _error("changeNickname", err);
49
+ return callback(err);
50
+ });
51
+
52
+ return returnPromise;
53
+ };
54
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ import { parseAndCheckLogin } from "../utils";
4
+ import { error as _error } from "npmlog";
5
+
6
+ export default 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))
27
+ throw {
28
+ error:
29
+ "The color you are trying to use is not a valid thread color. Use api.threadColors to find acceptable values.",
30
+ };
31
+
32
+ var form = {
33
+ dpr: 1,
34
+ queries: JSON.stringify({
35
+ o0: {
36
+ //This doc_id is valid as of January 31, 2020
37
+ doc_id: "1727493033983591",
38
+ query_params: {
39
+ data: {
40
+ actor_id: ctx.userID,
41
+ client_mutation_id: "0",
42
+ source: "SETTINGS",
43
+ theme_id: validatedColor,
44
+ thread_id: threadID,
45
+ },
46
+ },
47
+ },
48
+ }),
49
+ };
50
+
51
+ defaultFuncs
52
+ .post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
53
+ .then(parseAndCheckLogin(ctx, defaultFuncs))
54
+ .then(function (resData) {
55
+ if (resData[resData.length - 1].error_results > 0)
56
+ throw resData[0].o0.errors;
57
+
58
+ return callback();
59
+ })
60
+ .catch(function (err) {
61
+ _error("changeThreadColor", err);
62
+ return callback(err);
63
+ });
64
+
65
+ return returnPromise;
66
+ };
67
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ import { parseAndCheckLogin } from "../utils";
4
+ import { error as _error } from "npmlog";
5
+
6
+ export default 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(
28
+ "https://www.facebook.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg",
29
+ ctx.jar,
30
+ form,
31
+ )
32
+ .then(parseAndCheckLogin(ctx, defaultFuncs))
33
+ .then(function (resData) {
34
+ if (resData.error === 1357031)
35
+ throw {
36
+ error:
37
+ "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.",
38
+ };
39
+ if (resData.error) throw resData;
40
+
41
+ return callback();
42
+ })
43
+ .catch(function (err) {
44
+ _error("changeThreadEmoji", err);
45
+ return callback(err);
46
+ });
47
+
48
+ return returnPromise;
49
+ };
50
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ import { getType, parseAndCheckLogin } from "../utils";
4
+ import { error as _error } from "npmlog";
5
+
6
+ export default function (defaultFuncs, api, ctx) {
7
+ return function createNewGroup(participantIDs, groupTitle, callback) {
8
+ if (getType(groupTitle) == "Function") {
9
+ callback = groupTitle;
10
+ groupTitle = null;
11
+ }
12
+
13
+ if (getType(participantIDs) !== "Array")
14
+ throw { error: "createNewGroup: participantIDs should be an array." };
15
+
16
+ if (participantIDs.length < 2)
17
+ throw {
18
+ error: "createNewGroup: participantIDs should have at least 2 IDs.",
19
+ };
20
+
21
+ var resolveFunc = function () {};
22
+ var rejectFunc = function () {};
23
+ var returnPromise = new Promise(function (resolve, reject) {
24
+ resolveFunc = resolve;
25
+ rejectFunc = reject;
26
+ });
27
+
28
+ if (!callback) {
29
+ callback = function (err, threadID) {
30
+ if (err) return rejectFunc(err);
31
+ resolveFunc(threadID);
32
+ };
33
+ }
34
+
35
+ var pids = [];
36
+ for (var n in participantIDs) pids.push({ fbid: participantIDs[n] });
37
+ pids.push({ fbid: ctx.userID });
38
+
39
+ var form = {
40
+ fb_api_caller_class: "RelayModern",
41
+ fb_api_req_friendly_name: "MessengerGroupCreateMutation",
42
+ av: ctx.userID,
43
+ //This doc_id is valid as of January 11th, 2020
44
+ doc_id: "577041672419534",
45
+ variables: JSON.stringify({
46
+ input: {
47
+ entry_point: "jewel_new_group",
48
+ actor_id: ctx.userID,
49
+ participants: pids,
50
+ client_mutation_id: Math.round(Math.random() * 1024).toString(),
51
+ thread_settings: {
52
+ name: groupTitle,
53
+ joinable_mode: "PRIVATE",
54
+ thread_image_fbid: null,
55
+ },
56
+ },
57
+ }),
58
+ };
59
+
60
+ defaultFuncs
61
+ .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
62
+ .then(parseAndCheckLogin(ctx, defaultFuncs))
63
+ .then(function (resData) {
64
+ if (resData.errors) throw resData;
65
+ return callback(
66
+ null,
67
+ resData.data.messenger_group_thread_create.thread.thread_key
68
+ .thread_fbid,
69
+ );
70
+ })
71
+ .catch(function (err) {
72
+ _error("createNewGroup", err);
73
+ return callback(err);
74
+ });
75
+
76
+ return returnPromise;
77
+ };
78
+ }
@@ -0,0 +1,66 @@
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ "use strict";
3
+
4
+ import { getType, parseAndCheckLogin } from "../utils";
5
+ import { error } from "npmlog";
6
+
7
+ export default function (defaultFuncs, api, ctx) {
8
+ return function createPoll(title, threadID, options, callback) {
9
+ var resolveFunc = function () {};
10
+ var rejectFunc = function () {};
11
+ var returnPromise = new Promise(function (resolve, reject) {
12
+ resolveFunc = resolve;
13
+ rejectFunc = reject;
14
+ });
15
+
16
+ if (!callback) {
17
+ if (getType(options) == "Function") {
18
+ callback = options;
19
+ options = null;
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]
41
+ ? "1"
42
+ : "0";
43
+ ind++;
44
+ }
45
+ }
46
+
47
+ defaultFuncs
48
+ .post(
49
+ "https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1",
50
+ ctx.jar,
51
+ form,
52
+ )
53
+ .then(parseAndCheckLogin(ctx, defaultFuncs))
54
+ .then(function (resData) {
55
+ if (resData.payload.status != "success") throw resData;
56
+
57
+ return callback();
58
+ })
59
+ .catch(function (err) {
60
+ error("createPoll", err);
61
+ return callback(err);
62
+ });
63
+
64
+ return returnPromise;
65
+ };
66
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ import { getType, parseAndCheckLogin } from "../utils";
4
+ import { error } from "npmlog";
5
+
6
+ export default 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 (getType(messageOrMessages) !== "Array")
27
+ messageOrMessages = [messageOrMessages];
28
+
29
+ for (var i = 0; i < messageOrMessages.length; i++)
30
+ form["message_ids[" + i + "]"] = messageOrMessages[i];
31
+
32
+ defaultFuncs
33
+ .post(
34
+ "https://www.facebook.com/ajax/mercury/delete_messages.php",
35
+ ctx.jar,
36
+ form,
37
+ )
38
+ .then(parseAndCheckLogin(ctx, defaultFuncs))
39
+ .then(function (resData) {
40
+ if (resData.error) throw resData;
41
+
42
+ return callback();
43
+ })
44
+ .catch(function (err) {
45
+ error("deleteMessage", err);
46
+ return callback(err);
47
+ });
48
+
49
+ return returnPromise;
50
+ };
51
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ import { getType, parseAndCheckLogin } from "../utils";
4
+ import { error } from "npmlog";
5
+
6
+ export default 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 (getType(threadOrThreads) !== "Array")
26
+ threadOrThreads = [threadOrThreads];
27
+ for (var i = 0; i < threadOrThreads.length; i++)
28
+ form["ids[" + i + "]"] = threadOrThreads[i];
29
+
30
+ defaultFuncs
31
+ .post(
32
+ "https://www.facebook.com/ajax/mercury/delete_thread.php",
33
+ ctx.jar,
34
+ form,
35
+ )
36
+ .then(parseAndCheckLogin(ctx, defaultFuncs))
37
+ .then(function (resData) {
38
+ if (resData.error) throw resData;
39
+
40
+ return callback();
41
+ })
42
+ .catch(function (err) {
43
+ error("deleteThread", err);
44
+ return callback(err);
45
+ });
46
+
47
+ return returnPromise;
48
+ };
49
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ import { getType, parseAndCheckLogin } from "../utils";
4
+ import { error } from "npmlog";
5
+
6
+ export default 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 (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++)
32
+ form["recipient_map[" + (timestamp + i) + "]"] = userOrUsers[i];
33
+
34
+ defaultFuncs
35
+ .post(
36
+ "https://www.facebook.com/mercury/attachments/forward/",
37
+ ctx.jar,
38
+ form,
39
+ )
40
+ .then(parseAndCheckLogin(ctx.jar, defaultFuncs))
41
+ .then(function (resData) {
42
+ if (resData.error) throw resData;
43
+
44
+ return callback();
45
+ })
46
+ .catch(function (err) {
47
+ error("forwardAttachment", err);
48
+ return callback(err);
49
+ });
50
+
51
+ return returnPromise;
52
+ };
53
+ }
@@ -0,0 +1,36 @@
1
+ /* eslint-disable no-undef */
2
+ /* eslint-disable @typescript-eslint/no-var-requires */
3
+ /* eslint-disable linebreak-style */
4
+ "use strict";
5
+
6
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
7
+ import utils from "../utils";
8
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
9
+ import log from "npmlog";
10
+
11
+ export default function (defaultFuncs, api, ctx) {
12
+ return function getAccessToken(callback) {
13
+ var resolveFunc = function () {};
14
+ var rejectFunc = function () {};
15
+ var returnPromise = new Promise(function (resolve, reject) {
16
+ resolveFunc = resolve;
17
+ rejectFunc = reject;
18
+ });
19
+
20
+ if (!callback) {
21
+ callback = function (err, userInfo) {
22
+ if (err) return rejectFunc(err);
23
+ resolveFunc(userInfo);
24
+ };
25
+ }
26
+ try {
27
+ var { getAccessToken } = require("../Extra/ExtraAddons");
28
+ getAccessToken(ctx.jar, ctx, defaultFuncs).then((data) =>
29
+ callback(null, data),
30
+ );
31
+ } catch (e) {
32
+ callback(null, e);
33
+ }
34
+ return returnPromise;
35
+ };
36
+ }
@@ -0,0 +1,8 @@
1
+ /* eslint-disable no-undef */
2
+ "use strict";
3
+
4
+ module.exports = function (defaultFuncs, api, ctx) {
5
+ return function getCurrentUserID() {
6
+ return ctx.userID;
7
+ };
8
+ };
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
4
+ import { format } from "util";
5
+
6
+ export default function () {
7
+ return function getEmojiUrl(c, size, pixelRatio) {
8
+ /*
9
+ Resolves Facebook Messenger emoji image asset URL for an emoji character.
10
+ Supported sizes are 32, 64, and 128.
11
+ Supported pixel ratios are '1.0' and '1.5' (possibly more; haven't tested)
12
+ */
13
+ const baseUrl = "https://static.xx.fbcdn.net/images/emoji.php/v8/z%s/%s";
14
+ pixelRatio = pixelRatio || "1.0";
15
+
16
+ let ending = format(
17
+ "%s/%s/%s.png",
18
+ pixelRatio,
19
+ size,
20
+ c.codePointAt(0).toString(16),
21
+ );
22
+ let base = 317426846;
23
+ for (let i = 0; i < ending.length; i++)
24
+ base = (base << 5) - base + ending.charCodeAt(i);
25
+
26
+ let hashed = (base & 255).toString(16);
27
+ return format(baseUrl, hashed, ending);
28
+ };
29
+ }