rapido-fca 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/package.json +1 -1
  2. package/readme.md +39 -237
  3. package/src/addExternalModule.js +23 -19
  4. package/src/addUserToGroup.js +97 -99
  5. package/src/changeAdminStatus.js +62 -86
  6. package/src/changeArchivedStatus.js +49 -49
  7. package/src/changeAvatar.js +108 -118
  8. package/src/changeBio.js +64 -63
  9. package/src/changeBlockedStatus.js +38 -40
  10. package/src/changeGroupImage.js +126 -129
  11. package/src/changeNickname.js +49 -49
  12. package/src/changeThreadColor.js +53 -53
  13. package/src/changeThreadEmoji.js +45 -45
  14. package/src/createNewGroup.js +72 -74
  15. package/src/createPoll.js +59 -59
  16. package/src/deleteMessage.js +50 -50
  17. package/src/deleteThread.js +50 -50
  18. package/src/editMessage.js +49 -51
  19. package/src/forwardAttachment.js +54 -54
  20. package/src/getCurrentUserID.js +3 -3
  21. package/src/getEmojiUrl.js +17 -17
  22. package/src/getFriendsList.js +67 -67
  23. package/src/getMessage.js +767 -806
  24. package/src/getThreadHistory.js +642 -656
  25. package/src/getThreadInfo.js +1 -1
  26. package/src/getThreadList.js +227 -199
  27. package/src/getThreadPictures.js +71 -51
  28. package/src/getUserID.js +58 -53
  29. package/src/getUserInfo.js +60 -52
  30. package/src/handleFriendRequest.js +65 -41
  31. package/src/handleMessageRequest.js +60 -42
  32. package/src/httpGet.js +57 -49
  33. package/src/httpPost.js +57 -48
  34. package/src/httpPostFormData.js +63 -0
  35. package/src/listenMqtt.js +895 -827
  36. package/src/logout.js +61 -61
  37. package/src/markAsDelivered.js +53 -42
  38. package/src/markAsRead.js +69 -59
  39. package/src/markAsReadAll.js +42 -32
  40. package/src/markAsSeen.js +54 -43
  41. package/src/muteThread.js +47 -40
  42. package/src/refreshFb_dtsg.js +69 -77
  43. package/src/removeUserFromGroup.js +67 -67
  44. package/src/resolvePhotoUrl.js +34 -34
  45. package/src/searchForThread.js +43 -43
  46. package/src/sendMessage.js +228 -80
  47. package/src/sendTypingIndicator.js +88 -86
  48. package/src/setMessageReaction.js +109 -110
  49. package/src/setPostReaction.js +87 -90
  50. package/src/setTitle.js +72 -76
  51. package/src/threadColors.js +121 -121
  52. package/src/unfriend.js +43 -43
  53. package/src/unsendMessage.js +38 -34
  54. package/src/uploadAttachment.js +81 -79
  55. package/src/changeAvatarV2.js +0 -86
  56. package/src/changeAvt.js +0 -85
  57. package/src/changeBlockedStatusMqtt.js +0 -80
  58. package/src/changeCover.js +0 -72
  59. package/src/changeName.js +0 -79
  60. package/src/changeUsername.js +0 -59
  61. package/src/createCommentPost.js +0 -230
  62. package/src/createPost.js +0 -276
  63. package/src/editMessageOld.js +0 -67
  64. package/src/follow.js +0 -74
  65. package/src/getAccess.js +0 -112
  66. package/src/getAvatarUser.js +0 -78
  67. package/src/getRegion.js +0 -7
  68. package/src/getThreadHistoryDeprecated.js +0 -71
  69. package/src/getThreadInfoDeprecated.js +0 -56
  70. package/src/getThreadListDeprecated.js +0 -46
  71. package/src/getUID.js +0 -119
  72. package/src/searchStickers.js +0 -53
  73. package/src/sendMessageMqtt.js +0 -322
  74. package/src/sendTypingIndicatorV2.js +0 -28
  75. package/src/setMessageReactionMqtt.js +0 -62
  76. package/src/setStoryReaction.js +0 -64
  77. package/src/shareContact.js +0 -110
  78. package/src/shareLink.js +0 -59
  79. package/src/stopListenMqtt.js +0 -23
