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,77 +1,77 @@
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 changeBio(bio, publish, 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
- if (utils.getType(publish) == "Function" || utils.getType(publish) == "AsyncFunction") {
17
- callback = publish;
18
- } else {
19
- callback = function (err) {
20
- if (err) {
21
- return rejectFunc(err);
22
- }
23
- resolveFunc();
24
- };
25
- }
26
- }
27
-
28
- if (utils.getType(publish) != "Boolean") {
29
- publish = false;
30
- }
31
-
32
- if (utils.getType(bio) != "String") {
33
- bio = "";
34
- publish = false;
35
- }
36
-
37
- var form = {
38
- fb_api_caller_class: "RelayModern",
39
- fb_api_req_friendly_name: "ProfileCometSetBioMutation",
40
- // This doc_is is valid as of May 23, 2020
41
- doc_id: "2725043627607610",
42
- variables: JSON.stringify({
43
- input: {
44
- bio: bio,
45
- publish_bio_feed_story: publish,
46
- actor_id: ctx.userID,
47
- client_mutation_id: Math.round(Math.random() * 1024).toString()
48
- },
49
- hasProfileTileViewID: false,
50
- profileTileViewID: null,
51
- scale: 1
52
- }),
53
- av: ctx.userID
54
- };
55
-
56
- defaultFuncs
57
- .post(
58
- "https://www.facebook.com/api/graphql/",
59
- ctx.jar,
60
- form
61
- )
62
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
63
- .then(function (resData) {
64
- if (resData.errors) {
65
- throw resData;
66
- }
67
-
68
- return callback();
69
- })
70
- .catch(function (err) {
71
- log.error("changeBio", err);
72
- return callback(err);
73
- });
74
-
75
- return returnPromise;
76
- };
77
- };
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 changeBio(bio, publish, 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
+ if (utils.getType(publish) == "Function" || utils.getType(publish) == "AsyncFunction") {
17
+ callback = publish;
18
+ } else {
19
+ callback = function (err) {
20
+ if (err) {
21
+ return rejectFunc(err);
22
+ }
23
+ resolveFunc();
24
+ };
25
+ }
26
+ }
27
+
28
+ if (utils.getType(publish) != "Boolean") {
29
+ publish = false;
30
+ }
31
+
32
+ if (utils.getType(bio) != "String") {
33
+ bio = "";
34
+ publish = false;
35
+ }
36
+
37
+ var form = {
38
+ fb_api_caller_class: "RelayModern",
39
+ fb_api_req_friendly_name: "ProfileCometSetBioMutation",
40
+ // This doc_is is valid as of May 23, 2020
41
+ doc_id: "2725043627607610",
42
+ variables: JSON.stringify({
43
+ input: {
44
+ bio: bio,
45
+ publish_bio_feed_story: publish,
46
+ actor_id: ctx.userID,
47
+ client_mutation_id: Math.round(Math.random() * 1024).toString()
48
+ },
49
+ hasProfileTileViewID: false,
50
+ profileTileViewID: null,
51
+ scale: 1
52
+ }),
53
+ av: ctx.userID
54
+ };
55
+
56
+ defaultFuncs
57
+ .post(
58
+ "https://www.facebook.com/api/graphql/",
59
+ ctx.jar,
60
+ form
61
+ )
62
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
63
+ .then(function (resData) {
64
+ if (resData.errors) {
65
+ throw resData;
66
+ }
67
+
68
+ return callback();
69
+ })
70
+ .catch(function (err) {
71
+ log.error("changeBio", err);
72
+ return callback(err);
73
+ });
74
+
75
+ return returnPromise;
76
+ };
77
+ };
@@ -1,47 +1,47 @@
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 changeBlockedStatus(userID, block, 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) {
18
- return rejectFunc(err);
19
- }
20
- resolveFunc();
21
- };
22
- }
23
-
24
- defaultFuncs
25
- .post(
26
- `https://www.facebook.com/messaging/${block ? "" : "un"}block_messages/`,
27
- ctx.jar,
28
- {
29
- fbid: userID
30
- }
31
- )
32
- .then(utils.saveCookies(ctx.jar))
33
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
34
- .then(function (resData) {
35
- if (resData.error) {
36
- throw resData;
37
- }
38
-
39
- return callback();
40
- })
41
- .catch(function (err) {
42
- log.error("changeBlockedStatus", err);
43
- return callback(err);
44
- });
45
- return returnPromise;
46
- };
47
- };
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 changeBlockedStatus(userID, block, 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) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc();
21
+ };
22
+ }
23
+
24
+ defaultFuncs
25
+ .post(
26
+ `https://www.facebook.com/messaging/${block ? "" : "un"}block_messages/`,
27
+ ctx.jar,
28
+ {
29
+ fbid: userID
30
+ }
31
+ )
32
+ .then(utils.saveCookies(ctx.jar))
33
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
34
+ .then(function (resData) {
35
+ if (resData.error) {
36
+ throw resData;
37
+ }
38
+
39
+ return callback();
40
+ })
41
+ .catch(function (err) {
42
+ log.error("changeBlockedStatus", err);
43
+ return callback(err);
44
+ });
45
+ return returnPromise;
46
+ };
47
+ };
@@ -1,129 +1,129 @@
1
- "use strict";
2
-
3
- var utils = require("../utils");
4
- var log = require("npmlog");
5
- var bluebird = require("bluebird");
6
-
7
- module.exports = function(defaultFuncs, api, ctx) {
8
- function handleUpload(image, callback) {
9
- var uploads = [];
10
-
11
- var form = {
12
- images_only: "true",
13
- "attachment[]": image
14
- };
15
-
16
- uploads.push(
17
- defaultFuncs
18
- .postFormData(
19
- "https://upload.facebook.com/ajax/mercury/upload.php",
20
- ctx.jar,
21
- form,
22
- {}
23
- )
24
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
25
- .then(function(resData) {
26
- if (resData.error) {
27
- throw resData;
28
- }
29
-
30
- return resData.payload.metadata[0];
31
- })
32
- );
33
-
34
- // resolve all promises
35
- bluebird
36
- .all(uploads)
37
- .then(function(resData) {
38
- callback(null, resData);
39
- })
40
- .catch(function(err) {
41
- log.error("handleUpload", err);
42
- return callback(err);
43
- });
44
- }
45
-
46
- return function changeGroupImage(image, threadID, callback) {
47
- if (
48
- !callback &&
49
- (utils.getType(threadID) === "Function" ||
50
- utils.getType(threadID) === "AsyncFunction")
51
- ) {
52
- throw { error: "please pass a threadID as a second argument." };
53
- }
54
-
55
- var resolveFunc = function(){};
56
- var rejectFunc = function(){};
57
- var returnPromise = new Promise(function (resolve, reject) {
58
- resolveFunc = resolve;
59
- rejectFunc = reject;
60
- });
61
-
62
- if (!callback) {
63
- callback = function(err) {
64
- if (err) {
65
- return rejectFunc(err);
66
- }
67
- resolveFunc();
68
- };
69
- }
70
-
71
- var messageAndOTID = utils.generateOfflineThreadingID();
72
- var form = {
73
- client: "mercury",
74
- action_type: "ma-type:log-message",
75
- author: "fbid:" + ctx.userID,
76
- author_email: "",
77
- ephemeral_ttl_mode: "0",
78
- is_filtered_content: false,
79
- is_filtered_content_account: false,
80
- is_filtered_content_bh: false,
81
- is_filtered_content_invalid_app: false,
82
- is_filtered_content_quasar: false,
83
- is_forward: false,
84
- is_spoof_warning: false,
85
- is_unread: false,
86
- log_message_type: "log:thread-image",
87
- manual_retry_cnt: "0",
88
- message_id: messageAndOTID,
89
- offline_threading_id: messageAndOTID,
90
- source: "source:chat:web",
91
- "source_tags[0]": "source:chat",
92
- status: "0",
93
- thread_fbid: threadID,
94
- thread_id: "",
95
- timestamp: Date.now(),
96
- timestamp_absolute: "Today",
97
- timestamp_relative: utils.generateTimestampRelative(),
98
- timestamp_time_passed: "0"
99
- };
100
-
101
- handleUpload(image, function(err, payload) {
102
- if (err) {
103
- return callback(err);
104
- }
105
-
106
- form["thread_image_id"] = payload[0]["image_id"];
107
- form["thread_id"] = threadID;
108
-
109
- defaultFuncs
110
- .post("https://www.facebook.com/messaging/set_thread_image/", ctx.jar, form)
111
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
112
- .then(function(resData) {
113
- // check for errors here
114
-
115
- if (resData.error) {
116
- throw resData;
117
- }
118
-
119
- return callback();
120
- })
121
- .catch(function(err) {
122
- log.error("changeGroupImage", err);
123
- return callback(err);
124
- });
125
- });
126
-
127
- return returnPromise;
128
- };
129
- };
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+ var bluebird = require("bluebird");
6
+
7
+ module.exports = function(defaultFuncs, api, ctx) {
8
+ function handleUpload(image, callback) {
9
+ var uploads = [];
10
+
11
+ var form = {
12
+ images_only: "true",
13
+ "attachment[]": image
14
+ };
15
+
16
+ uploads.push(
17
+ defaultFuncs
18
+ .postFormData(
19
+ "https://upload.facebook.com/ajax/mercury/upload.php",
20
+ ctx.jar,
21
+ form,
22
+ {}
23
+ )
24
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
25
+ .then(function(resData) {
26
+ if (resData.error) {
27
+ throw resData;
28
+ }
29
+
30
+ return resData.payload.metadata[0];
31
+ })
32
+ );
33
+
34
+ // resolve all promises
35
+ bluebird
36
+ .all(uploads)
37
+ .then(function(resData) {
38
+ callback(null, resData);
39
+ })
40
+ .catch(function(err) {
41
+ log.error("handleUpload", err);
42
+ return callback(err);
43
+ });
44
+ }
45
+
46
+ return function changeGroupImage(image, threadID, callback) {
47
+ if (
48
+ !callback &&
49
+ (utils.getType(threadID) === "Function" ||
50
+ utils.getType(threadID) === "AsyncFunction")
51
+ ) {
52
+ throw { error: "please pass a threadID as a second argument." };
53
+ }
54
+
55
+ var resolveFunc = function(){};
56
+ var rejectFunc = function(){};
57
+ var returnPromise = new Promise(function (resolve, reject) {
58
+ resolveFunc = resolve;
59
+ rejectFunc = reject;
60
+ });
61
+
62
+ if (!callback) {
63
+ callback = function(err) {
64
+ if (err) {
65
+ return rejectFunc(err);
66
+ }
67
+ resolveFunc();
68
+ };
69
+ }
70
+
71
+ var messageAndOTID = utils.generateOfflineThreadingID();
72
+ var form = {
73
+ client: "mercury",
74
+ action_type: "ma-type:log-message",
75
+ author: "fbid:" + ctx.userID,
76
+ author_email: "",
77
+ ephemeral_ttl_mode: "0",
78
+ is_filtered_content: false,
79
+ is_filtered_content_account: false,
80
+ is_filtered_content_bh: false,
81
+ is_filtered_content_invalid_app: false,
82
+ is_filtered_content_quasar: false,
83
+ is_forward: false,
84
+ is_spoof_warning: false,
85
+ is_unread: false,
86
+ log_message_type: "log:thread-image",
87
+ manual_retry_cnt: "0",
88
+ message_id: messageAndOTID,
89
+ offline_threading_id: messageAndOTID,
90
+ source: "source:chat:web",
91
+ "source_tags[0]": "source:chat",
92
+ status: "0",
93
+ thread_fbid: threadID,
94
+ thread_id: "",
95
+ timestamp: Date.now(),
96
+ timestamp_absolute: "Today",
97
+ timestamp_relative: utils.generateTimestampRelative(),
98
+ timestamp_time_passed: "0"
99
+ };
100
+
101
+ handleUpload(image, function(err, payload) {
102
+ if (err) {
103
+ return callback(err);
104
+ }
105
+
106
+ form["thread_image_id"] = payload[0]["image_id"];
107
+ form["thread_id"] = threadID;
108
+
109
+ defaultFuncs
110
+ .post("https://www.facebook.com/messaging/set_thread_image/", ctx.jar, form)
111
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
112
+ .then(function(resData) {
113
+ // check for errors here
114
+
115
+ if (resData.error) {
116
+ throw resData;
117
+ }
118
+
119
+ return callback();
120
+ })
121
+ .catch(function(err) {
122
+ log.error("changeGroupImage", err);
123
+ return callback(err);
124
+ });
125
+ });
126
+
127
+ return returnPromise;
128
+ };
129
+ };
@@ -1,59 +1,59 @@
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 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) {
17
- return rejectFunc(err);
18
- }
19
- resolveFunc();
20
- };
21
- }
22
-
23
- var form = {
24
- nickname: nickname,
25
- participant_id: participantID,
26
- thread_or_other_fbid: threadID
27
- };
28
-
29
- defaultFuncs
30
- .post(
31
- "https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1",
32
- ctx.jar,
33
- form
34
- )
35
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
36
- .then(function(resData) {
37
- if (resData.error === 1545014) {
38
- throw { error: "Trying to change nickname of user isn't in thread" };
39
- }
40
- if (resData.error === 1357031) {
41
- throw {
42
- error:
43
- "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."
44
- };
45
- }
46
- if (resData.error) {
47
- throw resData;
48
- }
49
-
50
- return callback();
51
- })
52
- .catch(function(err) {
53
- log.error("changeNickname", err);
54
- return callback(err);
55
- });
56
-
57
- return returnPromise;
58
- };
59
- };
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 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) {
17
+ return rejectFunc(err);
18
+ }
19
+ resolveFunc();
20
+ };
21
+ }
22
+
23
+ var form = {
24
+ nickname: nickname,
25
+ participant_id: participantID,
26
+ thread_or_other_fbid: threadID
27
+ };
28
+
29
+ defaultFuncs
30
+ .post(
31
+ "https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1",
32
+ ctx.jar,
33
+ form
34
+ )
35
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
36
+ .then(function(resData) {
37
+ if (resData.error === 1545014) {
38
+ throw { error: "Trying to change nickname of user isn't in thread" };
39
+ }
40
+ if (resData.error === 1357031) {
41
+ throw {
42
+ error:
43
+ "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."
44
+ };
45
+ }
46
+ if (resData.error) {
47
+ throw resData;
48
+ }
49
+
50
+ return callback();
51
+ })
52
+ .catch(function(err) {
53
+ log.error("changeNickname", err);
54
+ return callback(err);
55
+ });
56
+
57
+ return returnPromise;
58
+ };
59
+ };