alicezetion 1.5.6 → 1.5.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -1
  2. package/.cache/replit/nix/env.json +1 -1
  3. package/index.js +489 -526
  4. package/leiamnash/addExternalModule.js +15 -19
  5. package/leiamnash/addUserToGroup.js +77 -113
  6. package/leiamnash/changeAdminStatus.js +47 -79
  7. package/leiamnash/changeArchivedStatus.js +41 -55
  8. package/leiamnash/changeBio.js +64 -77
  9. package/leiamnash/changeBlockedStatus.js +36 -47
  10. package/leiamnash/changeGroupImage.js +105 -129
  11. package/leiamnash/changeNickname.js +43 -59
  12. package/leiamnash/changeThreadColor.js +61 -71
  13. package/leiamnash/changeThreadEmoji.js +41 -55
  14. package/leiamnash/chat.js +324 -459
  15. package/leiamnash/createNewGroup.js +70 -86
  16. package/leiamnash/createPoll.js +59 -71
  17. package/leiamnash/deleteMessage.js +44 -56
  18. package/leiamnash/deleteThread.js +42 -56
  19. package/leiamnash/forwardAttachment.js +47 -60
  20. package/leiamnash/forwardMessage.js +0 -0
  21. package/leiamnash/getCurrentUserID.js +7 -7
  22. package/leiamnash/getEmojiUrl.js +27 -29
  23. package/leiamnash/getFriendsList.js +73 -84
  24. package/leiamnash/getThreadHistory.js +537 -645
  25. package/leiamnash/getThreadHistoryDeprecated.js +71 -93
  26. package/leiamnash/getThreadInfo.js +171 -206
  27. package/leiamnash/getThreadInfoDeprecated.js +56 -80
  28. package/leiamnash/getThreadList.js +213 -238
  29. package/leiamnash/getThreadListDeprecated.js +46 -75
  30. package/leiamnash/getThreadPictures.js +59 -79
  31. package/leiamnash/getUserID.js +61 -66
  32. package/leiamnash/getUserInfo.js +66 -72
  33. package/leiamnash/handleFriendRequest.js +46 -61
  34. package/leiamnash/handleMessageRequest.js +47 -65
  35. package/leiamnash/httpGet.js +47 -52
  36. package/leiamnash/httpPost.js +47 -52
  37. package/leiamnash/listen.js +553 -0
  38. package/leiamnash/listenMqtt-Test.js +687 -0
  39. package/leiamnash/listenMqtt.js +685 -789
  40. package/leiamnash/logout.js +68 -75
  41. package/leiamnash/markAsDelivered.js +47 -58
  42. package/leiamnash/markAsRead.js +70 -80
  43. package/leiamnash/markAsReadAll.js +39 -49
  44. package/leiamnash/markAsSeen.js +48 -59
  45. package/leiamnash/muteThread.js +45 -52
  46. package/leiamnash/removeUserFromGroup.js +45 -79
  47. package/leiamnash/resolvePhotoUrl.js +36 -45
  48. package/leiamnash/searchForThread.js +42 -53
  49. package/leiamnash/sendTypingIndicator.js +70 -103
  50. package/leiamnash/setMessageReaction.js +103 -117
  51. package/leiamnash/setPostReaction.js +63 -76
  52. package/leiamnash/setTitle.js +70 -86
  53. package/leiamnash/threadColors.js +41 -57
  54. package/leiamnash/unfriend.js +42 -52
  55. package/leiamnash/unsendMessage.js +39 -49
  56. package/package.json +73 -71
  57. package/utils.js +1198 -1356
