rapido-fca 0.0.10 → 1.0.0

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.

Potentially problematic release.


This version of rapido-fca might be problematic. Click here for more details.

Files changed (60) hide show
  1. package/LICENSE +21 -0
  2. package/index.js +4 -4
  3. package/package.json +15 -16
  4. package/readme.md +237 -39
  5. package/src/Screenshot.js +83 -0
  6. package/src/addExternalModule.js +19 -23
  7. package/src/addUserToGroup.js +99 -97
  8. package/src/changeAdminStatus.js +86 -62
  9. package/src/changeArchivedStatus.js +49 -49
  10. package/src/changeAvatar.js +118 -108
  11. package/src/changeBio.js +63 -64
  12. package/src/changeBlockedStatus.js +40 -38
  13. package/src/changeGroupImage.js +129 -126
  14. package/src/changeNickname.js +49 -49
  15. package/src/changeThreadColor.js +53 -53
  16. package/src/changeThreadEmoji.js +45 -45
  17. package/src/createNewGroup.js +74 -72
  18. package/src/createPoll.js +59 -59
  19. package/src/deleteMessage.js +50 -50
  20. package/src/deleteThread.js +50 -50
  21. package/src/editMessage.js +51 -49
  22. package/src/forwardAttachment.js +54 -54
  23. package/src/getCurrentUserID.js +3 -3
  24. package/src/getEmojiUrl.js +17 -17
  25. package/src/getFriendsList.js +67 -67
  26. package/src/getMessage.js +806 -767
  27. package/src/getThreadHistory.js +656 -642
  28. package/src/getThreadInfo.js +1 -1
  29. package/src/getThreadList.js +199 -227
  30. package/src/getThreadPictures.js +51 -71
  31. package/src/getUserID.js +53 -58
  32. package/src/getUserInfo.js +52 -60
  33. package/src/handleFriendRequest.js +41 -65
  34. package/src/handleMessageRequest.js +42 -60
  35. package/src/httpGet.js +49 -57
  36. package/src/httpPost.js +48 -57
  37. package/src/listenMqtt.js +827 -827
  38. package/src/listenMqtt.txt +827 -0
  39. package/src/logout.js +61 -61
  40. package/src/markAsDelivered.js +42 -53
  41. package/src/markAsRead.js +59 -69
  42. package/src/markAsReadAll.js +32 -42
  43. package/src/markAsSeen.js +43 -54
  44. package/src/muteThread.js +40 -47
  45. package/src/postFormData.txt +46 -0
  46. package/src/refreshFb_dtsg.js +77 -69
  47. package/src/removeUserFromGroup.js +67 -67
  48. package/src/resolvePhotoUrl.js +34 -34
  49. package/src/searchForThread.js +43 -43
  50. package/src/sendMessage.js +80 -228
  51. package/src/sendTypingIndicator.js +86 -88
  52. package/src/setPostReaction.js +90 -87
  53. package/src/setTitle.js +76 -72
  54. package/src/threadColors.js +121 -121
  55. package/src/unfriend.js +43 -43
  56. package/src/unsendMessage.js +34 -38
  57. package/src/uploadAttachment.js +80 -81
  58. package/src/httpPostFormData.js +0 -63
  59. package/src/setEmojiReaction.js +0 -59
  60. package/src/videoAttachment.js +0 -76
@@ -1,86 +1,88 @@
1
1
  "use strict";
2
2
 
3
3
  const utils = require("../utils");
4
- const log = require("npmlog");
4
+ // @NethWs3Dev
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 { error: "createNewGroup: participantIDs should have at least 2 IDs." };
19
- }
17
+ if (participantIDs.length < 2) {
18
+ throw {
19
+ error: "createNewGroup: participantIDs should have at least 2 IDs.",
20
+ };
21
+ }
20
22
 
21
- let resolveFunc = function () { };
22
- let rejectFunc = function () { };
23
- const returnPromise = new Promise(function (resolve, reject) {
24
- resolveFunc = resolve;
25
- rejectFunc = reject;
26
- });
23
+ let resolveFunc = function () {};
24
+ let rejectFunc = function () {};
25
+ const returnPromise = new Promise(function (resolve, reject) {
26
+ resolveFunc = resolve;
27
+ rejectFunc = reject;
28
+ });
27
29
 
28
- if (!callback) {
29
- callback = function (err, threadID) {
30
- if (err) {
31
- return rejectFunc(err);
32
- }
33
- resolveFunc(threadID);
34
- };
35
- }
30
+ if (!callback) {
31
+ callback = function (err, threadID) {
32
+ if (err) {
33
+ return rejectFunc(err);
34
+ }
35
+ resolveFunc(threadID);
36
+ };
37
+ }
36
38
 
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 });
39
+ const pids = [];
40
+ for (const n in participantIDs) {
41
+ pids.push({
42
+ fbid: participantIDs[n],
43
+ });
44
+ }
45
+ pids.push({ fbid: ctx.userID });
44
46
 
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
- };
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
+ };
65
67
 
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
- });
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
+ });
83
85
 
