toru-fca 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.
Files changed (113) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +319 -0
  3. package/advancedSystem.js +95 -0
  4. package/build/messagix.dll +0 -0
  5. package/build/messagix.so +0 -0
  6. package/checkUpdate.js +37 -0
  7. package/config.json +45 -0
  8. package/e2ee.js +719 -0
  9. package/index.js +715 -0
  10. package/lib/index.mjs +1412 -0
  11. package/package.json +69 -0
  12. package/src/OldMessage.js +357 -0
  13. package/src/addExternalModule.js +25 -0
  14. package/src/addUserToGroup.js +117 -0
  15. package/src/changeAdminStatus.js +105 -0
  16. package/src/changeArchivedStatus.js +57 -0
  17. package/src/changeAvatar.js +138 -0
  18. package/src/changeAvatarV2.js +86 -0
  19. package/src/changeAvt.js +85 -0
  20. package/src/changeBio.js +78 -0
  21. package/src/changeBlockedStatus.js +51 -0
  22. package/src/changeBlockedStatusMqtt.js +80 -0
  23. package/src/changeCover.js +72 -0
  24. package/src/changeGroupImage.js +137 -0
  25. package/src/changeName.js +79 -0
  26. package/src/changeNickname.js +61 -0
  27. package/src/changeThreadColor.js +67 -0
  28. package/src/changeThreadEmoji.js +57 -0
  29. package/src/changeUsername.js +59 -0
  30. package/src/createCommentPost.js +230 -0
  31. package/src/createNewGroup.js +90 -0
  32. package/src/createPoll.js +73 -0
  33. package/src/createPost.js +276 -0
  34. package/src/data/getThreadInfo.json +1 -0
  35. package/src/deleteMessage.js +58 -0
  36. package/src/deleteThread.js +58 -0
  37. package/src/editMessage.js +81 -0
  38. package/src/editMessageOld.js +67 -0
  39. package/src/follow.js +74 -0
  40. package/src/forwardAttachment.js +62 -0
  41. package/src/friendList.js +104 -0
  42. package/src/getAccess.js +112 -0
  43. package/src/getAvatarUser.js +78 -0
  44. package/src/getBotInitialData.js +42 -0
  45. package/src/getCtx.js +5 -0
  46. package/src/getCurrentUserID.js +7 -0
  47. package/src/getEmojiUrl.js +29 -0
  48. package/src/getFriendsList.js +85 -0
  49. package/src/getMessage.js +849 -0
  50. package/src/getOptions.js +5 -0
  51. package/src/getRegion.js +7 -0
  52. package/src/getThreadHistory.js +682 -0
  53. package/src/getThreadHistoryDeprecated.js +71 -0
  54. package/src/getThreadInfo.js +232 -0
  55. package/src/getThreadInfoDeprecated.js +56 -0
  56. package/src/getThreadList.js +213 -0
  57. package/src/getThreadListDeprecated.js +46 -0
  58. package/src/getThreadPictures.js +59 -0
  59. package/src/getThreadTheme.js +81 -0
  60. package/src/getUID.js +119 -0
  61. package/src/getUserID.js +61 -0
  62. package/src/getUserInfo.js +66 -0
  63. package/src/handleFriendRequest.js +46 -0
  64. package/src/handleMessageRequest.js +47 -0
  65. package/src/httpGet.js +49 -0
  66. package/src/httpPost.js +48 -0
  67. package/src/httpPostFormData.js +70 -0
  68. package/src/listenMqtt.js +955 -0
  69. package/src/listenNotification.js +85 -0
  70. package/src/logout.js +19 -0
  71. package/src/markAsDelivered.js +47 -0
  72. package/src/markAsRead.js +72 -0
  73. package/src/markAsReadAll.js +40 -0
  74. package/src/markAsSeen.js +48 -0
  75. package/src/metaTheme.js +189 -0
  76. package/src/muteThread.js +45 -0
  77. package/src/note.js +228 -0
  78. package/src/pinMessage.js +59 -0
  79. package/src/refreshFb_dtsg.js +91 -0
  80. package/src/removeSuspiciousAccount.js +78 -0
  81. package/src/removeUserFromGroup.js +81 -0
  82. package/src/reply.js +442 -0
  83. package/src/resolvePhotoUrl.js +47 -0
  84. package/src/searchForThread.js +53 -0
  85. package/src/searchFriends.js +140 -0
  86. package/src/searchStickers.js +53 -0
  87. package/src/send.js +46 -0
  88. package/src/sendButtons.js +163 -0
  89. package/src/sendComment.js +159 -0
  90. package/src/sendFriendRequest.js +112 -0
  91. package/src/sendMessage.js +440 -0
  92. package/src/sendMessageMqtt.js +323 -0
  93. package/src/sendTypingIndicator.js +54 -0
  94. package/src/setActiveStatus.js +92 -0
  95. package/src/setMessageReaction.js +149 -0
  96. package/src/setMessageReactionMqtt.js +62 -0
  97. package/src/setPostReaction.js +114 -0
  98. package/src/setProfileGuard.js +44 -0
  99. package/src/setProfileLock.js +97 -0
  100. package/src/setStoryReaction.js +133 -0
  101. package/src/setStorySeen.js +108 -0
  102. package/src/setThreadTheme.js +102 -0
  103. package/src/setTitle.js +92 -0
  104. package/src/shareContact.js +110 -0
  105. package/src/shareLink.js +59 -0
  106. package/src/stopListenMqtt.js +37 -0
  107. package/src/storyManager.js +357 -0
  108. package/src/suggestFriend.js +132 -0
  109. package/src/threadColors.js +131 -0
  110. package/src/unfriend.js +54 -0
  111. package/src/unsendMessage.js +68 -0
  112. package/src/uploadAttachment.js +115 -0
  113. package/utils.js +3044 -0
