alicezetion 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -1
  2. package/.cache/replit/nix/env.json +1 -1
  3. package/alice/addExternalModule.js +19 -19
  4. package/alice/addUserToGroup.js +113 -113
  5. package/alice/changeAdminStatus.js +79 -79
  6. package/alice/changeArchivedStatus.js +55 -55
  7. package/alice/changeBio.js +77 -77
  8. package/alice/changeBlockedStatus.js +47 -47
  9. package/alice/changeGroupImage.js +129 -129
  10. package/alice/changeNickname.js +59 -59
  11. package/alice/changeThreadColor.js +71 -71
  12. package/alice/changeThreadEmoji.js +55 -55
  13. package/alice/{sendMessage.js → chat.js} +459 -459
  14. package/alice/createNewGroup.js +86 -86
  15. package/alice/createPoll.js +71 -71
  16. package/alice/deleteMessage.js +56 -56
  17. package/alice/deleteThread.js +56 -56
  18. package/alice/forwardAttachment.js +60 -60
  19. package/alice/getCurrentUserID.js +7 -7
  20. package/alice/getEmojiUrl.js +29 -29
  21. package/alice/getFriendsList.js +84 -84
  22. package/alice/getThreadHistory.js +645 -645
  23. package/alice/getThreadHistoryDeprecated.js +93 -93
  24. package/alice/getThreadInfo.js +206 -206
  25. package/alice/getThreadInfoDeprecated.js +80 -80
  26. package/alice/getThreadList.js +238 -238
  27. package/alice/getThreadListDeprecated.js +75 -75
  28. package/alice/getThreadPictures.js +79 -79
  29. package/alice/getUserID.js +66 -66
  30. package/alice/getUserInfo.js +72 -72
  31. package/alice/handleFriendRequest.js +61 -61
  32. package/alice/handleMessageRequest.js +65 -65
  33. package/alice/httpGet.js +52 -52
  34. package/alice/httpPost.js +52 -52
  35. package/alice/listenMqtt.js +789 -789
  36. package/alice/logout.js +75 -75
  37. package/alice/markAsDelivered.js +58 -58
  38. package/alice/markAsRead.js +80 -80
  39. package/alice/markAsSeen.js +59 -59
  40. package/alice/muteThread.js +52 -52
  41. package/alice/{setMessageReaction.js → react.js} +117 -117
  42. package/alice/removeUserFromGroup.js +79 -79
  43. package/alice/resolvePhotoUrl.js +45 -45
  44. package/alice/searchForThread.js +53 -53
  45. package/alice/{markAsReadAll.js → seen.js} +49 -49
  46. package/alice/sendTypingIndicator.js +103 -103
  47. package/alice/setPostReaction.js +76 -76
  48. package/alice/setTitle.js +86 -86
  49. package/alice/threadColors.js +57 -57
  50. package/alice/unfriend.js +52 -52
  51. package/alice/unsendMessage.js +49 -49
  52. package/index.js +604 -604
  53. package/package.json +74 -77
  54. package/test/data/shareAttach.js +146 -0
  55. package/test/data/something.mov +0 -0
  56. package/test/data/test.png +0 -0
  57. package/test/data/test.txt +7 -0
  58. package/test/example-config.json +18 -0
  59. package/test/test-page.js +140 -0
  60. package/test/test.js +385 -0
  61. package/utils.js +1357 -1359
  62. package/.travis.yml +0 -6
