alicezetion 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -1
  2. package/.cache/replit/modules.stamp +1 -0
  3. package/.cache/replit/nix/env.json +1 -1
  4. package/index.js +536 -604
  5. package/package.json +78 -75
  6. package/replit.nix +6 -0
  7. package/src/addExternalModule.js +15 -0
  8. package/{alice → src}/addUserToGroup.js +77 -113
  9. package/src/changeAdminStatus.js +47 -0
  10. package/src/changeArchivedStatus.js +41 -0
  11. package/{alice → src}/changeBio.js +64 -77
  12. package/{alice → src}/changeBlockedStatus.js +36 -47
  13. package/{alice → src}/changeGroupImage.js +105 -129
  14. package/src/changeNickname.js +43 -0
  15. package/{alice → src}/changeThreadColor.js +61 -71
  16. package/src/changeThreadEmoji.js +41 -0
  17. package/src/chat.js +315 -0
  18. package/{alice → src}/createNewGroup.js +70 -86
  19. package/{alice → src}/createPoll.js +59 -71
  20. package/src/deleteMessage.js +44 -0
  21. package/src/deleteThread.js +42 -0
  22. package/src/forwardAttachment.js +47 -0
  23. package/src/forwardMessage.js +0 -0
  24. package/{alice → src}/getCurrentUserID.js +7 -7
  25. package/{alice → src}/getEmojiUrl.js +27 -29
  26. package/{alice → src}/getFriendsList.js +73 -84
  27. package/{alice → src}/getThreadHistory.js +537 -645
  28. package/src/getThreadHistoryDeprecated.js +71 -0
  29. package/{alice → src}/getThreadInfo.js +171 -206
  30. package/src/getThreadInfoDeprecated.js +56 -0
  31. package/{alice → src}/getThreadList.js +213 -238
  32. package/src/getThreadListDeprecated.js +46 -0
  33. package/src/getThreadPictures.js +59 -0
  34. package/{alice → src}/getUserID.js +61 -66
  35. package/{alice → src}/getUserInfo.js +66 -72
  36. package/src/handleFriendRequest.js +46 -0
  37. package/src/handleMessageRequest.js +47 -0
  38. package/{alice → src}/httpGet.js +47 -52
  39. package/{alice → src}/httpPost.js +47 -52
  40. package/src/listen.js +553 -0
  41. package/src/listenMqtt-Test.js +687 -0
  42. package/src/listenMqtt.js +677 -0
  43. package/{alice → src}/logout.js +68 -75
  44. package/{alice → src}/markAsDelivered.js +47 -58
  45. package/{alice → src}/markAsRead.js +70 -80
  46. package/{alice/seen.js → src/markAsReadAll.js} +39 -49
  47. package/{alice → src}/markAsSeen.js +48 -59
  48. package/{alice → src}/muteThread.js +45 -52
  49. package/src/removeUserFromGroup.js +45 -0
  50. package/{alice → src}/resolvePhotoUrl.js +36 -45
  51. package/src/searchForThread.js +42 -0
  52. package/{alice → src}/sendTypingIndicator.js +70 -103
  53. package/{alice/react.js → src/setMessageReaction.js} +103 -117
  54. package/{alice → src}/setPostReaction.js +63 -76
  55. package/{alice → src}/setTitle.js +70 -86
  56. package/src/threadColors.js +41 -0
  57. package/{alice → src}/unfriend.js +42 -52
  58. package/{alice → src}/unsendMessage.js +39 -49
  59. package/utils.js +1193 -1357
  60. package/alice/addExternalModule.js +0 -19
  61. package/alice/changeAdminStatus.js +0 -79
  62. package/alice/changeArchivedStatus.js +0 -55
  63. package/alice/changeNickname.js +0 -59
  64. package/alice/changeThreadEmoji.js +0 -55
  65. package/alice/chat.js +0 -459
  66. package/alice/deleteMessage.js +0 -56
  67. package/alice/deleteThread.js +0 -56
  68. package/alice/forwardAttachment.js +0 -60
  69. package/alice/getThreadHistoryDeprecated.js +0 -93
  70. package/alice/getThreadInfoDeprecated.js +0 -80
  71. package/alice/getThreadListDeprecated.js +0 -75
  72. package/alice/getThreadPictures.js +0 -79
  73. package/alice/handleFriendRequest.js +0 -61
  74. package/alice/handleMessageRequest.js +0 -65
  75. package/alice/listenMqtt.js +0 -789
  76. package/alice/removeUserFromGroup.js +0 -79
  77. package/alice/searchForThread.js +0 -53
  78. package/alice/threadColors.js +0 -57
  79. package/test/data/shareAttach.js +0 -146
  80. package/test/data/something.mov +0 -0
  81. package/test/data/test.png +0 -0
  82. package/test/data/test.txt +0 -7
  83. package/test/example-config.json +0 -18
  84. package/test/test-page.js +0 -140
  85. package/test/test.js +0 -385
