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,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 getThreadList(start, end, type, callback) {
8
- if (utils.getType(callback) === "Undefined") {
9
- if (utils.getType(end) !== "Number") {
10
- throw {
11
- error: "Please pass a number as a second argument."
12
- };
13
- } else if (
14
- utils.getType(type) === "Function" ||
15
- utils.getType(type) === "AsyncFunction"
16
- ) {
17
- callback = type;
18
- type = "inbox"; //default to inbox
19
- } else if (utils.getType(type) !== "String") {
20
- throw {
21
- error:
22
- "Please pass a String as a third argument. Your options are: inbox, pending, and archived"
23
- };
24
- } else {
25
- throw {
26
- error: "getThreadList: need callback"
27
- };
28
- }
29
- }
30
-
31
- if (type === "archived") {
32
- type = "action:archived";
33
- } else if (type !== "inbox" && type !== "pending" && type !== "other") {
34
- throw {
35
- error:
36
- "type can only be one of the following: inbox, pending, archived, other"
37
- };
38
- }
39
-
40
- if (end <= start) end = start + 20;
41
-
42
- var form = {
43
- client: "mercury"
44
- };
45
-
46
- form[type + "[offset]"] = start;
47
- form[type + "[limit]"] = end - start;
48
-
49
- if (ctx.globalOptions.pageID) {
50
- form.request_user_id = ctx.globalOptions.pageID;
51
- }
52
-
53
- defaultFuncs
54
- .post(
55
- "https://www.facebook.com/ajax/mercury/threadlist_info.php",
56
- ctx.jar,
57
- form
58
- )
59
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
60
- .then(function(resData) {
61
- if (resData.error) {
62
- throw resData;
63
- }
64
- log.verbose("getThreadList", JSON.stringify(resData.payload.threads));
65
- return callback(
66
- null,
67
- (resData.payload.threads || []).map(utils.formatThread)
68
- );
69
- })
70
- .catch(function(err) {
71
- log.error("getThreadList", err);
72
- return callback(err);
73
- });
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 getThreadList(start, end, type, callback) {
8
+ if (utils.getType(callback) === "Undefined") {
9
+ if (utils.getType(end) !== "Number") {
10
+ throw {
11
+ error: "Please pass a number as a second argument."
12
+ };
13
+ } else if (
14
+ utils.getType(type) === "Function" ||
15
+ utils.getType(type) === "AsyncFunction"
16
+ ) {
17
+ callback = type;
18
+ type = "inbox"; //default to inbox
19
+ } else if (utils.getType(type) !== "String") {
20
+ throw {
21
+ error:
22
+ "Please pass a String as a third argument. Your options are: inbox, pending, and archived"
23
+ };
24
+ } else {
25
+ throw {
26
+ error: "getThreadList: need callback"
27
+ };
28
+ }
29
+ }
30
+
31
+ if (type === "archived") {
32
+ type = "action:archived";
33
+ } else if (type !== "inbox" && type !== "pending" && type !== "other") {
34
+ throw {
35
+ error:
36
+ "type can only be one of the following: inbox, pending, archived, other"
37
+ };
38
+ }
39
+
40
+ if (end <= start) end = start + 20;
41
+
42
+ var form = {
43
+ client: "mercury"
44
+ };
45
+
46
+ form[type + "[offset]"] = start;
47
+ form[type + "[limit]"] = end - start;
48
+
49
+ if (ctx.globalOptions.pageID) {
50
+ form.request_user_id = ctx.globalOptions.pageID;
51
+ }
52
+
53
+ defaultFuncs
54
+ .post(
55
+ "https://www.facebook.com/ajax/mercury/threadlist_info.php",
56
+ ctx.jar,
57
+ form
58
+ )
59
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
60
+ .then(function(resData) {
61
+ if (resData.error) {
62
+ throw resData;
63
+ }
64
+ log.verbose("getThreadList", JSON.stringify(resData.payload.threads));
65
+ return callback(
66
+ null,
67
+ (resData.payload.threads || []).map(utils.formatThread)
68
+ );
69
+ })
70
+ .catch(function(err) {
71
+ log.error("getThreadList", err);
72
+ return callback(err);
73
+ });
74
+ };
75
+ };
@@ -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 getThreadPictures(threadID, offset, limit, 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
- thread_id: threadID,
26
- offset: offset,
27
- limit: limit
28
- };
29
-
30
- defaultFuncs
31
- .post(
32
- "https://www.facebook.com/ajax/messaging/attachments/sharedphotos.php",
33
- ctx.jar,
34
- form
35
- )
36
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
37
- .then(function(resData) {
38
- if (resData.error) {
39
- throw resData;
40
- }
41
- return Promise.all(
42
- resData.payload.imagesData.map(function(image) {
43
- form = {
44
- thread_id: threadID,
45
- image_id: image.fbid
46
- };
47
- return defaultFuncs
48
- .post(
49
- "https://www.facebook.com/ajax/messaging/attachments/sharedphotos.php",
50
- ctx.jar,
51
- form
52
- )
53
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
54
- .then(function(resData) {
55
- if (resData.error) {
56
- throw resData;
57
- }
58
- // the response is pretty messy
59
- var queryThreadID =
60
- resData.jsmods.require[0][3][1].query_metadata.query_path[0]
61
- .message_thread;
62
- var imageData =
63
- resData.jsmods.require[0][3][1].query_results[queryThreadID]
64
- .message_images.edges[0].node.image2;
65
- return imageData;
66
- });
67
- })
68
- );
69
- })
70
- .then(function(resData) {
71
- callback(null, resData);
72
- })
73
- .catch(function(err) {
74
- log.error("Error in getThreadPictures", err);
75
- callback(err);
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 getThreadPictures(threadID, offset, limit, 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
+ thread_id: threadID,
26
+ offset: offset,
27
+ limit: limit
28
+ };
29
+
30
+ defaultFuncs
31
+ .post(
32
+ "https://www.facebook.com/ajax/messaging/attachments/sharedphotos.php",
33
+ ctx.jar,
34
+ form
35
+ )
36
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
37
+ .then(function(resData) {
38
+ if (resData.error) {
39
+ throw resData;
40
+ }
41
+ return Promise.all(
42
+ resData.payload.imagesData.map(function(image) {
43
+ form = {
44
+ thread_id: threadID,
45
+ image_id: image.fbid
46
+ };
47
+ return defaultFuncs
48
+ .post(
49
+ "https://www.facebook.com/ajax/messaging/attachments/sharedphotos.php",
50
+ ctx.jar,
51
+ form
52
+ )
53
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
54
+ .then(function(resData) {
55
+ if (resData.error) {
56
+ throw resData;
57
+ }
58
+ // the response is pretty messy
59
+ var queryThreadID =
60
+ resData.jsmods.require[0][3][1].query_metadata.query_path[0]
61
+ .message_thread;
62
+ var imageData =
63
+ resData.jsmods.require[0][3][1].query_results[queryThreadID]
64
+ .message_images.edges[0].node.image2;
65
+ return imageData;
66
+ });
67
+ })
68
+ );
69
+ })
70
+ .then(function(resData) {
71
+ callback(null, resData);
72
+ })
73
+ .catch(function(err) {
74
+ log.error("Error in getThreadPictures", err);
75
+ callback(err);
76
+ });
77
+ return returnPromise;
78
+ };
79
+ };
@@ -1,66 +1,66 @@
1
- "use strict";
2
-
3
- var utils = require("../utils");
4
- var log = require("npmlog");
5
-
6
- function formatData(data) {
7
- return {
8
- userID: utils.formatID(data.uid.toString()),
9
- photoUrl: data.photo,
10
- indexRank: data.index_rank,
11
- name: data.text,
12
- isVerified: data.is_verified,
13
- profileUrl: data.path,
14
- category: data.category,
15
- score: data.score,
16
- type: data.type
17
- };
18
- }
19
-
20
- module.exports = function(defaultFuncs, api, ctx) {
21
- return function getUserID(name, callback) {
22
- var resolveFunc = function(){};
23
- var rejectFunc = function(){};
24
- var returnPromise = new Promise(function (resolve, reject) {
25
- resolveFunc = resolve;
26
- rejectFunc = reject;
27
- });
28
-
29
- if (!callback) {
30
- callback = function (err, friendList) {
31
- if (err) {
32
- return rejectFunc(err);
33
- }
34
- resolveFunc(friendList);
35
- };
36
- }
37
-
38
- var form = {
39
- value: name.toLowerCase(),
40
- viewer: ctx.userID,
41
- rsp: "search",
42
- context: "search",
43
- path: "/home.php",
44
- request_id: utils.getGUID()
45
- };
46
-
47
- defaultFuncs
48
- .get("https://www.facebook.com/ajax/typeahead/search.php", ctx.jar, form)
49
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
50
- .then(function(resData) {
51
- if (resData.error) {
52
- throw resData;
53
- }
54
-
55
- var data = resData.payload.entries;
56
-
57
- callback(null, data.map(formatData));
58
- })
59
- .catch(function(err) {
60
- log.error("getUserID", err);
61
- return callback(err);
62
- });
63
-
64
- return returnPromise;
65
- };
66
- };
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+
6
+ function formatData(data) {
7
+ return {
8
+ userID: utils.formatID(data.uid.toString()),
9
+ photoUrl: data.photo,
10
+ indexRank: data.index_rank,
11
+ name: data.text,
12
+ isVerified: data.is_verified,
13
+ profileUrl: data.path,
14
+ category: data.category,
15
+ score: data.score,
16
+ type: data.type
17
+ };
18
+ }
19
+
20
+ module.exports = function(defaultFuncs, api, ctx) {
21
+ return function getUserID(name, callback) {
22
+ var resolveFunc = function(){};
23
+ var rejectFunc = function(){};
24
+ var returnPromise = new Promise(function (resolve, reject) {
25
+ resolveFunc = resolve;
26
+ rejectFunc = reject;
27
+ });
28
+
29
+ if (!callback) {
30
+ callback = function (err, friendList) {
31
+ if (err) {
32
+ return rejectFunc(err);
33
+ }
34
+ resolveFunc(friendList);
35
+ };
36
+ }
37
+
38
+ var form = {
39
+ value: name.toLowerCase(),
40
+ viewer: ctx.userID,
41
+ rsp: "search",
42
+ context: "search",
43
+ path: "/home.php",
44
+ request_id: utils.getGUID()
45
+ };
46
+
47
+ defaultFuncs
48
+ .get("https://www.facebook.com/ajax/typeahead/search.php", ctx.jar, form)
49
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
50
+ .then(function(resData) {
51
+ if (resData.error) {
52
+ throw resData;
53
+ }
54
+
55
+ var data = resData.payload.entries;
56
+
57
+ callback(null, data.map(formatData));
58
+ })
59
+ .catch(function(err) {
60
+ log.error("getUserID", err);
61
+ return callback(err);
62
+ });
63
+
64
+ return returnPromise;
65
+ };
66
+ };
@@ -1,72 +1,72 @@
1
- "use strict";
2
-
3
- var utils = require("../utils");
4
- var log = require("npmlog");
5
-
6
- function formatData(data) {
7
- var retObj = {};
8
-
9
- for (var prop in data) {
10
- // eslint-disable-next-line no-prototype-builtins
11
- if (data.hasOwnProperty(prop)) {
12
- var innerObj = data[prop];
13
- retObj[prop] = {
14
- name: innerObj.name,
15
- firstName: innerObj.firstName,
16
- vanity: innerObj.vanity,
17
- thumbSrc: innerObj.thumbSrc,
18
- profileUrl: innerObj.uri,
19
- gender: innerObj.gender,
20
- type: innerObj.type,
21
- isFriend: innerObj.is_friend,
22
- isBirthday: !!innerObj.is_birthday
23
- };
24
- }
25
- }
26
-
27
- return retObj;
28
- }
29
-
30
- module.exports = function(defaultFuncs, api, ctx) {
31
- return function getUserInfo(id, callback) {
32
- var resolveFunc = function(){};
33
- var rejectFunc = function(){};
34
- var returnPromise = new Promise(function (resolve, reject) {
35
- resolveFunc = resolve;
36
- rejectFunc = reject;
37
- });
38
-
39
- if (!callback) {
40
- callback = function (err, friendList) {
41
- if (err) {
42
- return rejectFunc(err);
43
- }
44
- resolveFunc(friendList);
45
- };
46
- }
47
-
48
- if (utils.getType(id) !== "Array") {
49
- id = [id];
50
- }
51
-
52
- var form = {};
53
- id.map(function(v, i) {
54
- form["ids[" + i + "]"] = v;
55
- });
56
- defaultFuncs
57
- .post("https://www.facebook.com/chat/user_info/", ctx.jar, form)
58
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
59
- .then(function(resData) {
60
- if (resData.error) {
61
- throw resData;
62
- }
63
- return callback(null, formatData(resData.payload.profiles));
64
- })
65
- .catch(function(err) {
66
- log.error("getUserInfo", err);
67
- return callback(err);
68
- });
69
-
70
- return returnPromise;
71
- };
72
- };
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+
6
+ function formatData(data) {
7
+ var retObj = {};
8
+
9
+ for (var prop in data) {
10
+ // eslint-disable-next-line no-prototype-builtins
11
+ if (data.hasOwnProperty(prop)) {
12
+ var innerObj = data[prop];
13
+ retObj[prop] = {
14
+ name: innerObj.name,
15
+ firstName: innerObj.firstName,
16
+ vanity: innerObj.vanity,
17
+ thumbSrc: innerObj.thumbSrc,
18
+ profileUrl: innerObj.uri,
19
+ gender: innerObj.gender,
20
+ type: innerObj.type,
21
+ isFriend: innerObj.is_friend,
22
+ isBirthday: !!innerObj.is_birthday
23
+ };
24
+ }
25
+ }
26
+
27
+ return retObj;
28
+ }
29
+
30
+ module.exports = function(defaultFuncs, api, ctx) {
31
+ return function getUserInfo(id, callback) {
32
+ var resolveFunc = function(){};
33
+ var rejectFunc = function(){};
34
+ var returnPromise = new Promise(function (resolve, reject) {
35
+ resolveFunc = resolve;
36
+ rejectFunc = reject;
37
+ });
38
+
39
+ if (!callback) {
40
+ callback = function (err, friendList) {
41
+ if (err) {
42
+ return rejectFunc(err);
43
+ }
44
+ resolveFunc(friendList);
45
+ };
46
+ }
47
+
48
+ if (utils.getType(id) !== "Array") {
49
+ id = [id];
50
+ }
51
+
52
+ var form = {};
53
+ id.map(function(v, i) {
54
+ form["ids[" + i + "]"] = v;
55
+ });
56
+ defaultFuncs
57
+ .post("https://www.facebook.com/chat/user_info/", ctx.jar, form)
58
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
59
+ .then(function(resData) {
60
+ if (resData.error) {
61
+ throw resData;
62
+ }
63
+ return callback(null, formatData(resData.payload.profiles));
64
+ })
65
+ .catch(function(err) {
66
+ log.error("getUserInfo", err);
67
+ return callback(err);
68
+ });
69
+
70
+ return returnPromise;
71
+ };
72
+ };