@@ -1,52 +1,45 @@
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, data) {
18
+ if (err) return rejectFunc(err);
19
+
20
+ resolveFunc(data);
21
+ };
22
+ }
23
+
24
+ var form = {
25
+ thread_fbid: threadID,
26
+ mute_settings: muteSeconds
27
+ };
28
+
29
+ defaultFuncs
30
+ .post("https://www.facebook.com/ajax/mercury/change_mute_thread.php", ctx.jar, form)
31
+ .then(utils.saveCookies(ctx.jar))
32
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
33
+ .then(function (resData) {
34
+ if (resData.error) throw resData;
35
+
36
+ return callback();
37
+ })
38
+ .catch(function (err) {
39
+ log.error("muteThread", err);
40
+ return callback(err);
41
+ });
42
+
43
+ return returnPromise;
44
+ };
45
+ };
@@ -1,79 +1,45 @@
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 removeUserFromGroup(userID, 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
- if (
16
- utils.getType(threadID) !== "Number" &&
17
- utils.getType(threadID) !== "String"
18
- ) {
19
- throw {
20
- error:
21
- "threadID should be of type Number or String and not " +
22
- utils.getType(threadID) +
23
- "."
24
- };
25
- }
26
- if (
27
- utils.getType(userID) !== "Number" &&
28
- utils.getType(userID) !== "String"
29
- ) {
30
- throw {
31
- error:
32
- "userID should be of type Number or String and not " +
33
- utils.getType(userID) +
34
- "."
35
- };
36
- }
37
-
38
- var resolveFunc = function(){};
39
- var rejectFunc = function(){};
40
- var returnPromise = new Promise(function (resolve, reject) {
41
- resolveFunc = resolve;
42
- rejectFunc = reject;
43
- });
44
-
45
- if (!callback) {
46
- callback = function (err, friendList) {
47
- if (err) {
48
- return rejectFunc(err);
49
- }
50
- resolveFunc(friendList);
51
- };
52
- }
53
-
54
- var form = {
55
- uid: userID,
56
- tid: threadID
57
- };
58
-
59
- defaultFuncs
60
- .post("https://www.facebook.com/chat/remove_participants", ctx.jar, form)
61
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
62
- .then(function(resData) {
63
- if (!resData) {
64
- throw { error: "Remove from group failed." };
65
- }
66
- if (resData.error) {
67
- throw resData;
68
- }
69
-
70
- return callback();
71
- })
72
- .catch(function(err) {
73
- log.error("removeUserFromGroup", err);
74
- return callback(err);
75
- });
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 removeUserFromGroup(userID, threadID, callback) {
8
+ if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
9
+ if (utils.getType(threadID) !== "Number" && utils.getType(threadID) !== "String") throw { error: "threadID should be of type Number or String and not " + utils.getType(threadID) + "." };
10
+ if (utils.getType(userID) !== "Number" && utils.getType(userID) !== "String") throw { error: "userID should be of type Number or String and not " + utils.getType(userID) + "." };
11
+
12
+ var resolveFunc = function () { };
13
+ var rejectFunc = function () { };
14
+ var returnPromise = new Promise(function (resolve, reject) {
15
+ resolveFunc = resolve;
16
+ rejectFunc = reject;
17
+ });
18
+
19
+ if (!callback) {
20
+ callback = function (err, data) {
21
+ if (err) return rejectFunc(err);
22
+ resolveFunc(data);
23
+ };
24
+ }
25
+
26
+ var form = {
27
+ uid: userID,
28
+ tid: threadID
29
+ };
30
+
31
+ defaultFuncs
32
+ .post("https://www.facebook.com/chat/remove_participants", ctx.jar, form)
33
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
34
+ .then(function (resData) {
35
+ if (!resData) throw { error: "Remove from group failed." };
36
+ if (resData.error) throw resData;
37
+ return callback();
38
+ })
39
+ .catch(function (err) {
40
+ log.error("removeUserFromGroup", Bailing out of trying to parse response");
41
+ return callback(err);
42
+ });
43
+ return returnPromise;
44
+ };
45
+ };
@@ -1,45 +1,36 @@
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 resolvePhotoUrl(photoID, 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
- defaultFuncs
25
- .get("https://www.facebook.com/mercury/attachments/photo", ctx.jar, {
26
- photo_id: photoID
27
- })
28
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
29
- .then(resData => {
30
- if (resData.error) {
31
- throw resData;
32
- }
33
-
34
- var photoUrl = resData.jsmods.require[0][3][0];
35
-
36
- return callback(null, photoUrl);
37
- })
38
- .catch(err => {
39
- log.error("resolvePhotoUrl", err);
40
- return callback(err);
41
- });
42
-
43
- return returnPromise;
44
- };
45
- };
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 resolvePhotoUrl(photoID, 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, data) {
17
+ if (err) return rejectFunc(err);
18
+ resolveFunc(data);
19
+ };
20
+ }
21
+
22
+ defaultFuncs
23
+ .get("https://www.facebook.com/mercury/attachments/photo", ctx.jar, { photo_id: photoID })
24
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
25
+ .then(resData => {
26
+ if (resData.error) throw resData;
27
+ var photoUrl = resData.jsmods.require[0][3][0];
28
+ return callback(null, photoUrl);
29
+ })
30
+ .catch(err => {
31
+ log.error("resolvePhotoUrl", err);
32
+ return callback(err);
33
+ });
34
+ return returnPromise;
35
+ };
36
+ };
@@ -1,53 +1,42 @@
1
- "use strict";
2
-
3
- var utils = require("../utils");
4
-
5
- module.exports = function(defaultFuncs, api, ctx) {
6
- return function searchForThread(name, callback) {
7
- var resolveFunc = function(){};
8
- var rejectFunc = function(){};
9
- var returnPromise = new Promise(function (resolve, reject) {
10
- resolveFunc = resolve;
11
- rejectFunc = reject;
12
- });
13
-
14
- if (!callback) {
15
- callback = function (err, friendList) {
16
- if (err) {
17
- return rejectFunc(err);
18
- }
19
- resolveFunc(friendList);
20
- };
21
- }
22
-
23
- var tmpForm = {
24
- client: "web_messenger",
25
- query: name,
26
- offset: 0,
27
- limit: 21,
28
- index: "fbid"
29
- };
30
-
31
- defaultFuncs
32
- .post(
33
- "https://www.facebook.com/ajax/mercury/search_threads.php",
34
- ctx.jar,
35
- tmpForm
36
- )
37
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
38
- .then(function(resData) {
39
- if (resData.error) {
40
- throw resData;
41
- }
42
- if (!resData.payload.mercury_payload.threads) {
43
- return callback({ error: "Could not find thread `" + name + "`." });
44
- }
45
- return callback(
46
- null,
47
- resData.payload.mercury_payload.threads.map(utils.formatThread)
48
- );
49
- });
50
-
51
- return returnPromise;
52
- };
53
- };
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+
5
+ module.exports = function (defaultFuncs, api, ctx) {
6
+ return function searchForThread(name, callback) {
7
+ var resolveFunc = function () { };
8
+ var rejectFunc = function () { };
9
+ var returnPromise = new Promise(function (resolve, reject) {
10
+ resolveFunc = resolve;
11
+ rejectFunc = reject;
12
+ });
13
+
14
+ if (!callback) {
15
+ callback = function (err, data) {
16
+ if (err) return rejectFunc(err);
17
+ resolveFunc(data);
18
+ };
19
+ }
20
+
21
+ var tmpForm = {
22
+ client: "web_messenger",
23
+ query: name,
24
+ offset: 0,
25
+ limit: 21,
26
+ index: "fbid"
27
+ };
28
+
29
+ defaultFuncs
30
+ .post("https://www.facebook.com/ajax/mercury/search_threads.php", ctx.jar, tmpForm)
31
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
32
+ .then(function (resData) {
33
+ if (resData.error) throw resData;
34
+ if (!resData.payload.mercury_payload.threads) return callback({ error: "Could not find thread `" + name + "`." });
35
+ return callback(
36
+ null,
37
+ resData.payload.mercury_payload.threads.map(utils.formatThread)
38
+ );
39
+ });
40
+ return returnPromise;
41
+ };
42
+ };
@@ -1,103 +1,70 @@
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) form.to = threadID;
19
+
20
+ defaultFuncs
21
+ .post("https://www.facebook.com/ajax/messaging/typ.php", ctx.jar, form)
22
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
23
+ .then(function (resData) {
24
+ if (resData.error) throw resData;
25
+ return callback();
26
+ })
27
+ .catch(function (err) {
28
+ log.error("sendTypingIndicator", err);
29
+ if (utils.getType(err) == "Object" && err.error === "Not logged in") ctx.loggedIn = false;
30
+ return callback(err);
31
+ });
32
+ }
33
+ else {
34
+ api.getUserInfo(threadID, function (err, res) {
35
+ if (err) return callback(err);
36
+ // If id is single person chat
37
+ if (Object.keys(res).length > 0) form.to = threadID;
38
+ defaultFuncs
39
+ .post("https://www.facebook.com/ajax/messaging/typ.php", ctx.jar, form)
40
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
41
+ .then(function (resData) {
42
+ if (resData.error) throw resData;
43
+ return callback();
44
+ })
45
+ .catch(function (err) {
46
+ log.error("sendTypingIndicator", err);
47
+ if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
48
+ return callback(err);
49
+ });
50
+ });
51
+ }
52
+ }
53
+
54
+ return function sendTypingIndicator(threadID, callback, isGroup) {
55
+ if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
56
+ if (callback) log.warn("sendTypingIndicator", "callback is not a function - ignoring.");
57
+ callback = () => { };
58
+ }
59
+
60
+ makeTypingIndicator(true, threadID, callback, isGroup);
61
+
62
+ return function end(cb) {
63
+ if (utils.getType(cb) !== "Function" && utils.getType(cb) !== "AsyncFunction") {
64
+ if (cb) log.warn("sendTypingIndicator", "callback is not a function - ignoring.");
65
+ cb = () => { };
66
+ }
67
+ makeTypingIndicator(false, threadID, cb, isGroup);
68
+ };
69
+ };
70
+ };