@@ -1,55 +1,55 @@
1
1
  "use strict";
2
2
 
3
3
  const utils = require("../utils");
4
- // @NethWs3Dev
4
+ const log = require("npmlog");
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
- return function changeThreadEmoji(emoji, threadID, callback) {
8
- let resolveFunc = function () {};
9
- let rejectFunc = function () {};
10
- const returnPromise = new Promise(function (resolve, reject) {
11
- resolveFunc = resolve;
12
- rejectFunc = reject;
13
- });
7
+ return function changeThreadEmoji(emoji, threadID, callback) {
8
+ let resolveFunc = function () { };
9
+ let rejectFunc = function () { };
10
+ const returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
14
 
15
- if (!callback) {
16
- callback = function (err) {
17
- if (err) {
18
- return rejectFunc(err);
19
- }
20
- resolveFunc();
21
- };
22
- }
23
- const form = {
24
- emoji_choice: emoji,
25
- thread_or_other_fbid: threadID,
26
- };
15
+ if (!callback) {
16
+ callback = function (err) {
17
+ if (err) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc();
21
+ };
22
+ }
23
+ const form = {
24
+ emoji_choice: emoji,
25
+ thread_or_other_fbid: threadID
26
+ };
27
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
- }
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
45
 
46
- return callback();
47
- })
48
- .catch(function (err) {
49
- console.error("changeThreadEmoji", err);
50
- return callback(err);
51
- });
46
+ return callback();
47
+ })
48
+ .catch(function (err) {
49
+ log.error("changeThreadEmoji", err);
50
+ return callback(err);
51
+ });
52
52
 
53
- return returnPromise;
54
- };
53
+ return returnPromise;
54
+ };
55
55
  };
@@ -1,88 +1,86 @@
1
1
  "use strict";
2
2
 
3
3
  const utils = require("../utils");
