alicezetion 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -1
  2. package/.cache/replit/nix/env.json +1 -1
  3. package/.travis.yml +6 -0
  4. package/index.js +532 -604
  5. package/package.json +78 -75
  6. package/replit.nix +5 -0
  7. package/src/addExternalModule.js +15 -0
  8. package/{alice → src}/addUserToGroup.js +77 -113
  9. package/src/changeAdminStatus.js +47 -0
  10. package/src/changeArchivedStatus.js +41 -0
  11. package/{alice → src}/changeBio.js +64 -77
  12. package/{alice → src}/changeBlockedStatus.js +36 -47
  13. package/{alice → src}/changeGroupImage.js +105 -129
  14. package/src/changeNickname.js +43 -0
  15. package/{alice → src}/changeThreadColor.js +61 -71
  16. package/src/changeThreadEmoji.js +41 -0
  17. package/src/chat.js +315 -0
  18. package/{alice → src}/createNewGroup.js +70 -86
  19. package/{alice → src}/createPoll.js +59 -71
  20. package/src/deleteMessage.js +44 -0
  21. package/src/deleteThread.js +42 -0
  22. package/src/forwardAttachment.js +47 -0
  23. package/src/forwardMessage.js +0 -0
  24. package/{alice → src}/getCurrentUserID.js +7 -7
  25. package/{alice → src}/getEmojiUrl.js +27 -29
  26. package/{alice → src}/getFriendsList.js +73 -84
  27. package/{alice → src}/getThreadHistory.js +537 -645
  28. package/src/getThreadHistoryDeprecated.js +71 -0
  29. package/{alice → src}/getThreadInfo.js +171 -206
  30. package/src/getThreadInfoDeprecated.js +56 -0
  31. package/{alice → src}/getThreadList.js +213 -238
  32. package/src/getThreadListDeprecated.js +46 -0
  33. package/src/getThreadPictures.js +59 -0
  34. package/{alice → src}/getUserID.js +61 -66
  35. package/{alice → src}/getUserInfo.js +66 -72
  36. package/src/handleFriendRequest.js +46 -0
  37. package/src/handleMessageRequest.js +47 -0
  38. package/{alice → src}/httpGet.js +47 -52
  39. package/{alice → src}/httpPost.js +47 -52
  40. package/src/listen.js +553 -0
  41. package/src/listenMqtt-Test.js +687 -0
  42. package/src/listenMqtt.js +677 -0
  43. package/{alice → src}/logout.js +68 -75
  44. package/{alice → src}/markAsDelivered.js +47 -58
  45. package/{alice → src}/markAsRead.js +70 -80
  46. package/{alice/seen.js → src/markAsReadAll.js} +39 -49
  47. package/{alice → src}/markAsSeen.js +48 -59
  48. package/{alice → src}/muteThread.js +45 -52
  49. package/src/removeUserFromGroup.js +45 -0
  50. package/{alice → src}/resolvePhotoUrl.js +36 -45
  51. package/src/searchForThread.js +42 -0
  52. package/{alice → src}/sendTypingIndicator.js +70 -103
  53. package/{alice/react.js → src/setMessageReaction.js} +103 -117
  54. package/{alice → src}/setPostReaction.js +63 -76
  55. package/{alice → src}/setTitle.js +70 -86
  56. package/src/threadColors.js +41 -0
  57. package/{alice → src}/unfriend.js +42 -52
  58. package/{alice → src}/unsendMessage.js +39 -49
  59. package/utils.js +1190 -1357
  60. package/alice/addExternalModule.js +0 -19
  61. package/alice/changeAdminStatus.js +0 -79
  62. package/alice/changeArchivedStatus.js +0 -55
  63. package/alice/changeNickname.js +0 -59
  64. package/alice/changeThreadEmoji.js +0 -55
  65. package/alice/chat.js +0 -459
  66. package/alice/deleteMessage.js +0 -56
  67. package/alice/deleteThread.js +0 -56
  68. package/alice/forwardAttachment.js +0 -60
  69. package/alice/getThreadHistoryDeprecated.js +0 -93
  70. package/alice/getThreadInfoDeprecated.js +0 -80
  71. package/alice/getThreadListDeprecated.js +0 -75
  72. package/alice/getThreadPictures.js +0 -79
  73. package/alice/handleFriendRequest.js +0 -61
  74. package/alice/handleMessageRequest.js +0 -65
  75. package/alice/listenMqtt.js +0 -789
  76. package/alice/removeUserFromGroup.js +0 -79
  77. package/alice/searchForThread.js +0 -53
  78. package/alice/threadColors.js +0 -57
  79. package/test/data/shareAttach.js +0 -146
  80. package/test/data/something.mov +0 -0
  81. package/test/data/test.png +0 -0
  82. package/test/data/test.txt +0 -7
  83. package/test/example-config.json +0 -18
  84. package/test/test-page.js +0 -140
  85. package/test/test.js +0 -385