@@ -0,0 +1,85 @@
1
+ 'use strict';
2
+
3
+ var utils = require('../utils');
4
+ //NethWs3Dev
5
+ var EventEmitter = require('node:events');
6
+
7
+ function format(res, globalCallback) {
8
+ var checkMinutes = (date_1, date_2) => {
9
+ let ms_1 = date_1.getTime();
10
+ let ms_2 = date_2.getTime();
11
+ return Math.ceil((ms_2 - ms_1) / (60 * 1000));
12
+ }
13
+
14
+ for (let index of res.notifications_page.edges) {
15
+ if (index.node.row_type !== 'NOTIFICATION') continue;
16
+
17
+ var timestamp = index.node.notif.creation_time.timestamp;
18
+ if (checkMinutes(new Date(timestamp * 1000), new Date()) <= 1)
19
+ globalCallback(null, {
20
+ id: res.node.notif.id,
21
+ noti_id: res.node.notif.notif_id,
22
+ body: index.node.notif.body.text,
23
+ url: index.node.notif.url,
24
+ timestamp: timestamp * 1000
25
+ });
26
+ }
27
+ }
28
+
29
+ module.exports = function (defaultFuncs, api, ctx) {
30
+ let globalCallback, interval;
31
+
32
+ function MessageRepeat() {
33
+ interval = setInterval(function () {
34
+ return defaultFuncs
35
+ .post('https://www.facebook.com/api/graphql/', ctx.jar, {
36
+ fb_api_req_friendly_name: 'CometNotificationsRootQuery',
37
+ doc_id: 6663491207045267,
38
+ variables: JSON.stringify({
39
+ count: 5,
40
+ environment: 'MAIN_SURFACE',
41
+ filter_tokens: ['Cg8CZnQPA2FsbAE='],
42
+ scale: 1
43
+ }),
44
+ server_timestamps: !0
45
+ })
46
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
47
+ .then(function (res) {
48
+ if (res.error || res.errors)
49
+ throw res;
50
+
51
+ return format(res.data.viewer, globalCallback);
52
+ })
53
+ .catch(function (err) {
54
+ utils.error('listenNotification', err);
55
+ clearInterval(interval);
56
+ interval = void 0;
57
+ return globalCallback(err);
58
+ });
59
+ }, 60 * 1000);
60
+ }
61
+
62
+ return function notification(callback) {
63
+ class MessageEmitter extends EventEmitter {
64
+ stop() {
65
+ globalCallback = () => {}
66
+
67
+ if (interval) {
68
+ clearInterval(interval);
69
+ interval = void 0;
70
+ }
71
+ Message.emit('stop', new Date());
72
+ }
73
+ }
74
+
75
+ var Message = new MessageEmitter();
76
+
77
+ if (typeof callback == 'function')
78
+ globalCallback = callback;
79
+ else
80
+ globalCallback = (error, message) => error ? Message.emit('error', error) : Message.emit('message', message);
81
+
82
+ MessageRepeat();
83
+ return Message;
84
+ }
85
+ }
package/src/logout.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ var log = require("npmlog");
4
+
5
+ // ─── LOGOUT — safe no-op (session preserved) ─────────────────────────────────
6
+ // alpha-fca keeps the Facebook session alive by default.
7
+ // Calling api.logout() does nothing and silently succeeds.
8
+ // This prevents accidental session destruction from bot code.
9
+ //
10
+ // If you NEED to destroy the session for a specific reason, call
11
+ // api.forceLogoutSession() — but this is discouraged.
12
+ module.exports = function (defaultFuncs, api, ctx) {
13
+ return function logout(callback) {
14
+ log.warn("logout", "[alpha-fca] Logout is disabled — Facebook session kept alive.");
15
+ var cb = typeof callback === "function" ? callback : function () {};
16
+ cb(null);
17
+ return Promise.resolve();
18
+ };
19
+ };
@@ -0,0 +1,47 @@
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 markAsDelivered(threadID, messageID, 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
+
19
+ resolveFunc(data);
20
+ };
21
+ }
22
+
23
+ if (!threadID || !messageID) return callback("Error: messageID or threadID is not defined");
24
+
25
+ var form = {};
26
+ form["message_ids[0]"] = messageID;
27
+ form["thread_ids[" + threadID + "][0]"] = messageID;
28
+
29
+ defaultFuncs
30
+ .post("https://www.facebook.com/ajax/mercury/delivery_receipts.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("markAsDelivered", err);
40
+ if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
41
+
42
+ return callback(err);
43
+ });
44
+
45
+ return returnPromise;
46
+ };
47
+ };
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ return async function markAsRead(threadID, read, callback) {
8
+ if (utils.getType(read) === 'Function' || utils.getType(read) === 'AsyncFunction') {
9
+ callback = read;
10
+ read = true;
11
+ }
12
+ if (read == undefined) read = true;
13
+
14
+ if (!callback) callback = () => { };
15
+
16
+ var form = {};
17
+
18
+ if (typeof ctx.globalOptions.pageID !== 'undefined') {
19
+ form["source"] = "PagesManagerMessagesInterface";
20
+ form["request_user_id"] = ctx.globalOptions.pageID;
21
+ form["ids[" + threadID + "]"] = read;
22
+ form["watermarkTimestamp"] = new Date().getTime();
23
+ form["shouldSendReadReceipt"] = true;
24
+ form["commerce_last_message_type"] = "";
25
+ //form["titanOriginatedThreadId"] = utils.generateThreadingID(ctx.clientID);
26
+
27
+ let resData;
28
+ try {
29
+ resData = await (
30
+ defaultFuncs
31
+ .post("https://www.facebook.com/ajax/mercury/change_read_status.php", ctx.jar, form)
32
+ .then(utils.saveCookies(ctx.jar))
33
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
34
+ );
35
+ }
36
+ catch (e) {
37
+ callback(e);
38
+ return e;
39
+ }
40
+
41
+ if (resData.error) {
42
+ let err = resData.error;
43
+ log.error("markAsRead", err);
44
+ if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
45
+ callback(err);
46
+ return err;
47
+ }
48
+
49
+ callback(null);
50
+ return null;
51
+ }
52
+ else {
53
+ try {
54
+ if (ctx.mqttClient) {
55
+ let err = await new Promise(r => ctx.mqttClient.publish("/mark_thread", JSON.stringify({
56
+ threadID,
57
+ mark: "read",
58
+ state: read
59
+ }), { qos: 1, retain: false }, r));
60
+ if (err) throw err;
61
+ callback(null); // signal success to caller
62
+ }
63
+ else throw { error: "You can only use this function after you start listening." };
64
+ }
65
+ catch (e) {
66
+ log.error("markAsRead", e);
67
+ callback(e);
68
+ return e;
69
+ }
70
+ }
71
+ };
72
+ };
@@ -0,0 +1,40 @@
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 markAsReadAll(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
+ var form = {
23
+ folder: 'inbox'
24
+ };
25
+
26
+ defaultFuncs
27
+ .post("https://www.facebook.com/ajax/mercury/mark_folder_as_read.php", ctx.jar, form)
28
+ .then(utils.saveCookies(ctx.jar))
29
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
30
+ .then(function (resData) {
31
+ if (resData.error) throw resData;
32
+ return callback();
33
+ })
34
+ .catch(function (err) {
35
+ log.error("markAsReadAll", err);
36
+ return callback(err);
37
+ });
38
+ return returnPromise;
39
+ };
40
+ };
@@ -0,0 +1,48 @@
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 markAsRead(seen_timestamp, callback) {
8
+ if (utils.getType(seen_timestamp) == "Function" ||
9
+ utils.getType(seen_timestamp) == "AsyncFunction") {
10
+ callback = seen_timestamp;
11
+ seen_timestamp = Date.now();
12
+ }
13
+
14
+ var resolveFunc = function () { };
15
+ var rejectFunc = function () { };
16
+ var returnPromise = new Promise(function (resolve, reject) {
17
+ resolveFunc = resolve;
18
+ rejectFunc = reject;
19
+ });
20
+
21
+ if (!callback) {
22
+ callback = function (err, data) {
23
+ if (err) return rejectFunc(err);
24
+
25
+ resolveFunc(data);
26
+ };
27
+ }
28
+
29
+ var form = {
30
+ seen_timestamp: seen_timestamp
31
+ };
32
+
33
+ defaultFuncs
34
+ .post("https://www.facebook.com/ajax/mercury/mark_seen.php", ctx.jar, form)
35
+ .then(utils.saveCookies(ctx.jar))
36
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
37
+ .then(function (resData) {
38
+ if (resData.error) throw resData;
39
+ return callback();
40
+ })
41
+ .catch(function (err) {
42
+ log.error("markAsSeen", err);
43
+ if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
44
+ return callback(err);
45
+ });
46
+ return returnPromise;
47
+ };
48
+ };
@@ -0,0 +1,189 @@
1
+ /**
2
+ * ===========================================================
3
+ * 💫 META THEME GENERATOR MODULE 💫
4
+ * ===========================================================
5
+ * 🧑‍💻 Author: HRIDOY (HRIDOY)
6
+ * 🔰 Owner & Developer
7
+ * 🌐 GitHub: https://github.com/hridoy-dev
8
+ * 🧠 Description:
9
+ * This module generates beautiful Messenger AI themes
10
+ * using Meta's hidden GraphQL endpoints. It allows you to
11
+ * create unique chat themes based on your custom prompt
12
+ * or optional image inspiration.
13
+ * -----------------------------------------------------------
14
+ * ⚙️ Features:
15
+ * • Generate AI-based Messenger chat themes.
16
+ * • Custom prompt & optional image URL input.
17
+ * • Returns structured theme data with full color mapping.
18
+ * -----------------------------------------------------------
19
+ * 🕊️ Respect the creator & give proper credits if reused.
20
+ * ===========================================================
21
+ */
22
+
23
+ "use strict";
24
+
25
+ const utils = require("../utils");
26
+ const log = require("npmlog");
27
+ /** © HRIDOY - Please give proper credits if you copy or reuse this code. */
28
+ module.exports = function (defaultFuncs, api, ctx) {
29
+ return function metaTheme(prompt, options, callback) {
30
+ var resolveFunc = function () { };
31
+ var rejectFunc = function () { };
32
+ var returnPromise = new Promise(function (resolve, reject) {
33
+ resolveFunc = resolve;
34
+ rejectFunc = reject;
35
+ });
36
+
37
+ // Handle optional parameters
38
+ if (typeof options === 'function') {
39
+ callback = options;
40
+ options = {};
41
+ }
42
+
43
+ if (!callback) {
44
+ callback = function (err, data) {
45
+ if (err) return rejectFunc(err);
46
+ resolveFunc(data);
47
+ };
48
+ }
49
+
50
+ if (!prompt || typeof prompt !== 'string') {
51
+ return callback({ error: "Prompt is required and must be a string" });
52
+ }
53
+
54
+ // Parse options
55
+ const numThemes = options.numThemes || 1;
56
+ const imageUrl = options.imageUrl || null;
57
+
58
+ const inputData = {
59
+ client_mutation_id: Math.floor(Math.random() * 10).toString(),
60
+ actor_id: ctx.userID,
61
+ bypass_cache: true,
62
+ caller: "MESSENGER",
63
+ num_themes: Math.min(numThemes, 5), // Limit to max 5 themes
64
+ prompt: prompt
65
+ };
66
+
67
+ // Add image URL if provided
68
+ if (imageUrl) {
69
+ inputData.image_url = imageUrl;
70
+ }
71
+
72
+ const form = {
73
+ av: ctx.userID,
74
+ __aaid: 0,
75
+ __user: ctx.userID,
76
+ __a: 1,
77
+ __req: utils.getSignatureID(),
78
+ __hs: "20358.HYP:comet_pkg.2.1...0",
79
+ dpr: 1,
80
+ __ccg: "EXCELLENT",
81
+ __rev: "1027673511",
82
+ __s: utils.getSignatureID(),
83
+ __hsi: "7554561631547849479",
84
+ __comet_req: 15,
85
+ fb_dtsg: ctx.fb_dtsg,
86
+ jazoest: ctx.ttstamp,
87
+ lsd: ctx.fb_dtsg,
88
+ __spin_r: "1027673511",
89
+ __spin_b: "trunk",
90
+ __spin_t: Date.now(),
91
+ __crn: "comet.fbweb.MWInboxHomeRoute",
92
+ qpl_active_flow_ids: "25309433,521485406",
93
+ fb_api_caller_class: "RelayModern",
94
+ fb_api_req_friendly_name: "useGenerateAIThemeMutation",
95
+ variables: JSON.stringify({ input: inputData }),
96
+ server_timestamps: true,
97
+ doc_id: "23873748445608673",
98
+ fb_api_analytics_tags: JSON.stringify(["qpl_active_flow_ids=25309433,521485406"])
99
+ };
100
+
101
+ defaultFuncs
102
+ .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
103
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
104
+ .then(function (resData) {
105
+ if (resData.errors) {
106
+ throw resData.errors;
107
+ }
108
+
109
+ if (resData.data && resData.data.xfb_generate_ai_themes_from_prompt) {
110
+ const themeData = resData.data.xfb_generate_ai_themes_from_prompt;
111
+ if (themeData.success && themeData.themes && themeData.themes.length > 0) {
112
+ const themes = themeData.themes.map((theme, index) => ({
113
+ success: true,
114
+ themeId: theme.id,
115
+ name: theme.accessibility_label,
116
+ description: theme.description,
117
+ serialNumber: index + 1,
118
+ colors: {
119
+ composerBackground: theme.composer_background_color,
120
+ backgroundGradient: theme.background_gradient_colors,
121
+ titleBarButton: theme.title_bar_button_tint_color,
122
+ inboundMessageGradient: theme.inbound_message_gradient_colors,
123
+ titleBarText: theme.title_bar_text_color,
124
+ composerTint: theme.composer_tint_color,
125
+ messageText: theme.message_text_color,
126
+ primaryButton: theme.primary_button_background_color,
127
+ titleBarBackground: theme.title_bar_background_color,
128
+ fallback: theme.fallback_color,
129
+ gradient: theme.gradient_colors
130
+ },
131
+ backgroundImage: theme.background_asset ? theme.background_asset.image.uri : null,
132
+ iconImage: theme.icon_asset ? theme.icon_asset.image.uri : null,
133
+ images: {
134
+ background: theme.background_asset ? theme.background_asset.image.uri : null,
135
+ icon: theme.icon_asset ? theme.icon_asset.image.uri : null
136
+ },
137
+ alternativeThemes: theme.alternative_themes ? theme.alternative_themes.map(alt => ({
138
+ id: alt.id,
139
+ name: alt.accessibility_label,
140
+ backgroundImage: alt.background_asset ? alt.background_asset.image.uri : null,
141
+ iconImage: alt.icon_asset ? alt.icon_asset.image.uri : null
142
+ })) : []
143
+ }));
144
+
145
+ const result = {
146
+ success: true,
147
+ count: themes.length,
148
+ themes: themes,
149
+ // For backward compatibility, include first theme data at root level
150
+ ...themes[0]
151
+ };
152
+ return callback(null, result);
153
+ } else {
154
+ throw new Error("No themes generated for the given prompt");
155
+ }
156
+ } else {
157
+ throw new Error("Invalid response from AI theme generation");
158
+ }
159
+ })
160
+ .catch(function (err) {
161
+ log.error("metaTheme", err);
162
+
163
+ // Check for specific error conditions
164
+ let errorMessage = "An error occurred while generating themes";
165
+
166
+ if (err.message && err.message.includes("not authorized")) {
167
+ errorMessage = "Your account is not authorized to generate AI themes. This feature may not be available for your account type.";
168
+ } else if (err.message && err.message.includes("rate limit")) {
169
+ errorMessage = "Rate limit exceeded. Please wait a moment before trying again.";
170
+ } else if (err.message && err.message.includes("Invalid")) {
171
+ errorMessage = "Invalid request parameters. Please check your input.";
172
+ } else if (err.statusCode === 403) {
173
+ errorMessage = "Access denied. Your account may not support Meta AI theme generation.";
174
+ } else if (err.statusCode === 429) {
175
+ errorMessage = "Too many requests. Please wait before trying again.";
176
+ }
177
+
178
+ return callback({
179
+ error: errorMessage,
180
+ originalError: err.message || err,
181
+ statusCode: err.statusCode || null
182
+ });
183
+ });
184
+
185
+ return returnPromise;
186
+ };
187
+ };
188
+
189
+ /** © HRIDOY - Please give proper credits if you copy or reuse this code. */
@@ -0,0 +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, 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
+ };