4
- // @NethWs3Dev
4
+ const log = require("npmlog");
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
- return function createNewGroup(participantIDs, groupTitle, callback) {
8
- if (utils.getType(groupTitle) == "Function") {
9
- callback = groupTitle;
10
- groupTitle = null;
11
- }
7
+ return function createNewGroup(participantIDs, groupTitle, callback) {
8
+ if (utils.getType(groupTitle) == "Function") {
9
+ callback = groupTitle;
10
+ groupTitle = null;
11
+ }
12
12
 
13
- if (utils.getType(participantIDs) !== "Array") {
14
- throw { error: "createNewGroup: participantIDs should be an array." };//
15
- }
13
+ if (utils.getType(participantIDs) !== "Array") {
14
+ throw { error: "createNewGroup: participantIDs should be an array." };
15
+ }
16
16
 
17
- if (participantIDs.length < 2) {
18
- throw {
19
- error: "createNewGroup: participantIDs should have at least 2 IDs.",
20
- };
21
- }
17
+ if (participantIDs.length < 2) {
18
+ throw { error: "createNewGroup: participantIDs should have at least 2 IDs." };
19
+ }
22
20
 
23
- let resolveFunc = function () {};
24
- let rejectFunc = function () {};
25
- const returnPromise = new Promise(function (resolve, reject) {
26
- resolveFunc = resolve;
27
- rejectFunc = reject;
28
- });
21
+ let resolveFunc = function () { };
22
+ let rejectFunc = function () { };
23
+ const returnPromise = new Promise(function (resolve, reject) {
24
+ resolveFunc = resolve;
25
+ rejectFunc = reject;
26
+ });
29
27
 
30
- if (!callback) {
31
- callback = function (err, threadID) {
32
- if (err) {
33
- return rejectFunc(err);
34
- }
35
- resolveFunc(threadID);
36
- };
37
- }
28
+ if (!callback) {
29
+ callback = function (err, threadID) {
30
+ if (err) {
31
+ return rejectFunc(err);
32
+ }
33
+ resolveFunc(threadID);
34
+ };
35
+ }
38
36
 
39
- const pids = [];
40
- for (const n in participantIDs) {
41
- pids.push({
42
- fbid: participantIDs[n],
43
- });
44
- }
45
- pids.push({ fbid: ctx.userID });
37
+ const pids = [];
38
+ for (const n in participantIDs) {
39
+ pids.push({
40
+ fbid: participantIDs[n]
41
+ });
42
+ }
43
+ pids.push({ fbid: ctx.i_userID || ctx.userID });
46
44
 
47
- const form = {
48
- fb_api_caller_class: "RelayModern",
49
- fb_api_req_friendly_name: "MessengerGroupCreateMutation",
50
- av: ctx.userID,
51
- //This doc_id is valid as of January 11th, 2020
52
- doc_id: "577041672419534",
53
- variables: JSON.stringify({
54
- input: {
55
- entry_point: "jewel_new_group",
56
- actor_id: ctx.userID,
57
- participants: pids,
58
- client_mutation_id: Math.round(Math.random() * 1024).toString(),
59
- thread_settings: {
60
- name: groupTitle,
61
- joinable_mode: "PRIVATE",
62
- thread_image_fbid: null,
63
- },
64
- },
65
- }),
66
- };
45
+ const form = {
46
+ fb_api_caller_class: "RelayModern",
47
+ fb_api_req_friendly_name: "MessengerGroupCreateMutation",
48
+ av: ctx.i_userID || ctx.userID,
49
+ //This doc_id is valid as of January 11th, 2020
50
+ doc_id: "577041672419534",
51
+ variables: JSON.stringify({
52
+ input: {
53
+ entry_point: "jewel_new_group",
54
+ actor_id: ctx.i_userID || ctx.userID,
55
+ participants: pids,
56
+ client_mutation_id: Math.round(Math.random() * 1024).toString(),
57
+ thread_settings: {
58
+ name: groupTitle,
59
+ joinable_mode: "PRIVATE",
60
+ thread_image_fbid: null
61
+ }
62
+ }
63
+ })
64
+ };
67
65
 
68
- defaultFuncs
69
- .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
70
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
71
- .then(function (resData) {
72
- if (resData.errors) {
73
- throw resData;
74
- }
75
- return callback(
76
- null,
77
- resData.data.messenger_group_thread_create.thread.thread_key
78
- .thread_fbid,
79
- );
80
- })
81
- .catch(function (err) {
82
- console.error("createNewGroup", err);
83
- return callback(err);
84
- });
66
+ defaultFuncs
67
+ .post(
68
+ "https://www.facebook.com/api/graphql/",
69
+ ctx.jar,
70
+ form
71
+ )
72
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
73
+ .then(function (resData) {
74
+ if (resData.errors) {
75
+ throw resData;
76
+ }
77
+ return callback(null, resData.data.messenger_group_thread_create.thread.thread_key.thread_fbid);
78
+ })
79
+ .catch(function (err) {
80
+ log.error("createNewGroup", err);
81
+ return callback(err);
82
+ });
85
83
 
86
- return returnPromise;
87
- };
84
+ return returnPromise;
85
+ };
88
86
  };
package/src/createPoll.js CHANGED
@@ -1,71 +1,71 @@
1
1
  "use strict";
2
2
 
3
3
  const utils = require("../utils");
