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
package/alice/logout.js CHANGED
@@ -1,75 +1,75 @@
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 logout(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
- 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
- var elem = resData.jsmods.instances[0][2][0].filter(function(v) {
37
- return v.value === "logout";
38
- })[0];
39
-
40
- var html = resData.jsmods.markup.filter(function(v) {
41
- return v[0] === elem.markup.__m;
42
- })[0][1].__html;
43
-
44
- var 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
- };
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 logout(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
+ 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
+ var elem = resData.jsmods.instances[0][2][0].filter(function(v) {
37
+ return v.value === "logout";
38
+ })[0];
39
+
40
+ var html = resData.jsmods.markup.filter(function(v) {
41
+ return v[0] === elem.markup.__m;
42
+ })[0][1].__html;
43
+
44
+ var 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
+ };
@@ -1,58 +1,58 @@
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 markAsDelivered(threadID, messageID, 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
- if (!threadID || !messageID) {
25
- return callback("Error: messageID or threadID is not defined");
26
- }
27
-
28
- var 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
- };
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 markAsDelivered(threadID, messageID, 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
+ if (!threadID || !messageID) {
25
+ return callback("Error: messageID or threadID is not defined");
26
+ }
27
+
28
+ var 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
+ };
@@ -1,80 +1,80 @@
1
- "use strict";
2
-
3
- var utils = require("../utils");
4
- var 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
- var 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
- let 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
- let 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
- };
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var 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
+ var 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
+ let 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
+ let 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
+ };
@@ -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 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
- var resolveFunc = function () { };
15
- var rejectFunc = function () { };
16
- var 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
- var 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
- };
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 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
+ var resolveFunc = function () { };
15
+ var rejectFunc = function () { };
16
+ var 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
+ var 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
+ };
@@ -1,52 +1,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, 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, 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
+ };