alicezetion 1.6.6 → 1.6.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 +804 -381
  4. package/leiamnash/addExternalModule.js +19 -19
  5. package/leiamnash/addUserToGroup.js +113 -113
  6. package/leiamnash/changeAdminStatus.js +79 -79
  7. package/leiamnash/changeApprovalMode.js +80 -0
  8. package/leiamnash/changeArchivedStatus.js +55 -55
  9. package/leiamnash/changeBio.js +77 -77
  10. package/leiamnash/changeBlockedStatus.js +47 -47
  11. package/leiamnash/changeGroupImage.js +129 -129
  12. package/leiamnash/changeNickname.js +59 -59
  13. package/leiamnash/changeThreadColor.js +71 -71
  14. package/leiamnash/changeThreadEmoji.js +55 -55
  15. package/leiamnash/chat.js +447 -459
  16. package/leiamnash/createNewGroup.js +86 -86
  17. package/leiamnash/createPoll.js +71 -71
  18. package/leiamnash/deleteMessage.js +56 -56
  19. package/leiamnash/deleteThread.js +56 -56
  20. package/leiamnash/forwardAttachment.js +60 -60
  21. package/leiamnash/getCurrentUserID.js +7 -7
  22. package/leiamnash/getEmojiUrl.js +29 -29
  23. package/leiamnash/getFriendsList.js +84 -84
  24. package/leiamnash/getThreadHistory.js +645 -645
  25. package/leiamnash/getThreadHistoryDeprecated.js +93 -93
  26. package/leiamnash/getThreadInfo.js +212 -206
  27. package/leiamnash/getThreadInfoDeprecated.js +80 -80
  28. package/leiamnash/getThreadList.js +238 -238
  29. package/leiamnash/getThreadListDeprecated.js +75 -75
  30. package/leiamnash/getThreadPictures.js +79 -79
  31. package/leiamnash/getUserID.js +66 -66
  32. package/leiamnash/getUserInfo.js +72 -72
  33. package/leiamnash/handleFriendRequest.js +61 -61
  34. package/leiamnash/handleMessageRequest.js +65 -65
  35. package/leiamnash/httpGet.js +52 -52
  36. package/leiamnash/httpPost.js +52 -52
  37. package/leiamnash/listenMqtt.js +1129 -789
  38. package/leiamnash/logout.js +75 -75
  39. package/leiamnash/markAsDelivered.js +58 -58
  40. package/leiamnash/markAsRead.js +80 -80
  41. package/leiamnash/markAsReadAll.js +49 -49
  42. package/leiamnash/markAsSeen.js +59 -59
  43. package/leiamnash/muteThread.js +52 -52
  44. package/leiamnash/removeUserFromGroup.js +79 -79
  45. package/leiamnash/resolvePhotoUrl.js +45 -45
  46. package/leiamnash/searchForThread.js +53 -53
  47. package/leiamnash/sendTypingIndicator.js +103 -103
  48. package/leiamnash/setMessageReaction.js +117 -117
  49. package/leiamnash/setPostReaction.js +76 -76
  50. package/leiamnash/setTitle.js +86 -86
  51. package/leiamnash/threadColors.js +57 -57
  52. package/leiamnash/unfriend.js +52 -52
  53. package/leiamnash/unsendMessage.js +49 -49
  54. package/package.json +72 -72
  55. package/replit.nix +3 -0
  56. package/utils.js +196 -71
  57. package/leiamnash/listen.js +0 -553