@@ -1,66 +1,61 @@
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, data) {
31
+ if (err) return rejectFunc(err);
32
+ resolveFunc(data);
33
+ };
34
+ }
35
+
36
+ var form = {
37
+ value: name.toLowerCase(),
38
+ viewer: ctx.userID,
39
+ rsp: "search",
40
+ context: "search",
41
+ path: "/home.php",
42
+ request_id: utils.getGUID()
43
+ };
44
+
45
+ defaultFuncs
46
+ .get("https://www.facebook.com/ajax/typeahead/search.php", ctx.jar, form)
47
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
48
+ .then(function (resData) {
49
+ if (resData.error) throw resData;
50
+
51
+ var data = resData.payload.entries;
52
+ callback(null, data.map(formatData));
53
+ })
54
+ .catch(function (err) {
55
+ log.error("getUserID", err);
56
+ return callback(err);
57
+ });
58
+
59
+ return returnPromise;
60
+ };
61
+ };
@@ -1,72 +1,66 @@
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, userInfo) {
41
+ if (err) return rejectFunc(err);
42
+ resolveFunc(userInfo);
43
+ };
44
+ }
45
+
46
+ if (utils.getType(id) !== "Array") id = [id];
47
+
48
+ var form = {};
49
+ id.map(function (v, i) {
50
+ form["ids[" + i + "]"] = v;
51
+ });
52
+ defaultFuncs
53
+ .post("https://www.facebook.com/chat/user_info/", ctx.jar, form)
54
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
55
+ .then(function (resData) {
56
+ if (resData.error) throw resData;
57
+ return callback(null, formatData(resData.payload.profiles));
58
+ })
59
+ .catch(function (err) {
60
+ log.error("getUserInfo", "Can't get user info");
61
+ return callback(err);
62
+ });
63
+
64
+ return returnPromise;
65
+ };
66
+ };
@@ -0,0 +1,46 @@
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 handleFriendRequest(userID, accept, callback) {
8
+ if (utils.getType(accept) !== "Boolean") throw { error: "Please pass a boolean as a second argument." };
9
+
10
+ var resolveFunc = function() {};
11
+ var rejectFunc = function() {};
12
+ var returnPromise = new Promise(function(resolve, reject) {
13
+ resolveFunc = resolve;
14
+ rejectFunc = reject;
15
+ });
16
+
17
+ if (!callback) {
18
+ callback = function(err, data) {
19
+ if (err) return rejectFunc(err);
20
+ resolveFunc(data);
21
+ };
22
+ }
23
+
24
+ var form = {
25
+ viewer_id: userID,
26
+ "frefs[0]": "jwl",
27
+ floc: "friend_center_requests",
28
+ ref: "/reqs.php",
29
+ action: (accept ? "confirm" : "reject")
30
+ };
31
+
32
+ defaultFuncs
33
+ .post("https://www.facebook.com/requests/friends/ajax/", ctx.jar, form)
34
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
35
+ .then(function(resData) {
36
+ if (resData.payload.err) throw { err: resData.payload.err };
37
+ return callback();
38
+ })
39
+ .catch(function(err) {
40
+ log.error("handleFriendRequest", err);
41
+ return callback(err);
42
+ });
43
+
44
+ return returnPromise;
45
+ };
46
+ };
@@ -0,0 +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 handleMessageRequest(threadID, accept, callback) {
8
+ if (utils.getType(accept) !== "Boolean") throw { error: "Please pass a boolean as a second argument." };
9
+
10
+ var resolveFunc = function () { };
11
+ var rejectFunc = function () { };
12
+ var returnPromise = new Promise(function (resolve, reject) {
13
+ resolveFunc = resolve;
14
+ rejectFunc = reject;
15
+ });
16
+
17
+ if (!callback) {
18
+ callback = function (err, data) {
19
+ if (err) return rejectFunc(err);
20
+ resolveFunc(data);
21
+ };
22
+ }
23
+
24
+ var form = {
25
+ client: "mercury"
26
+ };
27
+
28
+ if (utils.getType(threadID) !== "Array") threadID = [threadID];
29
+
30
+ var messageBox = accept ? "inbox" : "other";
31
+ for (var i = 0; i < threadID.length; i++) form[messageBox + "[" + i + "]"] = threadID[i];
32
+
33
+ defaultFuncs
34
+ .post("https://www.facebook.com/ajax/mercury/move_thread.php", ctx.jar, form)
35
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
36
+ .then(function (resData) {
37
+ if (resData.error) throw resData;
38
+ return callback();
39
+ })
40
+ .catch(function (err) {
41
+ log.error("handleMessageRequest", err);
42
+ return callback(err);
43
+ });
44
+
45
+ return returnPromise;
46
+ };
47
+ };
@@ -1,52 +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 httpGet(url, form, callback, notAPI) {
8
- var resolveFunc = function(){};
9
- var rejectFunc = function(){};
10
-
11
- var returnPromise = new Promise(function (resolve, reject) {
12
- resolveFunc = resolve;
13
- rejectFunc = reject;
14
- });
15
-
16
- if (!callback && (utils.getType(form) == "Function" || utils.getType(form) == "AsyncFunction")) {
17
- callback = form;
18
- form = {};
19
- }
20
-
21
- form = form || {};
22
-
23
- callback = callback || function(err, data) {
24
- if (err) return rejectFunc(err);
25
- resolveFunc(data);
26
- };
27
-
28
- if (notAPI) {
29
- utils
30
- .get(url, ctx.jar, form, ctx.globalOptions)
31
- .then(function(resData) {
32
- callback(null, resData.body.toString());
33
- })
34
- .catch(function(err) {
35
- log.error("httpGet", err);
36
- return callback(err);
37
- });
38
- } else {
39
- defaultFuncs
40
- .get(url, ctx.jar, form)
41
- .then(function(resData) {
42
- callback(null, resData.body.toString());
43
- })
44
- .catch(function(err) {
45
- log.error("httpGet", err);
46
- return callback(err);
47
- });
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
+ return function httpGet(url, form, callback, notAPI) {
8
+ var resolveFunc = function () { };
9
+ var rejectFunc = function () { };
10
+
11
+ var returnPromise = new Promise(function (resolve, reject) {
12
+ resolveFunc = resolve;
13
+ rejectFunc = reject;
14
+ });
15
+
16
+ if (!callback && (utils.getType(form) == "Function" || utils.getType(form) == "AsyncFunction")) {
17
+ callback = form;
18
+ form = {};
19
+ }
20
+ form = form || {};
21
+
22
+ callback = callback || function (err, data) {
23
+ if (err) return rejectFunc(err);
24
+ resolveFunc(data);
25
+ };
26
+
27
+ if (notAPI) {
28
+ utils
29
+ .get(url, ctx.jar, form, ctx.globalOptions)
30
+ .then(resData => callback(null, resData.body.toString()))
31
+ .catch(function (err) {
32
+ log.error("httpGet", err);
33
+ return callback(err);
34
+ });
35
+ }
36
+ else {
37
+ defaultFuncs
38
+ .get(url, ctx.jar, form)
39
+ .then(resData => callback(null, resData.body.toString()))
40
+ .catch(function (err) {
41
+ log.error("httpGet", err);
42
+ return callback(err);
43
+ });
44
+ }
45
+ return returnPromise;
46
+ };
47
+ };
@@ -1,52 +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 httpGet(url, form, callback, notAPI) {
8
- var resolveFunc = function(){};
9
- var rejectFunc = function(){};
10
-
11
- var returnPromise = new Promise(function (resolve, reject) {
12
- resolveFunc = resolve;
13
- rejectFunc = reject;
14
- });
15
-
16
- if (!callback && (utils.getType(form) == "Function" || utils.getType(form) == "AsyncFunction")) {
17
- callback = form;
18
- form = {};
19
- }
20
-
21
- form = form || {};
22
-
23
- callback = callback || function(err, data) {
24
- if (err) return rejectFunc(err);
25
- resolveFunc(data);
26
- };
27
-
28
- if (notAPI) {
29
- utils
30
- .post(url, ctx.jar, form, ctx.globalOptions)
31
- .then(function(resData) {
32
- callback(null, resData.body.toString());
33
- })
34
- .catch(function(err) {
35
- log.error("httpPost", err);
36
- return callback(err);
37
- });
38
- } else {
39
- defaultFuncs
40
- .post(url, ctx.jar, form, {})
41
- .then(function(resData) {
42
- callback(null, resData.body.toString());
43
- })
44
- .catch(function(err) {
45
- log.error("httpPost", err);
46
- return callback(err);
47
- });
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
+ return function httpGet(url, form, callback, notAPI) {
8
+ var resolveFunc = function () { };
9
+ var rejectFunc = function () { };
10
+
11
+ var returnPromise = new Promise(function (resolve, reject) {
12
+ resolveFunc = resolve;
13
+ rejectFunc = reject;
14
+ });
15
+
16
+ if (!callback && (utils.getType(form) == "Function" || utils.getType(form) == "AsyncFunction")) {
17
+ callback = form;
18
+ form = {};
19
+ }
20
+ form = form || {};
21
+
22
+ callback = callback || function (err, data) {
23
+ if (err) return rejectFunc(err);
24
+ resolveFunc(data);
25
+ };
26
+
27
+ if (notAPI) {
28
+ utils
29
+ .post(url, ctx.jar, form, ctx.globalOptions)
30
+ .then(resData => callback(null, resData.body.toString()))
31
+ .catch(function (err) {
32
+ log.error("httpPost", err);
33
+ return callback(err);
34
+ });
35
+ }
36
+ else {
37
+ defaultFuncs
38
+ .post(url, ctx.jar, form, {})
39
+ .then(resData => callback(null, resData.body.toString()))
40
+ .catch(function (err) {
41
+ log.error("httpPost", err);
42
+ return callback(err);
43
+ });
44
+ }
45
+ return returnPromise;
46
+ };
47
+ };