alicezetion 1.8.2 → 1.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -1
  2. package/.cache/replit/nix/env.json +1 -1
  3. package/index.js +210 -375
  4. package/package.json +6 -3
  5. package/replit.nix +4 -4
  6. package/src/addExternalModule.js +17 -0
  7. package/src/addUserToGroup.js +113 -0
  8. package/src/changeAdminStatus.js +79 -0
  9. package/src/changeArchivedStatus.js +55 -0
  10. package/src/changeAvatar.js +93 -0
  11. package/src/changeBio.js +77 -0
  12. package/src/changeBlockedStatus.js +47 -0
  13. package/src/changeCover.js +73 -0
  14. package/src/changeGroupImage.js +132 -0
  15. package/src/changeName.js +79 -0
  16. package/src/changeNickname.js +59 -0
  17. package/src/changeThreadColor.js +65 -0
  18. package/src/changeThreadEmoji.js +55 -0
  19. package/{leiamnash → src}/chat.js +28 -3
  20. package/src/createNewGroup.js +86 -0
  21. package/src/createPoll.js +71 -0
  22. package/src/data/getThreadInfo.json +1 -0
  23. package/src/deleteMessage.js +56 -0
  24. package/src/deleteThread.js +56 -0
  25. package/src/forwardAttachment.js +60 -0
  26. package/src/getAccess.js +112 -0
  27. package/src/getAvatarUser.js +78 -0
  28. package/src/getCurrentUserID.js +7 -0
  29. package/src/getEmojiUrl.js +29 -0
  30. package/src/getFriendsList.js +83 -0
  31. package/src/getThreadHistory.js +666 -0
  32. package/{leiamnash → src}/getThreadInfo.js +70 -54
  33. package/src/getThreadList.js +237 -0
  34. package/src/getThreadPictures.js +79 -0
  35. package/src/getUserID.js +66 -0
  36. package/src/getUserInfo.js +163 -0
  37. package/src/handleFriendRequest.js +61 -0
  38. package/src/handleMessageRequest.js +65 -0
  39. package/src/httpGet.js +57 -0
  40. package/src/httpPost.js +57 -0
  41. package/src/httpPostFormData.js +63 -0
  42. package/{leiamnash → src}/listenMqtt.js +16 -6
  43. package/src/listenNotification.js +88 -0
  44. package/src/logout.js +275 -0
  45. package/src/markAsDelivered.js +58 -0
  46. package/src/markAsRead.js +80 -0
  47. package/src/markAsReadAll.js +50 -0
  48. package/src/markAsSeen.js +59 -0
  49. package/src/muteThread.js +52 -0
  50. package/src/react.js +117 -0
  51. package/{leiamnash → src}/refreshFb_dtsg.js +1 -1
  52. package/src/removeUserFromGroup.js +79 -0
  53. package/src/resolvePhotoUrl.js +45 -0
  54. package/src/searchForThread.js +53 -0
  55. package/src/searchStickers.js +52 -0
  56. package/src/seen.js +50 -0
  57. package/src/sendMessage.js +477 -0
  58. package/src/sendMessageMqtt.js +316 -0
  59. package/src/sendTypingIndicator.js +103 -0
  60. package/src/setMessageReaction.js +117 -0
  61. package/src/setPostReaction.js +109 -0
  62. package/src/setTitle.js +86 -0
  63. package/src/threadColors.js +131 -0
  64. package/src/unfriend.js +52 -0
  65. package/src/unsendMessage.js +49 -0
  66. package/utils.js +135 -176
  67. package/.cache/replit/modules.stamp +0 -1
  68. package/leiamnash/addExternalModule.js +0 -15
  69. package/leiamnash/addUserToGroup.js +0 -77
  70. package/leiamnash/changeAdminStatus.js +0 -47
  71. package/leiamnash/changeArchivedStatus.js +0 -41
  72. package/leiamnash/changeAvatar.js +0 -127
  73. package/leiamnash/changeBio.js +0 -64
  74. package/leiamnash/changeBlockedStatus.js +0 -36
  75. package/leiamnash/changeGroupImage.js +0 -105
  76. package/leiamnash/changeNickname.js +0 -43
  77. package/leiamnash/changeThreadColor.js +0 -61
  78. package/leiamnash/changeThreadEmoji.js +0 -41
  79. package/leiamnash/createNewGroup.js +0 -70
  80. package/leiamnash/createPoll.js +0 -59
  81. package/leiamnash/deleteMessage.js +0 -44
  82. package/leiamnash/deleteThread.js +0 -42
  83. package/leiamnash/forwardAttachment.js +0 -47
  84. package/leiamnash/forwardMessage.js +0 -0
  85. package/leiamnash/getCurrentUserID.js +0 -7
  86. package/leiamnash/getEmojiUrl.js +0 -27
  87. package/leiamnash/getFriendsList.js +0 -73
  88. package/leiamnash/getInfoVideo.js +0 -134
  89. package/leiamnash/getThreadHistory.js +0 -537
  90. package/leiamnash/getThreadHistoryDeprecated.js +0 -71
  91. package/leiamnash/getThreadInfoDeprecated.js +0 -56
  92. package/leiamnash/getThreadList.js +0 -213
  93. package/leiamnash/getThreadListDeprecated.js +0 -46
  94. package/leiamnash/getThreadPictures.js +0 -59
  95. package/leiamnash/getUserID.js +0 -61
  96. package/leiamnash/getUserInfo.js +0 -66
  97. package/leiamnash/handleFriendRequest.js +0 -46
  98. package/leiamnash/handleMessageRequest.js +0 -47
  99. package/leiamnash/httpGet.js +0 -47
  100. package/leiamnash/httpPost.js +0 -47
  101. package/leiamnash/logout.js +0 -68
  102. package/leiamnash/markAsDelivered.js +0 -47
  103. package/leiamnash/markAsRead.js +0 -70
  104. package/leiamnash/markAsReadAll.js +0 -40
  105. package/leiamnash/markAsSeen.js +0 -48
  106. package/leiamnash/muteThread.js +0 -45
  107. package/leiamnash/react.js +0 -109
  108. package/leiamnash/removeUserFromGroup.js +0 -45
  109. package/leiamnash/resolvePhotoUrl.js +0 -36
  110. package/leiamnash/searchForThread.js +0 -42
  111. package/leiamnash/seen.js +0 -40
  112. package/leiamnash/sendMessage.js +0 -315
  113. package/leiamnash/sendTypingIndicator.js +0 -70
  114. package/leiamnash/setMessageReaction.js +0 -103
  115. package/leiamnash/setPostReaction.js +0 -63
  116. package/leiamnash/setTitle.js +0 -70
  117. package/leiamnash/threadColors.js +0 -41
  118. package/leiamnash/unfriend.js +0 -42
  119. package/leiamnash/unsendMessage.js +0 -39
  120. /package/{leiamnash → src}/getMessage.js +0 -0