4
- // @NethWs3Dev
4
+ const log = require("npmlog");
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
- return function createPoll(title, threadID, options, callback) {
8
- let resolveFunc = function () {};
9
- let rejectFunc = function () {};
10
- const returnPromise = new Promise(function (resolve, reject) {
11
- resolveFunc = resolve;
12
- rejectFunc = reject;
13
- });
7
+ return function createPoll(title, threadID, options, callback) {
8
+ let resolveFunc = function () { };
9
+ let rejectFunc = function () { };
10
+ const returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
14
 
15
- if (!callback) {
16
- if (utils.getType(options) == "Function") {
17
- callback = options;
18
- options = null;
19
- } else {
20
- callback = function (err) {
21
- if (err) {
22
- return rejectFunc(err);
23
- }
24
- resolveFunc();
25
- };
26
- }
27
- }
28
- if (!options) {
29
- options = {}; // Initial poll options are optional
30
- }
15
+ if (!callback) {
16
+ if (utils.getType(options) == "Function") {
17
+ callback = options;
18
+ options = null;
19
+ } else {
20
+ callback = function (err) {
21
+ if (err) {
22
+ return rejectFunc(err);
23
+ }
24
+ resolveFunc();
25
+ };
26
+ }
27
+ }
28
+ if (!options) {
29
+ options = {}; // Initial poll options are optional
30
+ }
31
31
 
32
- const form = {
33
- target_id: threadID,
34
- question_text: title,
35
- };
32
+ const form = {
33
+ target_id: threadID,
34
+ question_text: title
35
+ };
36
36
 
37
- // Set fields for options (and whether they are selected initially by the posting user)
38
- let ind = 0;
39
- for (const opt in options) {
40
- // eslint-disable-next-line no-prototype-builtins
41
- if (options.hasOwnProperty(opt)) {
42
- form["option_text_array[" + ind + "]"] = opt;
43
- form["option_is_selected_array[" + ind + "]"] = options[opt]
44
- ? "1"
45
- : "0";
46
- ind++;
47
- }
48
- }
37
+ // Set fields for options (and whether they are selected initially by the posting user)
38
+ let ind = 0;
39
+ for (const opt in options) {
40
+ // eslint-disable-next-line no-prototype-builtins
41
+ if (options.hasOwnProperty(opt)) {
42
+ form["option_text_array[" + ind + "]"] = opt;
43
+ form["option_is_selected_array[" + ind + "]"] = options[opt]
44
+ ? "1"
45
+ : "0";
46
+ ind++;
47
+ }
48
+ }
49
49
 
50
- defaultFuncs
51
- .post(
52
- "https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1",
53
- ctx.jar,
54
- form,
55
- )
56
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
57
- .then(function (resData) {
58
- if (resData.payload.status != "success") {
59
- throw resData;
60
- }
50
+ defaultFuncs
51
+ .post(
52
+ "https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1",
53
+ ctx.jar,
54
+ form
55
+ )
56
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
57
+ .then(function (resData) {
58
+ if (resData.payload.status != "success") {
59
+ throw resData;
60
+ }
61
61
 
62
- return callback();
63
- })
64
- .catch(function (err) {
65
- console.error("createPoll", err);
66
- return callback(err);
67
- });
62
+ return callback();
63
+ })
64
+ .catch(function (err) {
65
+ log.error("createPoll", err);
66
+ return callback(err);
67
+ });
68
68
 
69
- return returnPromise;
70
- };
69
+ return returnPromise;
70
+ };
71
71
  };
@@ -1,56 +1,56 @@
1
1
  "use strict";
2
2
 
3
3
  const utils = require("../utils");