@@ -1,117 +1,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, 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, 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,79 +1,79 @@
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 (
9
- !callback &&
10
- (utils.getType(threadID) === "Function" ||
11
- utils.getType(threadID) === "AsyncFunction")
12
- ) {
13
- throw { error: "please pass a threadID as a second argument." };
14
- }
15
- if (
16
- utils.getType(threadID) !== "Number" &&
17
- utils.getType(threadID) !== "String"
18
- ) {
19
- throw {
20
- error:
21
- "threadID should be of type Number or String and not " +
22
- utils.getType(threadID) +
23
- "."
24
- };
25
- }
26
- if (
27
- utils.getType(userID) !== "Number" &&
28
- utils.getType(userID) !== "String"
29
- ) {
30
- throw {
31
- error:
32
- "userID should be of type Number or String and not " +
33
- utils.getType(userID) +
34
- "."
35
- };
36
- }
37
-
38
- var resolveFunc = function(){};
39
- var rejectFunc = function(){};
40
- var returnPromise = new Promise(function (resolve, reject) {
41
- resolveFunc = resolve;
42
- rejectFunc = reject;
43
- });
44
-
45
- if (!callback) {
46
- callback = function (err, friendList) {
47
- if (err) {
48
- return rejectFunc(err);
49
- }
50
- resolveFunc(friendList);
51
- };
52
- }
53
-
54
- var form = {
55
- uid: userID,
56
- tid: threadID
57
- };
58
-
59
- defaultFuncs
60
- .post("https://www.facebook.com/chat/remove_participants", ctx.jar, form)
61
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
62
- .then(function(resData) {
63
- if (!resData) {
64
- throw { error: "Remove from group failed." };
65
- }
66
- if (resData.error) {
67
- throw resData;
68
- }
69
-
70
- return callback();
71
- })
72
- .catch(function(err) {
73
- log.error("removeUserFromGroup", err);
74
- return callback(err);
75
- });
76
-
77
- return returnPromise;
78
- };
79
- };
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 (
9
+ !callback &&
10
+ (utils.getType(threadID) === "Function" ||
11
+ utils.getType(threadID) === "AsyncFunction")
12
+ ) {
13
+ throw { error: "please pass a threadID as a second argument." };
14
+ }
15
+ if (
16
+ utils.getType(threadID) !== "Number" &&
17
+ utils.getType(threadID) !== "String"
18
+ ) {
19
+ throw {
20
+ error:
21
+ "threadID should be of type Number or String and not " +
22
+ utils.getType(threadID) +
23
+ "."
24
+ };
25
+ }
26
+ if (
27
+ utils.getType(userID) !== "Number" &&
28
+ utils.getType(userID) !== "String"
29
+ ) {
30
+ throw {
31
+ error:
32
+ "userID should be of type Number or String and not " +
33
+ utils.getType(userID) +
34
+ "."
35
+ };
36
+ }
37
+
38
+ var resolveFunc = function(){};
39
+ var rejectFunc = function(){};
40
+ var returnPromise = new Promise(function (resolve, reject) {
41
+ resolveFunc = resolve;
42
+ rejectFunc = reject;
43
+ });
44
+
45
+ if (!callback) {
46
+ callback = function (err, friendList) {
47
+ if (err) {
48
+ return rejectFunc(err);
49
+ }
50
+ resolveFunc(friendList);
51
+ };
52
+ }
53
+
54
+ var form = {
55
+ uid: userID,
56
+ tid: threadID
57
+ };
58
+
59
+ defaultFuncs
60
+ .post("https://www.facebook.com/chat/remove_participants", ctx.jar, form)
61
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
62
+ .then(function(resData) {
63
+ if (!resData) {
64
+ throw { error: "Remove from group failed." };
65
+ }
66
+ if (resData.error) {
67
+ throw resData;
68
+ }
69
+
70
+ return callback();
71
+ })
72
+ .catch(function(err) {
73
+ log.error("removeUserFromGroup", err);
74
+ return callback(err);
75
+ });
76
+
77
+ return returnPromise;
78
+ };
79
+ };
@@ -1,45 +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 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, 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,53 +1,53 @@
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, friendList) {
16
- if (err) {
17
- return rejectFunc(err);
18
- }
19
- resolveFunc(friendList);
20
- };
21
- }
22
-
23
- var tmpForm = {
24
- client: "web_messenger",
25
- query: name,
26
- offset: 0,
27
- limit: 21,
28
- index: "fbid"
29
- };
30
-
31
- defaultFuncs
32
- .post(
33
- "https://www.facebook.com/ajax/mercury/search_threads.php",
34
- ctx.jar,
35
- tmpForm
36
- )
37
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
38
- .then(function(resData) {
39
- if (resData.error) {
40
- throw resData;
41
- }
42
- if (!resData.payload.mercury_payload.threads) {
43
- return callback({ error: "Could not find thread `" + name + "`." });
44
- }
45
- return callback(
46
- null,
47
- resData.payload.mercury_payload.threads.map(utils.formatThread)
48
- );
49
- });
50
-
51
- return returnPromise;
52
- };
53
- };
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, friendList) {
16
+ if (err) {
17
+ return rejectFunc(err);
18
+ }
19
+ resolveFunc(friendList);
20
+ };
21
+ }
22
+
23
+ var tmpForm = {
24
+ client: "web_messenger",
25
+ query: name,
26
+ offset: 0,
27
+ limit: 21,
28
+ index: "fbid"
29
+ };
30
+
31
+ defaultFuncs
32
+ .post(
33
+ "https://www.facebook.com/ajax/mercury/search_threads.php",
34
+ ctx.jar,
35
+ tmpForm
36
+ )
37
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
38
+ .then(function(resData) {
39
+ if (resData.error) {
40
+ throw resData;
41
+ }
42
+ if (!resData.payload.mercury_payload.threads) {
43
+ return callback({ error: "Could not find thread `" + name + "`." });
44
+ }
45
+ return callback(
46
+ null,
47
+ resData.payload.mercury_payload.threads.map(utils.formatThread)
48
+ );
49
+ });
50
+
51
+ return returnPromise;
52
+ };
53
+ };