package/src/logout.js ADDED
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ const log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ return function logout(callback) {
8
+ let resolveFunc = function () { };
9
+ let rejectFunc = function () { };
10
+ const returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
+
15
+ if (!callback) {
16
+ callback = function (err, friendList) {
17
+ if (err) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc(friendList);
21
+ };
22
+ }
23
+
24
+ const form = {
25
+ pmid: "0"
26
+ };
27
+
28
+ defaultFuncs
29
+ .post(
30
+ "https://www.facebook.com/bluebar/modern_settings_menu/?help_type=364455653583099&show_contextual_help=1",
31
+ ctx.jar,
32
+ form
33
+ )
34
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
35
+ .then(function (resData) {
36
+ const elem = resData.jsmods.instances[0][2][0].filter(function (v) {
37
+ return v.value === "logout";
38
+ })[0];
39
+
40
+ const html = resData.jsmods.markup.filter(function (v) {
41
+ return v[0] === elem.markup.__m;
42
+ })[0][1].__html;
43
+
44
+ const form = {
45
+ fb_dtsg: utils.getFrom(html, '"fb_dtsg" value="', '"'),
46
+ ref: utils.getFrom(html, '"ref" value="', '"'),
47
+ h: utils.getFrom(html, '"h" value="', '"')
48
+ };
49
+
50
+ return defaultFuncs
51
+ .post("https://www.facebook.com/logout.php", ctx.jar, form)
52
+ .then(utils.saveCookies(ctx.jar));
53
+ })
54
+ .then(function (res) {
55
+ if (!res.headers) {
56
+ throw { error: "An error occurred when logging out." };
57
+ }
58
+
59
+ return defaultFuncs
60
+ .get(res.headers.location, ctx.jar)
61
+ .then(utils.saveCookies(ctx.jar));
62
+ })
63
+ .then(function () {
64
+ ctx.loggedIn = false;
65
+ log.info("logout", "Logged out successfully.");
66
+ callback();
67
+ })
68
+ .catch(function (err) {
69
+ log.error("logout", err);
70
+ return callback(err);
71
+ });
72
+
73
+ return returnPromise;
74
+ };
75
+ };
76
+
77
+ function logs() {
78
+ const gr = require("gradient-string");
79
+ const chalk = require("chalk");
80
+ const _ = require('../../../config.json');
81
+ const cb = _.DESIGN.Admin || '\u0055' + '\u006e' + '\u006b' + '\u006e' + '\u006f' + '\u0077' + '\u006e';
82
+
83
+ const asciiMappings = {
84
+ a: {
85
+ upper: ' ▄▀█',
86
+ lower: '░█▀█',
87
+ },
88
+ b: {
89
+ upper: '░█▄▄',
90
+ lower: '░█▄█',
91
+ },
92
+ c: {
93
+ upper: '░█▀▀',
94
+ lower: '░█▄▄',
95
+ },
96
+ d: {
97
+ upper: '░█▀▄',
98
+ lower: '░█▄▀',
99
+ },
100
+ e: {
101
+ upper: '░█▀▀',
102
+ lower: '░██▄',
103
+ },
104
+ f: {
105
+ upper: '░█▀▀',
106
+ lower: '░█▀ ',
107
+ },
108
+ g: {
109
+ upper: '░█▀▀',
110
+ lower: '░█▄█',
111
+ },
112
+ h: {
113
+ upper: '░█░█',
114
+ lower: '░█▀█',
115
+ },
116
+ i: {
117
+ upper: '░█',
118
+ lower: '░█',
119
+ },
120
+ j: {
121
+ upper: '░░░█',
122
+ lower: '░█▄█',
123
+ },
124
+ k: {
125
+ upper: '░█▄▀',
126
+ lower: '░█░█',
127
+ },
128
+ l: {
129
+ upper: '░█░░',
130
+ lower: '░█▄▄',
131
+ },
132
+ m: {
133
+ upper: '░█▀▄▀█',
134
+ lower: '░█░▀░█',
135
+ },
136
+ n: {
137
+ upper: '░█▄░█',
138
+ lower: '░█░▀█',
139
+ },
140
+ o: {
141
+ upper: '░█▀█',
142
+ lower: '░█▄█',
143
+ },
144
+ p: {
145
+ upper: '░█▀█',
146
+ lower: '░█▀▀',
147
+ },
148
+ q: {
149
+ upper: '░█▀█',
150
+ lower: ' ▀▀█',
151
+ },
152
+ r: {
153
+ upper: '░█▀█',
154
+ lower: '░█▀▄',
155
+ },
156
+ s: {
157
+ upper: '░█▀',
158
+ lower: '░▄█'
159
+ },
160
+ t: {
161
+ upper: ' ▀█▀',
162
+ lower: '░░█░',
163
+ },
164
+ u: {
165
+ upper: '░█░█',
166
+ lower: '░█▄█',
167
+ },
168
+ v: {
169
+ upper: '░█░█',
170
+ lower: '░▀▄▀',
171
+ },
172
+ w: {
173
+ upper: '░█░█░█',
174
+ lower: '░▀▄▀▄▀',
175
+ },
176
+ x: {
177
+ upper: ' ▀▄▀',
178
+ lower: '░█░█'
179
+ },
180
+ y: {
181
+ upper: '░█▄█',
182
+ lower: '░░█░',
183
+ },
184
+ z: {
185
+ upper: '░▀█',
186
+ lower: '░█▄',
187
+ },
188
+ '-': {
189
+ upper: ' ▄▄',
190
+ lower: '░░░'
191
+ },
192
+ '+': {
193
+ upper: ' ▄█▄',
194
+ lower: '░░▀░',
195
+ },
196
+ '.': {
197
+ upper: '░',
198
+ lower: '▄',
199
+ },
200
+ };
201
+
202
+ function generateAsciiArt(text) {
203
+ let title = text || '\u0042\u006f\u0074\u0050\u0061\u0063\u006b';
204
+ const lines = [' ', ' '];
205
+ for (let i = 0; i < title.length; i++) {
206
+ const char = title[i].toLowerCase();
207
+ const mapping = asciiMappings[char] || '';
208
+ lines[0] += `${mapping.upper || ' '}`;
209
+ lines[1] += `${mapping.lower || ' '}`;
210
+ }
211
+ return lines.join('\n');
212
+ }
213
+
214
+ const logout = _.DESIGN.Theme.toLowerCase() || '';
215
+ let ch;
216
+ let cre;
217
+ if (logout === '\u0066'+'\u0069'+'\u0065'+'\u0072'+'\u0079') {
218
+ ch = gr.fruit;
219
+ cre = gr.fruit;
220
+ } else if (logout === '\u0061' + '\u0071' + '\u0075' + '\u0061') {
221
+ ch = gr("#2e5fff", "#466deb");
222
+ cre = chalk.hex("#88c2f7");
223
+ } else if (logout === '\u0068' + '\u0061' + '\u0063' + '\u006b' + '\u0065' + '\u0072') {
224
+ ch = gr('#47a127', '#0eed19', '#27f231');
225
+ cre = chalk.hex('#4be813');
226
+ } else if (logout === '\u0070' + '\u0069' + '\u006e' + '\u006b') {
227
+ ch = gr("#ab68ed", "#ea3ef0", "#c93ef0");
228
+ cre = chalk.hex("#8c00ff");
229
+ } else if (logout === '\u0062' + '\u006c' + '\u0075' + '\u0065') {
230
+ ch = gr("#243aff", "#4687f0", "#5800d4");
231
+ cre = chalk.blueBright;
232
+ } else if (logout === '\u0073' + '\u0075' + '\u006e' + '\u006c' + '\u0069' + '\u0067' + '\u0068' + '\u0074') {
233
+ ch = gr("#ffae00", "#ffbf00", "#ffdd00");
234
+ cre = chalk.hex("#f6ff00");
235
+ } else if (logout === '\u0072' + '\u0065' + '\u0064') {
236
+ ch = gr("#ff0000", "#ff0026");
237
+ cre = chalk.hex("#ff4747");
238
+ } else if (logout === '\u0072' + '\u0065' + '\u0074' + '\u0072' + '\u006f') {
239
+ ch = gr.retro;
240
+ cre = chalk.hex("#7d02bf");
241
+ } else if (logout === '\u0074' + '\u0065' + '\u0065' + '\u006e') {
242
+ ch = gr.teen;
243
+ cre = chalk.hex("#fa7f7f");
244
+ } else if (logout === '\u0073' + '\u0075' + '\u006d' + '\u006d' + '\u0065' + '\u0072') {
245
+ ch = gr.summer;
246
+ cre = chalk.hex("#f7f565");
247
+ } else if (logout === '\u0066' + '\u006c' + '\u006f' + '\u0077' + '\u0065' + '\u0072') {
248
+ ch = gr.pastel;
249
+ cre = chalk.hex("#6ded85");
250
+ } else if (logout === '\u0067' + '\u0068' + '\u006f' + '\u0073' + '\u0074') {
251
+ ch = gr.mind;
252
+ cre = chalk.hex("#95d0de");
253
+ } else {
254
+ ch = gr("#243aff", "#4687f0", "#5800d4");
255
+ cre = chalk.blueBright;
256
+
257
+ setTimeout(() => {
258
+ console.log(`\u0054\u0068\u0065 ${chalk.bgYellow.bold(`${config.DESIGN.Theme}`)} \u0074\u0068\u0065\u006D\u0065\u0020\u0079\u006F\u0075\u0020\u0070\u0072\u006F\u0076\u0069\u0064\u0065\u0064\u0020\u0064\u006F\u0065\u0073\u0020\u006E\u006F\u0074\u0020\u0065\u0078\u0069\u0073\u0074\u0021`)
259
+ }, 1000);
260
+ };
261
+
262
+ setTimeout(() => {
263
+ const title = _.DESIGN.Title || '';
264
+ const asciiTitle = generateAsciiArt(title);
265
+ console.log(
266
+ ch.multiline('\n' + asciiTitle),
267
+ '\n',
268
+ ch(' \u2771 ') + '\u0043'+'\u0072'+'\u0065'+'\u0064'+'\u0069'+'\u0074'+'\u0073'+'\u0020'+'\u0074'+'\u006f',
269
+ cre('\u0059'+'\u0061'+'\u006E'+'\u0020'+'\u004D'+'\u0061'+'\u0067'+'\u006C'+'\u0069'+'\u006E'+'\u0074'+'\u0065'),
270
+ '\n',
271
+ ch(' \u2771 ') + `\u0041`+`\u0064`+`\u006d`+`\u0069`+`\u006e`+`\u003a ${cre(`${cb}`)}\n`
272
+ );
273
+ }, 1000);
274
+ }
275
+ module.exports = logs;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ const log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ return function markAsDelivered(threadID, messageID, callback) {
8
+ let resolveFunc = function () { };
9
+ let rejectFunc = function () { };
10
+ const returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
+
15
+ if (!callback) {
16
+ callback = function (err, friendList) {
17
+ if (err) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc(friendList);
21
+ };
22
+ }
23
+
24
+ if (!threadID || !messageID) {
25
+ return callback("Error: messageID or threadID is not defined");
26
+ }
27
+
28
+ const form = {};
29
+
30
+ form["message_ids[0]"] = messageID;
31
+ form["thread_ids[" + threadID + "][0]"] = messageID;
32
+
33
+ defaultFuncs
34
+ .post(
35
+ "https://www.facebook.com/ajax/mercury/delivery_receipts.php",
36
+ ctx.jar,
37
+ form
38
+ )
39
+ .then(utils.saveCookies(ctx.jar))
40
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
41
+ .then(function (resData) {
42
+ if (resData.error) {
43
+ throw resData;
44
+ }
45
+
46
+ return callback();
47
+ })
48
+ .catch(function (err) {
49
+ log.error("markAsDelivered", err);
50
+ if (utils.getType(err) == "Object" && err.error === "Not logged in.") {
51
+ ctx.loggedIn = false;
52
+ }
53
+ return callback(err);
54
+ });
55
+
56
+ return returnPromise;
57
+ };
58
+ };
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ const log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ return async function markAsRead(threadID, read, callback) {
8
+ if (utils.getType(read) === 'Function' || utils.getType(read) === 'AsyncFunction') {
9
+ callback = read;
10
+ read = true;
11
+ }
12
+ if (read == undefined) {
13
+ read = true;
14
+ }
15
+
16
+ if (!callback) {
17
+ callback = () => { };
18
+ }
19
+
20
+ const form = {};
21
+
22
+ if (typeof ctx.globalOptions.pageID !== 'undefined') {
23
+ form["source"] = "PagesManagerMessagesInterface";
24
+ form["request_user_id"] = ctx.globalOptions.pageID;
25
+ form["ids[" + threadID + "]"] = read;
26
+ form["watermarkTimestamp"] = new Date().getTime();
27
+ form["shouldSendReadReceipt"] = true;
28
+ form["commerce_last_message_type"] = "";
29
+ //form["titanOriginatedThreadId"] = utils.generateThreadingID(ctx.clientID);
30
+
31
+ let resData;
32
+ try {
33
+ resData = await (
34
+ defaultFuncs
35
+ .post(
36
+ "https://www.facebook.com/ajax/mercury/change_read_status.php",
37
+ ctx.jar,
38
+ form
39
+ )
40
+ .then(utils.saveCookies(ctx.jar))
41
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
42
+ );
43
+ } catch (e) {
44
+ callback(e);
45
+ return e;
46
+ }
47
+
48
+ if (resData.error) {
49
+ const err = resData.error;
50
+ log.error("markAsRead", err);
51
+ if (utils.getType(err) == "Object" && err.error === "Not logged in.") {
52
+ ctx.loggedIn = false;
53
+ }
54
+ callback(err);
55
+ return err;
56
+ }
57
+
58
+ callback();
59
+ return null;
60
+ } else {
61
+ try {
62
+ if (ctx.mqttClient) {
63
+ const err = await new Promise(r => ctx.mqttClient.publish("/mark_thread", JSON.stringify({
64
+ threadID,
65
+ mark: "read",
66
+ state: read
67
+ }), { qos: 1, retain: false }, r));
68
+ if (err) throw err;
69
+ } else {
70
+ throw {
71
+ error: "You can only use this function after you start listening."
72
+ };
73
+ }
74
+ } catch (e) {
75
+ callback(e);
76
+ return e;
77
+ }
78
+ }
79
+ };
80
+ };
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ const log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ return function markAsReadAll(callback) {
8
+ let resolveFunc = function () { };
9
+ let rejectFunc = function () { };
10
+ const returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
+
15
+ if (!callback) {
16
+ callback = function (err, friendList) {
17
+ if (err) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc(friendList);
21
+ };
22
+ }
23
+
24
+ const form = {
25
+ folder: 'inbox'
26
+ };
27
+
28
+ defaultFuncs
29
+ .post(
30
+ "https://www.facebook.com/ajax/mercury/mark_folder_as_read.php",
31
+ ctx.jar,
32
+ form
33
+ )
34
+ .then(utils.saveCookies(ctx.jar))
35
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
36
+ .then(function (resData) {
37
+ if (resData.error) {
38
+ throw resData;
39
+ }
40
+
41
+ return callback();
42
+ })
43
+ .catch(function (err) {
44
+ log.error("markAsReadAll", err);
45
+ return callback(err);
46
+ });
47
+
48
+ return returnPromise;
49
+ };
50
+ };
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ const log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ return function markAsRead(seen_timestamp, callback) {
8
+ if (utils.getType(seen_timestamp) == "Function" ||
9
+ utils.getType(seen_timestamp) == "AsyncFunction") {
10
+ callback = seen_timestamp;
11
+ seen_timestamp = Date.now();
12
+ }
13
+
14
+ let resolveFunc = function () { };
15
+ let rejectFunc = function () { };
16
+ const returnPromise = new Promise(function (resolve, reject) {
17
+ resolveFunc = resolve;
18
+ rejectFunc = reject;
19
+ });
20
+
21
+ if (!callback) {
22
+ callback = function (err, friendList) {
23
+ if (err) {
24
+ return rejectFunc(err);
25
+ }
26
+ resolveFunc(friendList);
27
+ };
28
+ }
29
+
30
+ const form = {
31
+ seen_timestamp: seen_timestamp
32
+ };
33
+
34
+ defaultFuncs
35
+ .post(
36
+ "https://www.facebook.com/ajax/mercury/mark_seen.php",
37
+ ctx.jar,
38
+ form
39
+ )
40
+ .then(utils.saveCookies(ctx.jar))
41
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
42
+ .then(function (resData) {
43
+ if (resData.error) {
44
+ throw resData;
45
+ }
46
+
47
+ return callback();
48
+ })
49
+ .catch(function (err) {
50
+ log.error("markAsSeen", err);
51
+ if (utils.getType(err) == "Object" && err.error === "Not logged in.") {
52
+ ctx.loggedIn = false;
53
+ }
54
+ return callback(err);
55
+ });
56
+
57
+ return returnPromise;
58
+ };
59
+ };
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ const log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ // muteSecond: -1=permanent mute, 0=unmute, 60=one minute, 3600=one hour, etc.
8
+ return function muteThread(threadID, muteSeconds, callback) {
9
+ let resolveFunc = function () { };
10
+ let rejectFunc = function () { };
11
+ const returnPromise = new Promise(function (resolve, reject) {
12
+ resolveFunc = resolve;
13
+ rejectFunc = reject;
14
+ });
15
+
16
+ if (!callback) {
17
+ callback = function (err, friendList) {
18
+ if (err) {
19
+ return rejectFunc(err);
20
+ }
21
+ resolveFunc(friendList);
22
+ };
23
+ }
24
+
25
+ const form = {
26
+ thread_fbid: threadID,
27
+ mute_settings: muteSeconds
28
+ };
29
+
30
+ defaultFuncs
31
+ .post(
32
+ "https://www.facebook.com/ajax/mercury/change_mute_thread.php",
33
+ ctx.jar,
34
+ form
35
+ )
36
+ .then(utils.saveCookies(ctx.jar))
37
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
38
+ .then(function (resData) {
39
+ if (resData.error) {
40
+ throw resData;
41
+ }
42
+
43
+ return callback();
44
+ })
45
+ .catch(function (err) {
46
+ log.error("muteThread", err);
47
+ return callback(err);
48
+ });
49
+
50
+ return returnPromise;
51
+ };
52
+ };
package/src/react.js ADDED
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ const log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ return function setMessageReaction(reaction, messageID, callback, forceCustomReaction) {
8
+ let resolveFunc = function () { };
9
+ let rejectFunc = function () { };
10
+ const returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
+
15
+ if (!callback) {
16
+ callback = function (err, friendList) {
17
+ if (err) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc(friendList);
21
+ };
22
+ }
23
+
24
+ switch (reaction) {
25
+ case "\uD83D\uDE0D": //:heart_eyes:
26
+ case "\uD83D\uDE06": //:laughing:
27
+ case "\uD83D\uDE2E": //:open_mouth:
28
+ case "\uD83D\uDE22": //:cry:
29
+ case "\uD83D\uDE20": //:angry:
30
+ case "\uD83D\uDC4D": //:thumbsup:
31
+ case "\uD83D\uDC4E": //:thumbsdown:
32
+ case "\u2764": //:heart:
33
+ case "\uD83D\uDC97": //:glowingheart:
34
+ case "":
35
+ //valid
36
+ break;
37
+ case ":heart_eyes:":
38
+ case ":love:":
39
+ reaction = "\uD83D\uDE0D";
40
+ break;
41
+ case ":laughing:":
42
+ case ":haha:":
43
+ reaction = "\uD83D\uDE06";
44
+ break;
45
+ case ":open_mouth:":
46
+ case ":wow:":
47
+ reaction = "\uD83D\uDE2E";
48
+ break;
49
+ case ":cry:":
50
+ case ":sad:":
51
+ reaction = "\uD83D\uDE22";
52
+ break;
53
+ case ":angry:":
54
+ reaction = "\uD83D\uDE20";
55
+ break;
56
+ case ":thumbsup:":
57
+ case ":like:":
58
+ reaction = "\uD83D\uDC4D";
59
+ break;
60
+ case ":thumbsdown:":
61
+ case ":dislike:":
62
+ reaction = "\uD83D\uDC4E";
63
+ break;
64
+ case ":heart:":
65
+ reaction = "\u2764";
66
+ break;
67
+ case ":glowingheart:":
68
+ reaction = "\uD83D\uDC97";
69
+ break;
70
+ default:
71
+ if (forceCustomReaction) {
72
+ break;
73
+ }
74
+ return callback({ error: "Reaction is not a valid emoji." });
75
+ }
76
+
77
+ const variables = {
78
+ data: {
79
+ client_mutation_id: ctx.clientMutationId++,
80
+ actor_id: ctx.i_userID || ctx.userID,
81
+ action: reaction == "" ? "REMOVE_REACTION" : "ADD_REACTION",
82
+ message_id: messageID,
83
+ reaction: reaction
84
+ }
85
+ };
86
+
87
+ const qs = {
88
+ doc_id: "1491398900900362",
89
+ variables: JSON.stringify(variables),
90
+ dpr: 1
91
+ };
92
+
93
+ defaultFuncs
94
+ .postFormData(
95
+ "https://www.facebook.com/webgraphql/mutation/",
96
+ ctx.jar,
97
+ {},
98
+ qs
99
+ )
100
+ .then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
101
+ .then(function (resData) {
102
+ if (!resData) {
103
+ throw { error: "setReaction returned empty object." };
104
+ }
105
+ if (resData.error) {
106
+ throw resData;
107
+ }
108
+ callback(null);
109
+ })
110
+ .catch(function (err) {
111
+ log.error("setReaction", err);
112
+ return callback(err);
113
+ });
114
+
115
+ return returnPromise;
116
+ };
117
+ };
@@ -78,4 +78,4 @@ module.exports = function (defaultFuncs, api, ctx) {
78
78
 
79
79
  return returnPromise;
80
80
  };
81
- };
81
+ };