alicezetion 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) 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 +182 -495
  5. package/package.json +10 -8
  6. package/replit.nix +4 -6
  7. package/src/addExternalModule.js +15 -0
  8. package/{leiamnash → src}/addUserToGroup.js +16 -52
  9. package/src/changeAdminStatus.js +47 -0
  10. package/src/changeArchivedStatus.js +41 -0
  11. package/{leiamnash → src}/changeBio.js +6 -19
  12. package/{leiamnash → src}/changeBlockedStatus.js +3 -14
  13. package/{leiamnash → src}/changeGroupImage.js +16 -40
  14. package/src/changeNickname.js +43 -0
  15. package/{leiamnash → src}/changeThreadColor.js +10 -20
  16. package/src/changeThreadEmoji.js +41 -0
  17. package/src/chat.js +315 -0
  18. package/{leiamnash → src}/createNewGroup.js +12 -28
  19. package/{leiamnash → src}/createPoll.js +13 -25
  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/{leiamnash → src}/getCurrentUserID.js +1 -1
  25. package/{leiamnash → src}/getEmojiUrl.js +2 -4
  26. package/{leiamnash → src}/getFriendsList.js +10 -21
  27. package/{leiamnash → src}/getThreadHistory.js +58 -166
  28. package/{leiamnash → src}/getThreadHistoryDeprecated.js +20 -42
  29. package/src/getThreadInfo.js +171 -0
  30. package/src/getThreadInfoDeprecated.js +56 -0
  31. package/{leiamnash → src}/getThreadList.js +41 -66
  32. package/src/getThreadListDeprecated.js +46 -0
  33. package/src/getThreadPictures.js +59 -0
  34. package/{leiamnash → src}/getUserID.js +9 -14
  35. package/{leiamnash → src}/getUserInfo.js +12 -18
  36. package/src/handleFriendRequest.js +46 -0
  37. package/src/handleMessageRequest.js +47 -0
  38. package/{leiamnash → src}/httpGet.js +12 -17
  39. package/{leiamnash → src}/httpPost.js +12 -17
  40. package/src/listen.js +553 -0
  41. package/src/listenMqtt-Test.js +687 -0
  42. package/src/listenMqtt.js +677 -0
  43. package/{leiamnash → src}/logout.js +13 -20
  44. package/{leiamnash → src}/markAsDelivered.js +11 -22
  45. package/{leiamnash → src}/markAsRead.js +11 -21
  46. package/{leiamnash → src}/markAsReadAll.js +10 -20
  47. package/{leiamnash → src}/markAsSeen.js +7 -18
  48. package/{leiamnash → src}/muteThread.js +11 -18
  49. package/src/removeUserFromGroup.js +45 -0
  50. package/{leiamnash → src}/resolvePhotoUrl.js +8 -17
  51. package/{leiamnash → src}/searchForThread.js +10 -21
  52. package/src/sendMessage.js +315 -0
  53. package/{leiamnash → src}/sendTypingIndicator.js +14 -47
  54. package/{leiamnash → src}/setMessageReaction.js +12 -26
  55. package/{leiamnash → src}/setPostReaction.js +13 -26
  56. package/{leiamnash → src}/setTitle.js +13 -29
  57. package/src/threadColors.js +41 -0
  58. package/{leiamnash → src}/unfriend.js +9 -19
  59. package/{leiamnash → src}/unsendMessage.js +9 -19
  60. package/test/data/shareAttach.js +146 -0
  61. package/test/data/something.mov +0 -0
  62. package/test/data/test.png +0 -0
  63. package/test/data/test.txt +7 -0
  64. package/test/example-config.json +18 -0
  65. package/test/test-page.js +140 -0
  66. package/test/test.js +385 -0
  67. package/utils.js +1021 -1238
  68. package/leiamnash/addExternalModule.js +0 -19
  69. package/leiamnash/changeAdminStatus.js +0 -79
  70. package/leiamnash/changeApprovalMode.js +0 -80
  71. package/leiamnash/changeArchivedStatus.js +0 -55
  72. package/leiamnash/changeNickname.js +0 -59
  73. package/leiamnash/changeThreadEmoji.js +0 -55
  74. package/leiamnash/chat.js +0 -447
  75. package/leiamnash/deleteMessage.js +0 -56
  76. package/leiamnash/deleteThread.js +0 -56
  77. package/leiamnash/forwardAttachment.js +0 -60
  78. package/leiamnash/getThreadInfo.js +0 -212
  79. package/leiamnash/getThreadInfoDeprecated.js +0 -80
  80. package/leiamnash/getThreadListDeprecated.js +0 -75
  81. package/leiamnash/getThreadPictures.js +0 -79
  82. package/leiamnash/handleFriendRequest.js +0 -61
  83. package/leiamnash/handleMessageRequest.js +0 -65
  84. package/leiamnash/listenMqtt.js +0 -1129
  85. package/leiamnash/removeUserFromGroup.js +0 -79
  86. package/leiamnash/threadColors.js +0 -57
@@ -1,19 +0,0 @@
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,79 +0,0 @@
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,80 +0,0 @@
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 +0,0 @@
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,59 +0,0 @@
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 changeNickname(nickname, threadID, participantID, 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
- if (!callback) {
15
- callback = function (err) {
16
- if (err) {
17
- return rejectFunc(err);
18
- }
19
- resolveFunc();
20
- };
21
- }
22
-
23
- var form = {
24
- nickname: nickname,
25
- participant_id: participantID,
26
- thread_or_other_fbid: threadID
27
- };
28
-
29
- defaultFuncs
30
- .post(
31
- "https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1",
32
- ctx.jar,
33
- form
34
- )
35
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
36
- .then(function(resData) {
37
- if (resData.error === 1545014) {
38
- throw { error: "Trying to change nickname of user isn't in thread" };
39
- }
40
- if (resData.error === 1357031) {
41
- throw {
42
- error:
43
- "Trying to change user nickname of a thread that doesn't exist. Have at least one message in the thread before trying to change the user nickname."
44
- };
45
- }
46
- if (resData.error) {
47
- throw resData;
48
- }
49
-
50
- return callback();
51
- })
52
- .catch(function(err) {
53
- log.error("changeNickname", err);
54
- return callback(err);
55
- });
56
-
57
- return returnPromise;
58
- };
59
- };
@@ -1,55 +0,0 @@
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 changeThreadEmoji(emoji, 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 (!callback) {
16
- callback = function(err) {
17
- if (err) {
18
- return rejectFunc(err);
19
- }
20
- resolveFunc();
21
- };
22
- }
23
- var form = {
24
- emoji_choice: emoji,
25
- thread_or_other_fbid: threadID
26
- };
27
-
28
- defaultFuncs
29
- .post(
30
- "https://www.facebook.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg",
31
- ctx.jar,
32
- form
33
- )
34
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
35
- .then(function(resData) {
36
- if (resData.error === 1357031) {
37
- throw {
38
- error:
39
- "Trying to change emoji of a chat that doesn't exist. Have at least one message in the thread before trying to change the emoji."
40
- };
41
- }
42
- if (resData.error) {
43
- throw resData;
44
- }
45
-
46
- return callback();
47
- })
48
- .catch(function(err) {
49
- log.error("changeThreadEmoji", err);
50
- return callback(err);
51
- });
52
-
53
- return returnPromise;
54
- };
55
- };