84
- return returnPromise;
85
- };
86
+ return returnPromise;
87
+ };
86
88
  };
package/src/createPoll.js CHANGED
@@ -1,71 +1,71 @@
1
1
  "use strict";
2
2
 
3
3
  const utils = require("../utils");
4
- const log = require("npmlog");
4
+ // @NethWs3Dev
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
- log.error("createPoll", err);
66
- return callback(err);
67
- });
62
+ return callback();
63
+ })
64
+ .catch(function (err) {
65
+ console.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
- const log = require("npmlog");
4
+ // @NethWs3Dev
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
- log.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
+ console.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
- const log = require("npmlog");
4
+ // @NethWs3Dev
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
- log.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
+ console.error("deleteThread", err);
51
+ return callback(err);
52
+ });
53
+
54
+ return returnPromise;
55
+ };
56
56
  };
@@ -1,66 +1,68 @@
1
1
  "use_strict";
2
2
  /**
3
- * @author RFS-ADRENO
4
- * @rewrittenBy Isai Ivanov
5
- */
3
+ * @author RFS-ADRENO
4
+ * @rewrittenBy Isai Ivanov
5
+ */
6
6
  const generateOfflineThreadingId = require('../utils');
7
7
 
8
8
  function canBeCalled(func) {
9
- try {
10
- Reflect.apply(func, null, []);
11
- return true;
12
- } catch (error) {
13
- return false;
14
- }
9
+ try {
10
+ Reflect.apply(func, null, []);
11
+ return true;
12
+ } catch (error) {
13
+ return false;
14
+ }
15
15
  }
16
16
 
17
17
  /**
18
- * A function for editing bot's messages.
19
- * @param {string} text - The text with which the bot will edit its messages.
20
- * @param {string} messageID - The message ID of the message the bot will edit.
21
- * @param {Object} callback - Callback for the function.
22
- */
18
+ * A function for editing bot's messages.
19
+ * @param {string} text - The text with which the bot will edit its messages.
20
+ * @param {string} messageID - The message ID of the message the bot will edit.
21
+ * @param {Object} callback - Callback for the function.
22
+ */
23
23
 
24
24
  module.exports = function (defaultFuncs, api, ctx) {
25
- return function editMessage(text, messageID, callback) {
26
- if (!ctx.mqttClient) {
27
- throw new Error('Not connected to MQTT');
28
- }
25
+ return function editMessage(text, messageID, callback) {
26
+ if (!ctx.mqttClient) {
27
+ throw new Error('Not connected to MQTT');
28
+ }
29
29
 
30
- ctx.wsReqNumber += 1;
31
- ctx.wsTaskNumber += 1;
30
+ ctx.wsReqNumber += 1;
31
+ ctx.wsTaskNumber += 1;
32
32
 
33
- const queryPayload = {
34
- message_id: messageID,
35
- text: text
36
- };
33
+ const queryPayload = {
34
+ message_id: messageID,
35
+ text: text
36
+ };
37
37
 
38
- const query = {
39
- failure_count: null,
40
- label: '742',
41
- payload: JSON.stringify(queryPayload),
42
- queue_name: 'edit_message',
43
- task_id: ctx.wsTaskNumber
44
- };
38
+ const query = {
39
+ failure_count: null,
40
+ label: '742',
41
+ payload: JSON.stringify(queryPayload),
42
+ queue_name: 'edit_message',
43
+ task_id: ctx.wsTaskNumber
44
+ };
45
45
 
46
- const context = {
47
- app_id: '2220391788200892',
48
- payload: {
49
- data_trace_id: null,
50
- epoch_id: parseInt(generateOfflineThreadingId),
51
- tasks: [query],
52
- version_id: '6903494529735864'
53
- },
54
- request_id: ctx.wsReqNumber,
55
- type: 3
56
- };
46
+ const context = {
47
+ app_id: '2220391788200892',
48
+ payload: {
49
+ data_trace_id: null,
50
+ epoch_id: parseInt(generateOfflineThreadingId),
51
+ tasks: [query],
52
+ version_id: '6903494529735864'
53
+ },
54
+ request_id: ctx.wsReqNumber,
55
+ type: 3
56
+ };
57
57
 
58
- context.payload = JSON.stringify(context.payload);
58
+ context.payload = JSON.stringify(context.payload);
59
59
 
60
- // if (canBeCalled(callback)) {
61
- // ctx.reqCallbacks[ctx.wsReqNumber] = callback;
62
- // }
60
+ // if (canBeCalled(callback)) {
61
+ // ctx.reqCallbacks[ctx.wsReqNumber] = callback;
62
+ // }
63
63
 
64
- ctx.mqttClient.publish('/ls_req', JSON.stringify(context), { qos: 1, retain: false });
65
- };
66
- };
64
+ ctx.mqttClient.publish('/ls_req', JSON.stringify(context), {
65
+ qos: 1, retain: false
66
+ });
67
+ };
68
+ };