@@ -1,19 +1,19 @@
1
- "use strict";
2
-
3
- const utils = require("../utils");
4
-
5
- module.exports = function(defaultFuncs, api, ctx) {
6
- return function addExternalModule(moduleObj) {
7
- if (utils.getType(moduleObj) == "Object") {
8
- for (let apiName in moduleObj) {
9
- if (utils.getType(moduleObj[apiName]) == "Function") {
10
- api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
11
- } else {
12
- throw new Error(`Item "${apiName}" in moduleObj must be a function, not ${utils.getType(moduleObj[apiName])}!`);
13
- }
14
- }
15
- } else {
16
- throw new Error(`moduleObj must be an object, not ${utils.getType(moduleObj)}!`);
17
- }
18
- };
19
- };
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+
5
+ module.exports = function(defaultFuncs, api, ctx) {
6
+ return function addExternalModule(moduleObj) {
7
+ if (utils.getType(moduleObj) == "Object") {
8
+ for (let apiName in moduleObj) {
9
+ if (utils.getType(moduleObj[apiName]) == "Function") {
10
+ api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
11
+ } else {
12
+ throw new Error(`Item "${apiName}" in moduleObj must be a function, not ${utils.getType(moduleObj[apiName])}!`);
13
+ }
14
+ }
15
+ } else {
16
+ throw new Error(`moduleObj must be an object, not ${utils.getType(moduleObj)}!`);
17
+ }
18
+ };
19
+ };
@@ -1,113 +1,113 @@
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 addUserToGroup(userID, threadID, 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 (
16
- !callback &&
17
- (utils.getType(threadID) === "Function" ||
18
- utils.getType(threadID) === "AsyncFunction")
19
- ) {
20
- throw { error: "please pass a threadID as a second argument." };
21
- }
22
-
23
- if (!callback) {
24
- callback = function(err) {
25
- if (err) {
26
- return rejectFunc(err);
27
- }
28
- resolveFunc();
29
- };
30
- }
31
-
32
- if (
33
- utils.getType(threadID) !== "Number" &&
34
- utils.getType(threadID) !== "String"
35
- ) {
36
- throw {
37
- error:
38
- "ThreadID should be of type Number or String and not " +
39
- utils.getType(threadID) +
40
- "."
41
- };
42
- }
43
-
44
- if (utils.getType(userID) !== "Array") {
45
- userID = [userID];
46
- }
47
-
48
- var messageAndOTID = utils.generateOfflineThreadingID();
49
- var form = {
50
- client: "mercury",
51
- action_type: "ma-type:log-message",
52
- author: "fbid:" + ctx.userID,
53
- thread_id: "",
54
- timestamp: Date.now(),
55
- timestamp_absolute: "Today",
56
- timestamp_relative: utils.generateTimestampRelative(),
57
- timestamp_time_passed: "0",
58
- is_unread: false,
59
- is_cleared: false,
60
- is_forward: false,
61
- is_filtered_content: false,
62
- is_filtered_content_bh: false,
63
- is_filtered_content_account: false,
64
- is_spoof_warning: false,
65
- source: "source:chat:web",
66
- "source_tags[0]": "source:chat",
67
- log_message_type: "log:subscribe",
68
- status: "0",
69
- offline_threading_id: messageAndOTID,
70
- message_id: messageAndOTID,
71
- threading_id: utils.generateThreadingID(ctx.clientID),
72
- manual_retry_cnt: "0",
73
- thread_fbid: threadID
74
- };
75
-
76
- for (var i = 0; i < userID.length; i++) {
77
- if (
78
- utils.getType(userID[i]) !== "Number" &&
79
- utils.getType(userID[i]) !== "String"
80
- ) {
81
- throw {
82
- error:
83
- "Elements of userID should be of type Number or String and not " +
84
- utils.getType(userID[i]) +
85
- "."
86
- };
87
- }
88
-
89
- form["log_message_data[added_participants][" + i + "]"] =
90
- "fbid:" + userID[i];
91
- }
92
-
93
- defaultFuncs
94
- .post("https://www.facebook.com/messaging/send/", ctx.jar, form)
95
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
96
- .then(function(resData) {
97
- if (!resData) {
98
- throw { error: "Add to group failed." };
99
- }
100
- if (resData.error) {
101
- throw resData;
102
- }
103
-
104
- return callback();
105
- })
106
- .catch(function(err) {
107
- log.error("addUserToGroup", err);
108
- return callback(err);
109
- });
110
-
111
- return returnPromise;
112
- };
113
- };
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 addUserToGroup(userID, threadID, 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 (
16
+ !callback &&
17
+ (utils.getType(threadID) === "Function" ||
18
+ utils.getType(threadID) === "AsyncFunction")
19
+ ) {
20
+ throw { error: "please pass a threadID as a second argument." };
21
+ }
22
+
23
+ if (!callback) {
24
+ callback = function(err) {
25
+ if (err) {
26
+ return rejectFunc(err);
27
+ }
28
+ resolveFunc();
29
+ };
30
+ }
31
+
32
+ if (
33
+ utils.getType(threadID) !== "Number" &&
34
+ utils.getType(threadID) !== "String"
35
+ ) {
36
+ throw {
37
+ error:
38
+ "ThreadID should be of type Number or String and not " +
39
+ utils.getType(threadID) +
40
+ "."
41
+ };
42
+ }
43
+
44
+ if (utils.getType(userID) !== "Array") {
45
+ userID = [userID];
46
+ }
47
+
48
+ var messageAndOTID = utils.generateOfflineThreadingID();
49
+ var form = {
50
+ client: "mercury",
51
+ action_type: "ma-type:log-message",
52
+ author: "fbid:" + ctx.userID,
53
+ thread_id: "",
54
+ timestamp: Date.now(),
55
+ timestamp_absolute: "Today",
56
+ timestamp_relative: utils.generateTimestampRelative(),
57
+ timestamp_time_passed: "0",
58
+ is_unread: false,
59
+ is_cleared: false,
60
+ is_forward: false,
61
+ is_filtered_content: false,
62
+ is_filtered_content_bh: false,
63
+ is_filtered_content_account: false,
64
+ is_spoof_warning: false,
65
+ source: "source:chat:web",
66
+ "source_tags[0]": "source:chat",
67
+ log_message_type: "log:subscribe",
68
+ status: "0",
69
+ offline_threading_id: messageAndOTID,
70
+ message_id: messageAndOTID,
71
+ threading_id: utils.generateThreadingID(ctx.clientID),
72
+ manual_retry_cnt: "0",
73
+ thread_fbid: threadID
74
+ };
75
+
76
+ for (var i = 0; i < userID.length; i++) {
77
+ if (
78
+ utils.getType(userID[i]) !== "Number" &&
79
+ utils.getType(userID[i]) !== "String"
80
+ ) {
81
+ throw {
82
+ error:
83
+ "Elements of userID should be of type Number or String and not " +
84
+ utils.getType(userID[i]) +
85
+ "."
86
+ };
87
+ }
88
+
89
+ form["log_message_data[added_participants][" + i + "]"] =
90
+ "fbid:" + userID[i];
91
+ }
92
+
93
+ defaultFuncs
94
+ .post("https://www.facebook.com/messaging/send/", ctx.jar, form)
95
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
96
+ .then(function(resData) {
97
+ if (!resData) {
98
+ throw { error: "Add to group failed." };
99
+ }
100
+ if (resData.error) {
101
+ throw resData;
102
+ }
103
+
104
+ return callback();
105
+ })
106
+ .catch(function(err) {
107
+ log.error("addUserToGroup", err);
108
+ return callback(err);
109
+ });
110
+
111
+ return returnPromise;
112
+ };
113
+ };
@@ -1,79 +1,79 @@
1
- "use strict";
2
-
3
- const utils = require("../utils");
4
- const log = require("npmlog");
5
-
6
- module.exports = function(defaultFuncs, api, ctx) {
7
- return function changeAdminStatus(threadID, adminIDs, adminStatus, callback) {
8
- if (utils.getType(threadID) !== "String") {
9
- throw {error: "changeAdminStatus: threadID must be a string"};
10
- }
11
-
12
- if (utils.getType(adminIDs) === "String") {
13
- adminIDs = [adminIDs];
14
- }
15
-
16
- if (utils.getType(adminIDs) !== "Array") {
17
- throw {error: "changeAdminStatus: adminIDs must be an array or string"};
18
- }
19
-
20
- if (utils.getType(adminStatus) !== "Boolean") {
21
- throw {error: "changeAdminStatus: adminStatus must be a string"};
22
- }
23
-
24
- var resolveFunc = function(){};
25
- var rejectFunc = function(){};
26
- var returnPromise = new Promise(function (resolve, reject) {
27
- resolveFunc = resolve;
28
- rejectFunc = reject;
29
- });
30
-
31
- if (!callback) {
32
- callback = function (err) {
33
- if (err) {
34
- return rejectFunc(err);
35
- }
36
- resolveFunc();
37
- };
38
- }
39
-
40
- if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
41
- throw {error: "changeAdminStatus: callback is not a function"};
42
- }
43
-
44
- let form = {
45
- "thread_fbid": threadID,
46
- };
47
-
48
- let i = 0;
49
- for (let u of adminIDs) {
50
- form[`admin_ids[${i++}]`] = u;
51
- }
52
- form["add"] = adminStatus;
53
-
54
- defaultFuncs
55
- .post("https://www.facebook.com/messaging/save_admins/?dpr=1", ctx.jar, form)
56
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
57
- .then(function(resData) {
58
- if (resData.error) {
59
- switch (resData.error) {
60
- case 1976004:
61
- throw { error: "Cannot alter admin status: you are not an admin.", rawResponse: resData };
62
- case 1357031:
63
- throw { error: "Cannot alter admin status: this thread is not a group chat.", rawResponse: resData };
64
- default:
65
- throw { error: "Cannot alter admin status: unknown error.", rawResponse: resData };
66
- }
67
- }
68
-
69
- callback();
70
- })
71
- .catch(function(err) {
72
- log.error("changeAdminStatus", err);
73
- return callback(err);
74
- });
75
-
76
- return returnPromise;
77
- };
78
- };
79
-
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ const log = require("npmlog");
5
+
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
+ return function changeAdminStatus(threadID, adminIDs, adminStatus, callback) {
8
+ if (utils.getType(threadID) !== "String") {
9
+ throw {error: "changeAdminStatus: threadID must be a string"};
10
+ }
11
+
12
+ if (utils.getType(adminIDs) === "String") {
13
+ adminIDs = [adminIDs];
14
+ }
15
+
16
+ if (utils.getType(adminIDs) !== "Array") {
17
+ throw {error: "changeAdminStatus: adminIDs must be an array or string"};
18
+ }
19
+
20
+ if (utils.getType(adminStatus) !== "Boolean") {
21
+ throw {error: "changeAdminStatus: adminStatus must be a string"};
22
+ }
23
+
24
+ var resolveFunc = function(){};
25
+ var rejectFunc = function(){};
26
+ var returnPromise = new Promise(function (resolve, reject) {
27
+ resolveFunc = resolve;
28
+ rejectFunc = reject;
29
+ });
30
+
31
+ if (!callback) {
32
+ callback = function (err) {
33
+ if (err) {
34
+ return rejectFunc(err);
35
+ }
36
+ resolveFunc();
37
+ };
38
+ }
39
+
40
+ if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
41
+ throw {error: "changeAdminStatus: callback is not a function"};
42
+ }
43
+
44
+ let form = {
45
+ "thread_fbid": threadID,
46
+ };
47
+
48
+ let i = 0;
49
+ for (let u of adminIDs) {
50
+ form[`admin_ids[${i++}]`] = u;
51
+ }
52
+ form["add"] = adminStatus;
53
+
54
+ defaultFuncs
55
+ .post("https://www.facebook.com/messaging/save_admins/?dpr=1", ctx.jar, form)
56
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
57
+ .then(function(resData) {
58
+ if (resData.error) {
59
+ switch (resData.error) {
60
+ case 1976004:
61
+ throw { error: "Cannot alter admin status: you are not an admin.", rawResponse: resData };
62
+ case 1357031:
63
+ throw { error: "Cannot alter admin status: this thread is not a group chat.", rawResponse: resData };
64
+ default:
65
+ throw { error: "Cannot alter admin status: unknown error.", rawResponse: resData };
66
+ }
67
+ }
68
+
69
+ callback();
70
+ })
71
+ .catch(function(err) {
72
+ log.error("changeAdminStatus", err);
73
+ return callback(err);
74
+ });
75
+
76
+ return returnPromise;
77
+ };
78
+ };
79
+
@@ -0,0 +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 function changeApprovalMode(approval_mode, threadID, callback) {
8
+ if (utils.getType(threadID) !== "String") {
9
+ throw { error: "changeApprovalMode: threadID must be a string" };
10
+ }
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) {
21
+ if (err) {
22
+ return rejectFunc(err);
23
+ }
24
+ resolveFunc(err);
25
+ };
26
+ }
27
+
28
+ if (
29
+ utils.getType(callback) !== "Function" &&
30
+ utils.getType(callback) !== "AsyncFunction"
31
+ ) {
32
+ throw { error: "changeApprovalMode: callback is not a function" };
33
+ }
34
+
35
+ approval_mode = parseInt(approval_mode);
36
+
37
+ if (approval_mode !== 0 && approval_mode !== 1) {
38
+ throw { error: "changeApprovalMode: approval_mode must be 0 or 1" };
39
+ }
40
+
41
+ var form = {
42
+ thread_fbid: threadID,
43
+ set_mode: approval_mode,
44
+ };
45
+
46
+ defaultFuncs
47
+ .post(
48
+ "https://www.facebook.com/messaging/set_approval_mode/?dpr=1",
49
+ ctx.jar,
50
+ form
51
+ )
52
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
53
+ .then(function(resData) {
54
+ if (resData.error) {
55
+ switch (resData.error) {
56
+ case 1357031:
57
+ throw {
58
+ error:
59
+ "Cannot alter approval mode: this thread is not a group chat or you are not an admin.",
60
+ rawResponse: resData,
61
+ };
62
+ default:
63
+ throw {
64
+ error:
65
+ "Cannot alter approval mode: unknown error.",
66
+ rawResponse: resData,
67
+ };
68
+ }
69
+ }
70
+
71
+ return callback();
72
+ })
73
+ .catch(function(err) {
74
+ log.error("changeApprovalMode", err);
75
+ return callback(err);
76
+ });
77
+
78
+ return returnPromise;
79
+ };
80
+ };
@@ -1,55 +1,55 @@
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 changeArchivedStatus(threadOrThreads, archive, 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
- var form = {};
25
-
26
- if (utils.getType(threadOrThreads) === "Array") {
27
- for (var i = 0; i < threadOrThreads.length; i++) {
28
- form["ids[" + threadOrThreads[i] + "]"] = archive;
29
- }
30
- } else {
31
- form["ids[" + threadOrThreads + "]"] = archive;
32
- }
33
-
34
- defaultFuncs
35
- .post(
36
- "https://www.facebook.com/ajax/mercury/change_archived_status.php",
37
- ctx.jar,
38
- form
39
- )
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("changeArchivedStatus", err);
50
- return callback(err);
51
- });
52
-
53
- return returnPromise;
54
- };
55
- };
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 changeArchivedStatus(threadOrThreads, archive, 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
+ var form = {};
25
+
26
+ if (utils.getType(threadOrThreads) === "Array") {
27
+ for (var i = 0; i < threadOrThreads.length; i++) {
28
+ form["ids[" + threadOrThreads[i] + "]"] = archive;
29
+ }
30
+ } else {
31
+ form["ids[" + threadOrThreads + "]"] = archive;
32
+ }
33
+
34
+ defaultFuncs
35
+ .post(
36
+ "https://www.facebook.com/ajax/mercury/change_archived_status.php",
37
+ ctx.jar,
38
+ form
39
+ )
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("changeArchivedStatus", err);
50
+ return callback(err);
51
+ });
52
+
53
+ return returnPromise;
54
+ };
55
+ };