4
- // @NethWs3Dev
4
+ const log = require("npmlog");
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
- return function deleteMessage(messageOrMessages, callback) {
8
- let resolveFunc = function () {};
9
- let rejectFunc = function () {};
10
- const 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
- const form = {
24
- client: "mercury",
25
- };
26
-
27
- if (utils.getType(messageOrMessages) !== "Array") {
28
- messageOrMessages = [messageOrMessages];
29
- }
30
-
31
- for (let i = 0; i < messageOrMessages.length; i++) {
32
- form["message_ids[" + i + "]"] = messageOrMessages[i];
33
- }
34
-
35
- defaultFuncs
36
- .post(
37
- "https://www.facebook.com/ajax/mercury/delete_messages.php",
38
- ctx.jar,
39
- form,
40
- )
41
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
42
- .then(function (resData) {
43
- if (resData.error) {
44
- throw resData;
45
- }
46
-
47
- return callback();
48
- })
49
- .catch(function (err) {
50
- console.error("deleteMessage", err);
51
- return callback(err);
52
- });
53
-
54
- return returnPromise;
55
- };
7
+ return function deleteMessage(messageOrMessages, callback) {
8
+ let resolveFunc = function () { };
9
+ let rejectFunc = function () { };
10
+ const 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
+ const form = {
24
+ client: "mercury"
25
+ };
26
+
27
+ if (utils.getType(messageOrMessages) !== "Array") {
28
+ messageOrMessages = [messageOrMessages];
29
+ }
30
+
31
+ for (let i = 0; i < messageOrMessages.length; i++) {
32
+ form["message_ids[" + i + "]"] = messageOrMessages[i];
33
+ }
34
+
35
+ defaultFuncs
36
+ .post(
37
+ "https://www.facebook.com/ajax/mercury/delete_messages.php",
38
+ ctx.jar,
39
+ form
40
+ )
41
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
42
+ .then(function (resData) {
43
+ if (resData.error) {
44
+ throw resData;
45
+ }
46
+
47
+ return callback();
48
+ })
49
+ .catch(function (err) {
50
+ log.error("deleteMessage", err);
51
+ return callback(err);
52
+ });
53
+
54
+ return returnPromise;
55
+ };
56
56
  };
@@ -1,56 +1,56 @@
1
1
  "use strict";
2
2
 
3
3
  const utils = require("../utils");
4
- // @NethWs3Dev
4
+ const log = require("npmlog");
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
- return function deleteThread(threadOrThreads, callback) {
8
- let resolveFunc = function () {};
9
- let rejectFunc = function () {};
10
- const 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
- const form = {
24
- client: "mercury",
25
- };
26
-
27
- if (utils.getType(threadOrThreads) !== "Array") {
28
- threadOrThreads = [threadOrThreads];
29
- }
30
-
31
- for (let i = 0; i < threadOrThreads.length; i++) {
32
- form["ids[" + i + "]"] = threadOrThreads[i];
33
- }
34
-
35
- defaultFuncs
36
- .post(
37
- "https://www.facebook.com/ajax/mercury/delete_thread.php",
38
- ctx.jar,
39
- form,
40
- )
41
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
42
- .then(function (resData) {
43
- if (resData.error) {
44
- throw resData;
45
- }
46
-
47
- return callback();
48
- })
49
- .catch(function (err) {
50
- console.error("deleteThread", err);
51
- return callback(err);
52
- });
53
-
54
- return returnPromise;
55
- };
7
+ return function deleteThread(threadOrThreads, callback) {
8
+ let resolveFunc = function () { };
9
+ let rejectFunc = function () { };
10
+ const 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
+ const form = {
24
+ client: "mercury"
25
+ };
26
+
27
+ if (utils.getType(threadOrThreads) !== "Array") {
28
+ threadOrThreads = [threadOrThreads];
29
+ }
30
+
31
+ for (let i = 0; i < threadOrThreads.length; i++) {
32
+ form["ids[" + i + "]"] = threadOrThreads[i];
33
+ }
34
+
35
+ defaultFuncs
36
+ .post(
37
+ "https://www.facebook.com/ajax/mercury/delete_thread.php",
38
+ ctx.jar,
39
+ form
40
+ )
41
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
42
+ .then(function (resData) {
43
+ if (resData.error) {
44
+ throw resData;
45
+ }
46
+
47
+ return callback();
48
+ })
49
+ .catch(function (err) {
50
+ log.error("deleteThread", err);
51
+ return callback(err);
52
+ });
53
+
54
+ return returnPromise;
55
+ };
56
56
  };