@@ -1,52 +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
- // muteSecond: -1=permanent mute, 0=unmute, 60=one minute, 3600=one hour, etc.
8
- return function muteThread(threadID, muteSeconds, 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
- callback = function (err, friendList) {
18
- if (err) {
19
- return rejectFunc(err);
20
- }
21
- resolveFunc(friendList);
22
- };
23
- }
24
-
25
- var 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
- };
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var 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
+ 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
+ callback = function (err, data) {
18
+ if (err) return rejectFunc(err);
19
+
20
+ resolveFunc(data);
21
+ };
22
+ }
23
+
24
+ var form = {
25
+ thread_fbid: threadID,
26
+ mute_settings: muteSeconds
27
+ };
28
+
29
+ defaultFuncs
30
+ .post("https://www.facebook.com/ajax/mercury/change_mute_thread.php", ctx.jar, form)
31
+ .then(utils.saveCookies(ctx.jar))
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("muteThread", err);
40
+ return callback(err);
41
+ });
42
+
43
+ return returnPromise;
44
+ };
45
+ };
@@ -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 removeUserFromGroup(userID, threadID, callback) {
8
+ if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
9
+ if (utils.getType(threadID) !== "Number" && utils.getType(threadID) !== "String") throw { error: "threadID should be of type Number or String and not " + utils.getType(threadID) + "." };
10
+ if (utils.getType(userID) !== "Number" && utils.getType(userID) !== "String") throw { error: "userID should be of type Number or String and not " + utils.getType(userID) + "." };
11
+
12
+ var resolveFunc = function () { };
13
+ var rejectFunc = function () { };
14
+ var returnPromise = new Promise(function (resolve, reject) {
15
+ resolveFunc = resolve;
16
+ rejectFunc = reject;
17
+ });
18
+
19
+ if (!callback) {
20
+ callback = function (err, data) {
21
+ if (err) return rejectFunc(err);
22
+ resolveFunc(data);
23
+ };
24
+ }
25
+
26
+ var form = {
27
+ uid: userID,
28
+ tid: threadID
29
+ };
30
+
31
+ defaultFuncs
32
+ .post("https://www.facebook.com/chat/remove_participants", ctx.jar, form)
33
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
34
+ .then(function (resData) {
35
+ if (!resData) throw { error: "Remove from group failed." };
36
+ if (resData.error) throw resData;
37
+ return callback();
38
+ })
39
+ .catch(function (err) {
40
+ log.error("removeUserFromGroup", "» Bailing out of trying to parse response");
41
+ return callback(err);
42
+ });
43
+ return returnPromise;
44
+ };
45
+ };
@@ -1,45 +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 resolvePhotoUrl(photoID, 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, friendList) {
17
- if (err) {
18
- return rejectFunc(err);
19
- }
20
- resolveFunc(friendList);
21
- };
22
- }
23
-
24
- defaultFuncs
25
- .get("https://www.facebook.com/mercury/attachments/photo", ctx.jar, {
26
- photo_id: photoID
27
- })
28
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
29
- .then(resData => {
30
- if (resData.error) {
31
- throw resData;
32
- }
33
-
34
- var photoUrl = resData.jsmods.require[0][3][0];
35
-
36
- return callback(null, photoUrl);
37
- })
38
- .catch(err => {
39
- log.error("resolvePhotoUrl", err);
40
- return callback(err);
41
- });
42
-
43
- return returnPromise;
44
- };
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 resolvePhotoUrl(photoID, 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, data) {
17
+ if (err) return rejectFunc(err);
18
+ resolveFunc(data);
19
+ };
20
+ }
21
+
22
+ defaultFuncs
23
+ .get("https://www.facebook.com/mercury/attachments/photo", ctx.jar, { photo_id: photoID })
24
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
25
+ .then(resData => {
26
+ if (resData.error) throw resData;
27
+ var photoUrl = resData.jsmods.require[0][3][0];
28
+ return callback(null, photoUrl);
29
+ })
30
+ .catch(err => {
31
+ log.error("resolvePhotoUrl", err);
32
+ return callback(err);
33
+ });
34
+ return returnPromise;
35
+ };
36
+ };
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+
5
+ module.exports = function (defaultFuncs, api, ctx) {
6
+ return function searchForThread(name, callback) {
7
+ var resolveFunc = function () { };
8
+ var rejectFunc = function () { };
9
+ var returnPromise = new Promise(function (resolve, reject) {
10
+ resolveFunc = resolve;
11
+ rejectFunc = reject;
12
+ });
13
+
14
+ if (!callback) {
15
+ callback = function (err, data) {
16
+ if (err) return rejectFunc(err);
17
+ resolveFunc(data);
18
+ };
19
+ }
20
+
21
+ var tmpForm = {
22
+ client: "web_messenger",
23
+ query: name,
24
+ offset: 0,
25
+ limit: 21,
26
+ index: "fbid"
27
+ };
28
+
29
+ defaultFuncs
30
+ .post("https://www.facebook.com/ajax/mercury/search_threads.php", ctx.jar, tmpForm)
31
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
32
+ .then(function (resData) {
33
+ if (resData.error) throw resData;
34
+ if (!resData.payload.mercury_payload.threads) return callback({ error: "Could not find thread `" + name + "`." });
35
+ return callback(
36
+ null,
37
+ resData.payload.mercury_payload.threads.map(utils.formatThread)
38
+ );
39
+ });
40
+ return returnPromise;
41
+ };
42
+ };
@@ -1,103 +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
- function makeTypingIndicator(typ, threadID, callback, isGroup) {
8
- var form = {
9
- typ: +typ,
10
- to: "",
11
- source: "mercury-chat",
12
- thread: threadID
13
- };
14
-
15
- // Check if thread is a single person chat or a group chat
16
- // More info on this is in api.sendMessage
17
- if (utils.getType(isGroup) == "Boolean") {
18
- if (!isGroup) {
19
- form.to = threadID;
20
- }
21
- defaultFuncs
22
- .post("https://www.facebook.com/ajax/messaging/typ.php", ctx.jar, form)
23
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
24
- .then(function (resData) {
25
- if (resData.error) {
26
- throw resData;
27
- }
28
-
29
- return callback();
30
- })
31
- .catch(function (err) {
32
- log.error("sendTypingIndicator", err);
33
- if (utils.getType(err) == "Object" && err.error === "Not logged in") {
34
- ctx.loggedIn = false;
35
- }
36
- return callback(err);
37
- });
38
- } else {
39
- api.getUserInfo(threadID, function (err, res) {
40
- if (err) {
41
- return callback(err);
42
- }
43
-
44
- // If id is single person chat
45
- if (Object.keys(res).length > 0) {
46
- form.to = threadID;
47
- }
48
-
49
- defaultFuncs
50
- .post("https://www.facebook.com/ajax/messaging/typ.php", ctx.jar, form)
51
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
52
- .then(function (resData) {
53
- if (resData.error) {
54
- throw resData;
55
- }
56
-
57
- return callback();
58
- })
59
- .catch(function (err) {
60
- log.error("sendTypingIndicator", err);
61
- if (utils.getType(err) == "Object" && err.error === "Not logged in.") {
62
- ctx.loggedIn = false;
63
- }
64
- return callback(err);
65
- });
66
- });
67
- }
68
- }
69
-
70
- return function sendTypingIndicator(threadID, callback, isGroup) {
71
- if (
72
- utils.getType(callback) !== "Function" &&
73
- utils.getType(callback) !== "AsyncFunction"
74
- ) {
75
- if (callback) {
76
- log.warn(
77
- "sendTypingIndicator",
78
- "callback is not a function - ignoring."
79
- );
80
- }
81
- callback = () => { };
82
- }
83
-
84
- makeTypingIndicator(true, threadID, callback, isGroup);
85
-
86
- return function end(cb) {
87
- if (
88
- utils.getType(cb) !== "Function" &&
89
- utils.getType(cb) !== "AsyncFunction"
90
- ) {
91
- if (cb) {
92
- log.warn(
93
- "sendTypingIndicator",
94
- "callback is not a function - ignoring."
95
- );
96
- }
97
- cb = () => { };
98
- }
99
-
100
- makeTypingIndicator(false, threadID, cb, isGroup);
101
- };
102
- };
103
- };
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ function makeTypingIndicator(typ, threadID, callback, isGroup) {
8
+ var form = {
9
+ typ: +typ,
10
+ to: "",
11
+ source: "mercury-chat",
12
+ thread: threadID
13
+ };
14
+
15
+ // Check if thread is a single person chat or a group chat
16
+ // More info on this is in api.sendMessage
17
+ if (utils.getType(isGroup) == "Boolean") {
18
+ if (!isGroup) form.to = threadID;
19
+
20
+ defaultFuncs
21
+ .post("https://www.facebook.com/ajax/messaging/typ.php", ctx.jar, form)
22
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
23
+ .then(function (resData) {
24
+ if (resData.error) throw resData;
25
+ return callback();
26
+ })
27
+ .catch(function (err) {
28
+ log.error("sendTypingIndicator", err);
29
+ if (utils.getType(err) == "Object" && err.error === "Not logged in") ctx.loggedIn = false;
30
+ return callback(err);
31
+ });
32
+ }
33
+ else {
34
+ api.getUserInfo(threadID, function (err, res) {
35
+ if (err) return callback(err);
36
+ // If id is single person chat
37
+ if (Object.keys(res).length > 0) form.to = threadID;
38
+ defaultFuncs
39
+ .post("https://www.facebook.com/ajax/messaging/typ.php", ctx.jar, form)
40
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
41
+ .then(function (resData) {
42
+ if (resData.error) throw resData;
43
+ return callback();
44
+ })
45
+ .catch(function (err) {
46
+ log.error("sendTypingIndicator", err);
47
+ if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
48
+ return callback(err);
49
+ });
50
+ });
51
+ }
52
+ }
53
+
54
+ return function sendTypingIndicator(threadID, callback, isGroup) {
55
+ if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
56
+ if (callback) log.warn("sendTypingIndicator", "callback is not a function - ignoring.");
57
+ callback = () => { };
58
+ }
59
+
60
+ makeTypingIndicator(true, threadID, callback, isGroup);
61
+
62
+ return function end(cb) {
63
+ if (utils.getType(cb) !== "Function" && utils.getType(cb) !== "AsyncFunction") {
64
+ if (cb) log.warn("sendTypingIndicator", "callback is not a function - ignoring.");
65
+ cb = () => { };
66
+ }
67
+ makeTypingIndicator(false, threadID, cb, isGroup);
68
+ };
69
+ };
70
+ };
@@ -1,117 +1,103 @@
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 setMessageReaction(reaction, messageID, callback, forceCustomReaction) {
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, 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
- var variables = {
78
- data: {
79
- client_mutation_id: ctx.clientMutationId++,
80
- actor_id: ctx.userID,
81
- action: reaction == "" ? "REMOVE_REACTION" : "ADD_REACTION",
82
- message_id: messageID,
83
- reaction: reaction
84
- }
85
- };
86
-
87
- var 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
- };
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 setMessageReaction(reaction, messageID, callback, forceCustomReaction) {
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, data) {
17
+ if (err) return rejectFunc(err);
18
+ resolveFunc(data);
19
+ };
20
+ }
21
+
22
+ switch (reaction) {
23
+ case "\uD83D\uDE0D": //:heart_eyes:
24
+ case "\uD83D\uDE06": //:laughing:
25
+ case "\uD83D\uDE2E": //:open_mouth:
26
+ case "\uD83D\uDE22": //:cry:
27
+ case "\uD83D\uDE20": //:angry:
28
+ case "\uD83D\uDC4D": //:thumbsup:
29
+ case "\uD83D\uDC4E": //:thumbsdown:
30
+ case "\u2764": //:heart:
31
+ case "\uD83D\uDC97": //:glowingheart:
32
+ case "":
33
+ //valid
34
+ break;
35
+ case ":heart_eyes:":
36
+ case ":love:":
37
+ reaction = "\uD83D\uDE0D";
38
+ break;
39
+ case ":laughing:":
40
+ case ":haha:":
41
+ reaction = "\uD83D\uDE06";
42
+ break;
43
+ case ":open_mouth:":
44
+ case ":wow:":
45
+ reaction = "\uD83D\uDE2E";
46
+ break;
47
+ case ":cry:":
48
+ case ":sad:":
49
+ reaction = "\uD83D\uDE22";
50
+ break;
51
+ case ":angry:":
52
+ reaction = "\uD83D\uDE20";
53
+ break;
54
+ case ":thumbsup:":
55
+ case ":like:":
56
+ reaction = "\uD83D\uDC4D";
57
+ break;
58
+ case ":thumbsdown:":
59
+ case ":dislike:":
60
+ reaction = "\uD83D\uDC4E";
61
+ break;
62
+ case ":heart:":
63
+ reaction = "\u2764";
64
+ break;
65
+ case ":glowingheart:":
66
+ reaction = "\uD83D\uDC97";
67
+ break;
68
+ default:
69
+ if (forceCustomReaction) break;
70
+ return callback({ error: "Reaction is not a valid emoji." });
71
+ }
72
+
73
+ var variables = {
74
+ data: {
75
+ client_mutation_id: ctx.clientMutationId++,
76
+ actor_id: ctx.userID,
77
+ action: reaction == "" ? "REMOVE_REACTION" : "ADD_REACTION",
78
+ message_id: messageID,
79
+ reaction: reaction
80
+ }
81
+ };
82
+
83
+ var qs = {
84
+ doc_id: "1491398900900362",
85
+ variables: JSON.stringify(variables),
86
+ dpr: 1
87
+ };
88
+
89
+ defaultFuncs
90
+ .postFormData("https://www.facebook.com/webgraphql/mutation/", ctx.jar, {}, qs)
91
+ .then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
92
+ .then(function (resData) {
93
+ if (!resData) throw { error: "setReaction returned empty object." };
94
+ if (resData.error) throw resData;
95
+ callback(null);
96
+ })
97
+ .catch(function (err) {
98
+ log.error("setReaction", err);
99
+ return callback(err);
100
+ });
101
+ return returnPromise;
102
+ };
103
+ };