alicezetion 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) 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/.cache/replit/modules.stamp +0 -0
  63. package/.travis.yml +0 -6
@@ -1,50 +1,50 @@
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 markAsReadAll(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
- var 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
- };
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 markAsReadAll(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
+ var 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
50
  };
@@ -1,103 +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
- 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) {
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,76 +1,76 @@
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 unsendMessage(postID, type, 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
- var map = {
25
- like: 1,
26
- heart: 2,
27
- wow: 3,
28
- haha: 4,
29
- sad: 7,
30
- angry: 8
31
- };
32
- if (typeof type != "number") {
33
- type = map[type.toLocaleLowerCase()];
34
- if (!type) {
35
- type = 1;
36
- }
37
- }
38
- var form = {
39
- av: ctx.userID,
40
- fb_api_caller_class: "RelayModern",
41
- fb_api_req_friendly_name: "UFI2FeedbackReactMutation",
42
- //This doc_id is valid as of January 17th, 2020
43
- doc_id: "2580813318646067",
44
- variables: JSON.stringify({
45
- input: {
46
- client_mutation_id: "7",
47
- actor_id: ctx.userID,
48
- feedback_reaction: type,
49
-
50
- },
51
- useDefaultActor: true
52
- })
53
- };
54
-
55
- defaultFuncs
56
- .post(
57
- "https://www.facebook.com/api/graphql/",
58
- ctx.jar,
59
- form
60
- )
61
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
62
- .then(function(resData) {
63
- if (resData.error) {
64
- throw resData;
65
- }
66
-
67
- return callback();
68
- })
69
- .catch(function(err) {
70
- log.error("setPostReaction", err);
71
- return callback(err);
72
- });
73
-
74
- return returnPromise;
75
- };
76
- };
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 unsendMessage(postID, type, 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
+ var map = {
25
+ like: 1,
26
+ heart: 2,
27
+ wow: 3,
28
+ haha: 4,
29
+ sad: 7,
30
+ angry: 8
31
+ };
32
+ if (typeof type != "number") {
33
+ type = map[type.toLocaleLowerCase()];
34
+ if (!type) {
35
+ type = 1;
36
+ }
37
+ }
38
+ var form = {
39
+ av: ctx.userID,
40
+ fb_api_caller_class: "RelayModern",
41
+ fb_api_req_friendly_name: "UFI2FeedbackReactMutation",
42
+ //This doc_id is valid as of January 17th, 2020
43
+ doc_id: "2580813318646067",
44
+ variables: JSON.stringify({
45
+ input: {
46
+ client_mutation_id: "7",
47
+ actor_id: ctx.userID,
48
+ feedback_reaction: type,
49
+
50
+ },
51
+ useDefaultActor: true
52
+ })
53
+ };
54
+
55
+ defaultFuncs
56
+ .post(
57
+ "https://www.facebook.com/api/graphql/",
58
+ ctx.jar,
59
+ form
60
+ )
61
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
62
+ .then(function(resData) {
63
+ if (resData.error) {
64
+ throw resData;
65
+ }
66
+
67
+ return callback();
68
+ })
69
+ .catch(function(err) {
70
+ log.error("setPostReaction", err);
71
+ return callback(err);
72
+ });
73
+
74
+ return returnPromise;
75
+ };
76
+ };
package/alice/setTitle.js CHANGED
@@ -1,86 +1,86 @@
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 setTitle(newTitle, 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
-
16
- var resolveFunc = function(){};
17
- var rejectFunc = function(){};
18
- var returnPromise = new Promise(function (resolve, reject) {
19
- resolveFunc = resolve;
20
- rejectFunc = reject;
21
- });
22
-
23
- if (!callback) {
24
- callback = function (err, friendList) {
25
- if (err) {
26
- return rejectFunc(err);
27
- }
28
- resolveFunc(friendList);
29
- };
30
- }
31
-
32
- var messageAndOTID = utils.generateOfflineThreadingID();
33
- var form = {
34
- client: "mercury",
35
- action_type: "ma-type:log-message",
36
- author: "fbid:" + ctx.userID,
37
- author_email: "",
38
- coordinates: "",
39
- timestamp: Date.now(),
40
- timestamp_absolute: "Today",
41
- timestamp_relative: utils.generateTimestampRelative(),
42
- timestamp_time_passed: "0",
43
- is_unread: false,
44
- is_cleared: false,
45
- is_forward: false,
46
- is_filtered_content: false,
47
- is_spoof_warning: false,
48
- source: "source:chat:web",
49
- "source_tags[0]": "source:chat",
50
- status: "0",
51
- offline_threading_id: messageAndOTID,
52
- message_id: messageAndOTID,
53
- threading_id: utils.generateThreadingID(ctx.clientID),
54
- manual_retry_cnt: "0",
55
- thread_fbid: threadID,
56
- thread_name: newTitle,
57
- thread_id: threadID,
58
- log_message_type: "log:thread-name"
59
- };
60
-
61
- defaultFuncs
62
- .post("https://www.facebook.com/messaging/set_thread_name/", ctx.jar, form)
63
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
64
- .then(function(resData) {
65
- if (resData.error && resData.error === 1545012) {
66
- throw { error: "Cannot change chat title: Not member of chat." };
67
- }
68
-
69
- if (resData.error && resData.error === 1545003) {
70
- throw { error: "Cannot set title of single-user chat." };
71
- }
72
-
73
- if (resData.error) {
74
- throw resData;
75
- }
76
-
77
- return callback();
78
- })
79
- .catch(function(err) {
80
- log.error("setTitle", err);
81
- return callback(err);
82
- });
83
-
84
- return returnPromise;
85
- };
86
- };
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 setTitle(newTitle, 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
+
16
+ var resolveFunc = function(){};
17
+ var rejectFunc = function(){};
18
+ var returnPromise = new Promise(function (resolve, reject) {
19
+ resolveFunc = resolve;
20
+ rejectFunc = reject;
21
+ });
22
+
23
+ if (!callback) {
24
+ callback = function (err, friendList) {
25
+ if (err) {
26
+ return rejectFunc(err);
27
+ }
28
+ resolveFunc(friendList);
29
+ };
30
+ }
31
+
32
+ var messageAndOTID = utils.generateOfflineThreadingID();
33
+ var form = {
34
+ client: "mercury",
35
+ action_type: "ma-type:log-message",
36
+ author: "fbid:" + ctx.userID,
37
+ author_email: "",
38
+ coordinates: "",
39
+ timestamp: Date.now(),
40
+ timestamp_absolute: "Today",
41
+ timestamp_relative: utils.generateTimestampRelative(),
42
+ timestamp_time_passed: "0",
43
+ is_unread: false,
44
+ is_cleared: false,
45
+ is_forward: false,
46
+ is_filtered_content: false,
47
+ is_spoof_warning: false,
48
+ source: "source:chat:web",
49
+ "source_tags[0]": "source:chat",
50
+ status: "0",
51
+ offline_threading_id: messageAndOTID,
52
+ message_id: messageAndOTID,
53
+ threading_id: utils.generateThreadingID(ctx.clientID),
54
+ manual_retry_cnt: "0",
55
+ thread_fbid: threadID,
56
+ thread_name: newTitle,
57
+ thread_id: threadID,
58
+ log_message_type: "log:thread-name"
59
+ };
60
+
61
+ defaultFuncs
62
+ .post("https://www.facebook.com/messaging/set_thread_name/", ctx.jar, form)
63
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
64
+ .then(function(resData) {
65
+ if (resData.error && resData.error === 1545012) {
66
+ throw { error: "Cannot change chat title: Not member of chat." };
67
+ }
68
+
69
+ if (resData.error && resData.error === 1545003) {
70
+ throw { error: "Cannot set title of single-user chat." };
71
+ }
72
+
73
+ if (resData.error) {
74
+ throw resData;
75
+ }
76
+
77
+ return callback();
78
+ })
79
+ .catch(function(err) {
80
+ log.error("setTitle", err);
81
+ return callback(err);
82
+ });
83
+
84
+ return returnPromise;
85
+ };
86
+ };