@cexy/hoonfca 1.0.1 → 1.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 (170) hide show
  1. package/.travis.yml +6 -0
  2. package/LICENSE-MIT +21 -0
  3. package/index.d.ts +620 -0
  4. package/index.js +778 -1
  5. package/package.json +31 -84
  6. package/src/{apis/addExternalModule.js → addExternalModule.js} +4 -5
  7. package/src/addUserToGroup.js +113 -0
  8. package/src/changeAdminStatus.js +95 -0
  9. package/src/changeApprovalMode.js +79 -0
  10. package/src/changeArchivedStatus.js +55 -0
  11. package/src/changeBio.js +76 -0
  12. package/src/changeBlockedStatus.js +47 -0
  13. package/src/changeBlockedStatusMqtt.js +86 -0
  14. package/src/changeGroupImage.js +133 -0
  15. package/src/changeNickname.js +59 -0
  16. package/src/changeThreadColor.js +71 -0
  17. package/src/{apis/changeThreadEmoji.js → changeThreadEmoji.js} +8 -6
  18. package/src/createNewGroup.js +88 -0
  19. package/src/createPoll.js +130 -0
  20. package/src/deleteMessage.js +56 -0
  21. package/src/deleteThread.js +56 -0
  22. package/src/editMessage.js +63 -0
  23. package/src/forwardAttachment.js +60 -0
  24. package/src/forwardMessage.js +63 -0
  25. package/src/getCurrentUserID.js +7 -0
  26. package/src/getEmojiUrl.js +29 -0
  27. package/src/getFriendsList.js +84 -0
  28. package/src/getGroupsList.js +83 -0
  29. package/src/getMarketplace.js +84 -0
  30. package/src/getNotifications.js +86 -0
  31. package/src/getPagesList.js +83 -0
  32. package/src/getStories.js +88 -0
  33. package/src/getThreadHistory.js +647 -0
  34. package/src/getThreadInfo.js +222 -0
  35. package/src/getThreadList.js +292 -0
  36. package/src/getThreadPictures.js +79 -0
  37. package/src/getUserID.js +66 -0
  38. package/src/getUserInfo.js +128 -0
  39. package/src/handleFriendRequest.js +57 -0
  40. package/src/handleMessageRequest.js +65 -0
  41. package/src/{apis/httpGet.js → httpGet.js} +15 -20
  42. package/src/httpPost.js +58 -0
  43. package/src/listenMqtt.js +1018 -0
  44. package/src/logout.js +75 -0
  45. package/src/markAsDelivered.js +58 -0
  46. package/src/{apis/markAsRead.js → markAsRead.js} +19 -30
  47. package/src/markAsReadAll.js +50 -0
  48. package/src/markAsSeen.js +61 -0
  49. package/src/muteThread.js +52 -0
  50. package/src/pinMessage.js +61 -0
  51. package/src/removeUserFromGroup.js +79 -0
  52. package/src/resolvePhotoUrl.js +45 -0
  53. package/src/searchForThread.js +53 -0
  54. package/src/searchUsers.js +89 -0
  55. package/src/sendComment.js +161 -0
  56. package/src/sendMessage.js +457 -0
  57. package/src/sendTypingIndicator.js +179 -0
  58. package/src/setBio.js +86 -0
  59. package/src/setMessageReaction.js +186 -0
  60. package/src/setPostReaction.js +71 -0
  61. package/src/setTheme.js +313 -0
  62. package/src/setTitle.js +90 -0
  63. package/src/shareContact.js +53 -0
  64. package/src/shareLink.js +62 -0
  65. package/src/threadColors.js +57 -0
  66. package/src/unfriend.js +53 -0
  67. package/src/unsendMessage.js +104 -0
  68. package/utils.js +1447 -0
  69. package/LICENSE +0 -3
  70. package/README.md +0 -491
  71. package/examples/login-with-cookies.js +0 -102
  72. package/examples/verify.js +0 -70
  73. package/src/apis/addUserToGroup.js +0 -108
  74. package/src/apis/changeAdminStatus.js +0 -148
  75. package/src/apis/changeArchivedStatus.js +0 -61
  76. package/src/apis/changeAvatar.js +0 -103
  77. package/src/apis/changeBio.js +0 -69
  78. package/src/apis/changeBlockedStatus.js +0 -54
  79. package/src/apis/changeGroupImage.js +0 -136
  80. package/src/apis/changeThreadColor.js +0 -116
  81. package/src/apis/comment.js +0 -207
  82. package/src/apis/createAITheme.js +0 -129
  83. package/src/apis/createNewGroup.js +0 -79
  84. package/src/apis/createPoll.js +0 -73
  85. package/src/apis/deleteMessage.js +0 -44
  86. package/src/apis/deleteThread.js +0 -52
  87. package/src/apis/e2ee.js +0 -17
  88. package/src/apis/editMessage.js +0 -70
  89. package/src/apis/emoji.js +0 -124
  90. package/src/apis/fetchThemeData.js +0 -82
  91. package/src/apis/follow.js +0 -81
  92. package/src/apis/forwardMessage.js +0 -52
  93. package/src/apis/friend.js +0 -243
  94. package/src/apis/gcmember.js +0 -122
  95. package/src/apis/gcname.js +0 -123
  96. package/src/apis/gcrule.js +0 -119
  97. package/src/apis/getAccess.js +0 -111
  98. package/src/apis/getBotInfo.js +0 -88
  99. package/src/apis/getBotInitialData.js +0 -43
  100. package/src/apis/getFriendsList.js +0 -79
  101. package/src/apis/getMessage.js +0 -423
  102. package/src/apis/getTheme.js +0 -95
  103. package/src/apis/getThemeInfo.js +0 -116
  104. package/src/apis/getThreadHistory.js +0 -239
  105. package/src/apis/getThreadInfo.js +0 -267
  106. package/src/apis/getThreadList.js +0 -232
  107. package/src/apis/getThreadPictures.js +0 -58
  108. package/src/apis/getUserID.js +0 -117
  109. package/src/apis/getUserInfo.js +0 -513
  110. package/src/apis/getUserInfoV2.js +0 -146
  111. package/src/apis/handleMessageRequest.js +0 -50
  112. package/src/apis/httpPost.js +0 -89
  113. package/src/apis/httpPostFormData.js +0 -69
  114. package/src/apis/listenMqtt.js +0 -1236
  115. package/src/apis/listenSpeed.js +0 -179
  116. package/src/apis/logout.js +0 -87
  117. package/src/apis/markAsDelivered.js +0 -47
  118. package/src/apis/markAsReadAll.js +0 -40
  119. package/src/apis/markAsSeen.js +0 -70
  120. package/src/apis/mqttDeltaValue.js +0 -278
  121. package/src/apis/muteThread.js +0 -45
  122. package/src/apis/nickname.js +0 -132
  123. package/src/apis/notes.js +0 -163
  124. package/src/apis/pinMessage.js +0 -150
  125. package/src/apis/produceMetaTheme.js +0 -180
  126. package/src/apis/realtime.js +0 -182
  127. package/src/apis/removeUserFromGroup.js +0 -117
  128. package/src/apis/resolvePhotoUrl.js +0 -58
  129. package/src/apis/searchForThread.js +0 -154
  130. package/src/apis/sendMessage.js +0 -354
  131. package/src/apis/sendMessageMqtt.js +0 -249
  132. package/src/apis/sendTypingIndicator.js +0 -91
  133. package/src/apis/setMessageReaction.js +0 -27
  134. package/src/apis/setMessageReactionMqtt.js +0 -61
  135. package/src/apis/setThreadTheme.js +0 -260
  136. package/src/apis/setThreadThemeMqtt.js +0 -94
  137. package/src/apis/share.js +0 -107
  138. package/src/apis/shareContact.js +0 -66
  139. package/src/apis/stickers.js +0 -257
  140. package/src/apis/story.js +0 -181
  141. package/src/apis/theme.js +0 -233
  142. package/src/apis/unfriend.js +0 -47
  143. package/src/apis/unsendMessage.js +0 -17
  144. package/src/engine/client.js +0 -92
  145. package/src/engine/models/buildAPI.js +0 -152
  146. package/src/engine/models/loginHelper.js +0 -519
  147. package/src/engine/models/setOptions.js +0 -88
  148. package/src/security/e2ee.js +0 -109
  149. package/src/types/index.d.ts +0 -498
  150. package/src/utils/antiSuspension.js +0 -506
  151. package/src/utils/auth-helpers.js +0 -149
  152. package/src/utils/autoReLogin.js +0 -336
  153. package/src/utils/axios.js +0 -436
  154. package/src/utils/cache.js +0 -54
  155. package/src/utils/clients.js +0 -282
  156. package/src/utils/constants.js +0 -410
  157. package/src/utils/formatters/data/formatAttachment.js +0 -370
  158. package/src/utils/formatters/data/formatDelta.js +0 -109
  159. package/src/utils/formatters/index.js +0 -159
  160. package/src/utils/formatters/value/formatCookie.js +0 -91
  161. package/src/utils/formatters/value/formatDate.js +0 -36
  162. package/src/utils/formatters/value/formatID.js +0 -16
  163. package/src/utils/formatters.js +0 -1373
  164. package/src/utils/headers.js +0 -230
  165. package/src/utils/index.js +0 -153
  166. package/src/utils/monitoring.js +0 -333
  167. package/src/utils/rateLimiter.js +0 -319
  168. package/src/utils/tokenRefresh.js +0 -657
  169. package/src/utils/user-agents.js +0 -238
  170. package/src/utils/validation.js +0 -157
package/src/apis/story.js DELETED
@@ -1,181 +0,0 @@
1
- "use strict";
2
-
3
- const utils = require('../utils');
4
- const { URL } = require('url');
5
-
6
- /**
7
- * @namespace api.story
8
- * @description A collection of functions for interacting with Facebook Stories.
9
- * @license Ex-it
10
- * @author Jonell Magallanes, ChoruOfficial
11
- */
12
- module.exports = function (defaultFuncs, api, ctx) {
13
-
14
- /**
15
- * (Internal) Extracts the Story ID from a Facebook story URL.
16
- * @param {string} url The Facebook story URL.
17
- * @returns {string|null} The extracted Story ID or null if not found.
18
- */
19
- function getStoryIDFromURL(url) {
20
- try {
21
- const urlObject = new URL(url);
22
- const pathParts = urlObject.pathname.split('/');
23
- const storiesIndex = pathParts.indexOf('stories');
24
- if (storiesIndex !== -1 && pathParts.length > storiesIndex + 2) {
25
- return pathParts[storiesIndex + 2];
26
- }
27
- return null;
28
- } catch (e) {
29
- return null;
30
- }
31
- }
32
-
33
- /**
34
- * (Internal) The core function to send a reply or reaction to a story.
35
- * @param {string} storyIdOrUrl The ID or URL of the story.
36
- * @param {string} message The text message or emoji reaction.
37
- * @param {boolean} isReaction True if the reply is a lightweight reaction.
38
- * @returns {Promise<object>} The server's response.
39
- */
40
- async function sendStoryReply(storyIdOrUrl, message, isReaction) {
41
- try {
42
- const allowedReactions = ["❤️", "👍", "🤗", "😆", "😡", "😢", "😮"];
43
-
44
- if (!storyIdOrUrl) throw new Error("Story ID or URL is required.");
45
- if (!message) throw new Error("A message or reaction is required.");
46
-
47
- let storyID = getStoryIDFromURL(storyIdOrUrl);
48
- if (!storyID) storyID = storyIdOrUrl;
49
-
50
- const variables = {
51
- input: {
52
- attribution_id_v2: "StoriesCometSuspenseRoot.react,comet.stories.viewer,via_cold_start",
53
- message: message,
54
- story_id: storyID,
55
- story_reply_type: isReaction ? "LIGHT_WEIGHT" : "TEXT",
56
- actor_id: ctx.userID,
57
- client_mutation_id: Math.floor(Math.random() * 10 + 1).toString()
58
- }
59
- };
60
-
61
- if (isReaction) {
62
- if (!allowedReactions.includes(message)) {
63
- throw new Error(`Invalid reaction. Please use one of: ${allowedReactions.join(" ")}`);
64
- }
65
- variables.input.lightweight_reaction_actions = {
66
- offsets: [0],
67
- reaction: message,
68
- };
69
- }
70
-
71
- const form = {
72
- av: ctx.userID,
73
- __user: ctx.userID,
74
- __a: "1",
75
- fb_dtsg: ctx.fb_dtsg,
76
- jazoest: ctx.jazoest,
77
- fb_api_caller_class: "RelayModern",
78
- fb_api_req_friendly_name: "useStoriesSendReplyMutation",
79
- variables: JSON.stringify(variables),
80
- doc_id: "9697491553691692"
81
- };
82
-
83
- const res = await defaultFuncs.post("https://www.facebook.com/api/graphql/", ctx.jar, form, {});
84
- if (res.data.errors) throw new Error(JSON.stringify(res.data.errors));
85
-
86
- const storyReplyData = res.data?.data?.direct_message_reply;
87
- if (!storyReplyData) throw new Error("Could not find 'direct_message_reply' in the response data.");
88
-
89
- return { success: true, result: storyReplyData };
90
- } catch (err) {
91
- console.error("Error in story reply API:", err);
92
- throw err;
93
- }
94
- }
95
-
96
- /**
97
- * Creates a new text-based story.
98
- * @param {string} message The text content of the story.
99
- * @param {string} [fontName="classic"] The name of the font to use. Options: `headline`, `classic`, `casual`, `fancy`.
100
- * @param {string} [backgroundName="blue"] The name of the background to use. Options: `orange`, `blue`, `green`, `modern`.
101
- * @returns {Promise<{success: boolean, storyID: string}>} A promise that resolves with the new story's ID.
102
- */
103
- async function create(message, fontName = "classic", backgroundName = "blue") {
104
- const fontMap = {
105
- headline: "1919119914775364",
106
- classic: "516266749248495",
107
- casual: "516266749248495",
108
- fancy: "1790435664339626"
109
- };
110
- const bgMap = {
111
- orange: "2163607613910521",
112
- blue: "401372137331149",
113
- green: "367314917184744",
114
- modern: "554617635055752"
115
- };
116
-
117
- const fontId = fontMap[fontName.toLowerCase()] || fontMap.classic;
118
- const bgId = bgMap[backgroundName.toLowerCase()] || bgMap.blue;
119
-
120
- const variables = {
121
- input: {
122
- audiences: [{ stories: { self: { target_id: ctx.userID } } }],
123
- audiences_is_complete: true,
124
- logging: { composer_session_id: "createStoriesText-" + Date.now() },
125
- navigation_data: { attribution_id_v2: "StoriesCreateRoot.react,comet.stories.create" },
126
- source: "WWW",
127
- message: { ranges: [], text: message },
128
- text_format_metadata: { inspirations_custom_font_id: fontId },
129
- text_format_preset_id: bgId,
130
- tracking: [null],
131
- actor_id: ctx.userID,
132
- client_mutation_id: "2"
133
- }
134
- };
135
-
136
- const form = {
137
- __a: "1",
138
- fb_api_caller_class: "RelayModern",
139
- fb_api_req_friendly_name: "StoriesCreateMutation",
140
- variables: JSON.stringify(variables),
141
- doc_id: "24226878183562473"
142
- };
143
-
144
- try {
145
- const res = await defaultFuncs.post("https://www.facebook.com/api/graphql/", ctx.jar, form, {});
146
- if (res.data.errors) throw new Error(JSON.stringify(res.data.errors));
147
-
148
- const storyNode = res.data?.data?.story_create?.viewer?.actor?.story_bucket?.nodes[0]?.first_story_to_show;
149
- if (!storyNode || !storyNode.id) throw new Error("Could not find the storyCardID in the response.");
150
-
151
- return { success: true, storyID: storyNode.id };
152
- } catch (error) {
153
- throw error;
154
- }
155
- }
156
-
157
- return {
158
- /**
159
- * Creates a new text-based story.
160
- * @param {string} message The text content of the story.
161
- * @param {string} [fontName="classic"] The font to use (`headline`, `classic`, `fancy`).
162
- * @param {string} [backgroundName="blue"] The background to use (`orange`, `blue`, `green`, `modern`).
163
- * @returns {Promise<{success: boolean, storyID: string}>}
164
- */
165
- create,
166
- /**
167
- * Reacts to a story with a specific emoji.
168
- * @param {string} storyIdOrUrl The ID or full URL of the story to react to.
169
- * @param {string} reaction The emoji to react with. Must be one of: ❤️, 👍, 🤗, 😆, 😡, 😢, 😮.
170
- * @returns {Promise<{success: boolean, result: object}>}
171
- */
172
- react: (storyIdOrUrl, reaction) => sendStoryReply(storyIdOrUrl, reaction, true),
173
- /**
174
- * Sends a text message reply to a story.
175
- * @param {string} storyIdOrUrl The ID or full URL of the story to reply to.
176
- * @param {string} message The text message to send.
177
- * @returns {Promise<{success: boolean, result: object}>}
178
- */
179
- msg: (storyIdOrUrl, message) => sendStoryReply(storyIdOrUrl, message, false)
180
- };
181
- };
package/src/apis/theme.js DELETED
@@ -1,233 +0,0 @@
1
- "use strict";
2
-
3
- const utils = require('../utils');
4
-
5
- module.exports = function (defaultFuncs, api, ctx) {
6
- /**
7
- * Made by Choru Official
8
- * Mqtt & Graph
9
- * Manages or sets the custom theme for a Facebook thread.
10
- * If only a theme name/keyword is provided, it attempts to find and set the matching theme.
11
- * If "list" is provided as the themeName, it lists available themes.
12
- *
13
- * @param {string} themeName The name or partial name of the theme (case-insensitive), or "list" to list themes.
14
- * @param {string} threadID The ID of the thread.
15
- * @param {Function} [callback] Optional callback function.
16
- * @param {string} [initiatorID] The ID of the user who initiated the theme change (e.g., from event.senderID).
17
- * @returns {Promise<void|Array<object>|object>} A promise that resolves on success (for setting theme, with a detailed event object), or with an array of themes (for listing), or rejects on error.
18
- */
19
- return async function theme(themeName, threadID, callback, initiatorID) {
20
- let _callback;
21
- let _initiatorID;
22
-
23
- let _resolveFunc;
24
- let _rejectFunc;
25
- const finalReturnPromise = new Promise((resolve, reject) => {
26
- _resolveFunc = resolve;
27
- _rejectFunc = reject;
28
- });
29
-
30
- if (utils.getType(callback) === "Function" || utils.getType(callback) === "AsyncFunction") {
31
- _callback = callback;
32
- _initiatorID = initiatorID;
33
- } else if (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction") {
34
- _callback = threadID;
35
- threadID = null;
36
- _initiatorID = callback;
37
- } else if (utils.getType(callback) === "string") {
38
- _initiatorID = callback;
39
- _callback = undefined;
40
- } else {
41
- _callback = undefined;
42
- _initiatorID = undefined;
43
- }
44
-
45
- if (!_callback) {
46
- _callback = function (_err, _data) {
47
- if (_err) _rejectFunc(_err);
48
- else _resolveFunc(_data);
49
- };
50
- }
51
-
52
- _initiatorID = _initiatorID || ctx.userID;
53
-
54
- threadID = threadID || ctx.threadID;
55
-
56
- if (!threadID) {
57
- return _callback(new Error("threadID is required to manage themes."));
58
- }
59
- if (!themeName) {
60
- return _callback(new Error("themeName (or 'list') is required."));
61
- }
62
-
63
- if (!ctx.mqttClient) {
64
- return _callback(new Error("Not connected to MQTT"));
65
- }
66
-
67
- const fetchThemes = async () => {
68
- const form = {
69
- fb_api_caller_class: 'RelayModern',
70
- fb_api_req_friendly_name: 'MWPThreadThemeQuery_AllThemesQuery',
71
- variables: JSON.stringify({ version: "default" }),
72
- server_timestamps: true,
73
- doc_id: '24474714052117636',
74
- };
75
-
76
- try {
77
- const resData = await defaultFuncs
78
- .post("https://www.facebook.com/api/graphql/", ctx.jar, form, null, {
79
- "x-fb-friendly-name": "MWPThreadThemeQuery_AllThemesQuery",
80
- "x-fb-lsd": ctx.lsd,
81
- "referer": `https://www.facebook.com/messages/t/${threadID}`
82
- })
83
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs));
84
-
85
- if (resData.errors) {
86
- throw new Error(JSON.stringify(resData.errors));
87
- }
88
- if (!resData.data || !resData.data.messenger_thread_themes) {
89
- throw new Error("Could not retrieve thread themes from response.");
90
- }
91
- return resData.data.messenger_thread_themes.map(themeData => {
92
- if (!themeData || !themeData.id) return null;
93
-
94
- return {
95
- id: themeData.id,
96
- name: themeData.accessibility_label,
97
- description: themeData.description,
98
- appColorMode: themeData.app_color_mode,
99
- composerBackgroundColor: themeData.composer_background_color,
100
- backgroundGradientColors: themeData.background_gradient_colors,
101
- titleBarButtonTintColor: themeData.title_bar_button_tint_color,
102
- inboundMessageGradientColors: themeData.inbound_message_gradient_colors,
103
- titleBarTextColor: themeData.title_bar_text_color,
104
- composerTintColor: themeData.composer_tint_color,
105
- titleBarAttributionColor: themeData.title_bar_attribution_color,
106
- composerInputBackgroundColor: themeData.composer_input_background_color,
107
- hotLikeColor: themeData.hot_like_color,
108
- backgroundImage: themeData.background_asset?.image?.uri,
109
- messageTextColor: themeData.message_text_color,
110
- inboundMessageTextColor: themeData.inbound_message_text_color,
111
- primaryButtonBackgroundColor: themeData.primary_button_background_color,
112
- titleBarBackgroundColor: themeData.title_bar_background_color,
113
- tertiaryTextColor: themeData.tertiary_text_color,
114
- reactionPillBackgroundColor: themeData.reaction_pill_background_color,
115
- secondaryTextColor: themeData.secondary_text_color,
116
- fallbackColor: themeData.fallback_color,
117
- gradientColors: themeData.gradient_colors,
118
- normalThemeId: themeData.normal_theme_id,
119
- iconAsset: themeData.icon_asset?.image?.uri,
120
- };
121
- }).filter(Boolean);
122
- } catch (fetchErr) {
123
- throw new Error(`Failed to fetch theme list: ${fetchErr.message || fetchErr}`);
124
- }
125
- };
126
-
127
- const setThreadTheme = async (themeIDToSet, actualThemeName, initiatorID) => {
128
- let currentEpochId = parseInt(utils.generateOfflineThreadingID());
129
-
130
- const createAndPublish = (label, queueName, payload) => {
131
- currentEpochId = parseInt(utils.generateOfflineThreadingID());
132
- ctx.wsReqNumber += 1;
133
- ctx.wsTaskNumber += 1;
134
-
135
- const request_id = ctx.wsReqNumber;
136
-
137
- const queryPayload = {
138
- thread_key: threadID.toString(),
139
- theme_fbid: themeIDToSet.toString(),
140
- sync_group: 1,
141
- ...payload
142
- };
143
-
144
- const query = {
145
- failure_count: null,
146
- label: label,
147
- payload: JSON.stringify(queryPayload),
148
- queue_name: queueName,
149
- task_id: ctx.wsTaskNumber,
150
- };
151
-
152
- const context = {
153
- app_id: ctx.appID,
154
- payload: {
155
- epoch_id: currentEpochId,
156
- tasks: [query],
157
- version_id: '24631415369801570',
158
- },
159
- request_id: request_id,
160
- type: 3,
161
- };
162
- context.payload = JSON.stringify(context.payload);
163
-
164
- return new Promise((res, rej) => {
165
- ctx.mqttClient.publish('/ls_req', JSON.stringify(context), { qos: 1, retain: false }, err => {
166
- if (err) {
167
- return rej(new Error(`MQTT publish failed for request ${request_id}: ${err.message}`));
168
- }
169
- res();
170
- });
171
- });
172
- };
173
-
174
- try {
175
- await Promise.all([
176
- createAndPublish('1013', `ai_generated_theme`, {}),
177
- createAndPublish('1037', `msgr_custom_thread_theme`, {}),
178
- createAndPublish('1028', `thread_theme_writer`, {}),
179
- createAndPublish('43', `thread_theme`, { source: null, payload: null })
180
- ]);
181
-
182
- return {
183
- type: "thread_theme_update",
184
- threadID: threadID,
185
- themeID: themeIDToSet,
186
- themeName: actualThemeName,
187
- senderID: initiatorID,
188
- BotID: ctx.userID,
189
- timestamp: Date.now(),
190
- };
191
-
192
- } catch (publishErr) {
193
- throw new Error(`Failed to publish theme change MQTT messages: ${publishErr.message || publishErr}`);
194
- }
195
- };
196
-
197
- try {
198
- if (themeName.toLowerCase() === "list") {
199
- const themes = await fetchThemes();
200
- _callback(null, themes);
201
- } else {
202
- const themes = await fetchThemes();
203
- const normalizedThemeName = themeName.toLowerCase();
204
-
205
- let matchedTheme = null;
206
-
207
- if (!isNaN(normalizedThemeName)) {
208
- matchedTheme = themes.find(t => t.id === normalizedThemeName);
209
- }
210
- if (!matchedTheme) {
211
- matchedTheme = themes.find(t => t.name.toLowerCase() === normalizedThemeName);
212
- }
213
-
214
- if (!matchedTheme) {
215
- matchedTheme = themes.find(t => t.name.toLowerCase().includes(normalizedThemeName));
216
- }
217
-
218
- if (!matchedTheme) {
219
- throw new Error(`Theme "${themeName}" not found. Try '/theme list' for available themes.`);
220
- }
221
-
222
- const themeEventObject = await setThreadTheme(matchedTheme.id, matchedTheme.name, _initiatorID);
223
-
224
- _callback(null, themeEventObject);
225
- }
226
- } catch (err) {
227
- const finalError = err instanceof Error ? err : new Error(err.message || err.error || 'An unknown error occurred during theme operation.');
228
- _callback(finalError);
229
- }
230
-
231
- return finalReturnPromise;
232
- };
233
- };
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- const utils = require('../utils');
4
-
5
- module.exports = (defaultFuncs, api, ctx) => {
6
- return async function unfriend(userID, callback) {
7
- let resolveFunc = () => {};
8
- let rejectFunc = () => {};
9
- const returnPromise = new Promise((resolve, reject) => {
10
- resolveFunc = resolve;
11
- rejectFunc = reject;
12
- });
13
-
14
- if (!callback) {
15
- callback = (err, result) => {
16
- if (err) return rejectFunc(err);
17
- resolveFunc(result);
18
- };
19
- }
20
-
21
- try {
22
- const form = {
23
- uid: userID,
24
- unref: "bd_friends_tab",
25
- floc: "friends_tab",
26
- "nctr[_mod]": "pagelet_timeline_app_collection_" + ctx.userID + ":2356318349:2"
27
- };
28
-
29
- const res = await defaultFuncs.post(
30
- "https://www.facebook.com/ajax/profile/removefriendconfirm.php",
31
- ctx.jar,
32
- form
33
- ).then(utils.parseAndCheckLogin(ctx, defaultFuncs));
34
-
35
- if (res.error) {
36
- throw res;
37
- }
38
-
39
- callback(null, true);
40
- } catch (err) {
41
- utils.error("unfriend", err);
42
- callback(err);
43
- }
44
-
45
- return returnPromise;
46
- };
47
- };
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- const utils = require('../utils');
4
-
5
-
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return async (messageID) => {
8
- const defData = await defaultFuncs.post("https://www.facebook.com/messaging/unsend_message/", ctx.jar, {
9
- message_id: messageID
10
- })
11
- const resData = await utils.parseAndCheckLogin(ctx, defaultFuncs)(defData);
12
- if (resData.error) {
13
- throw new Error(resData);
14
- }
15
- return resData;
16
- };
17
- };
@@ -1,92 +0,0 @@
1
- "use strict";
2
-
3
- const utils = require("../utils");
4
- const setOptionsModel = require('./models/setOptions');
5
- const buildAPIModel = require('./models/buildAPI');
6
- const loginHelperModel = require('./models/loginHelper');
7
-
8
- let globalOptions = {};
9
- let ctx = null;
10
- let defaultFuncs = null;
11
- let api = null;
12
-
13
- const fbLink = (ext) => ("https://www.facebook.com" + (ext ? '/' + ext : ''));
14
- const ERROR_RETRIEVING = "Error retrieving userID. This can be caused by many factors, including being blocked by Facebook for logging in from an unknown location. Try logging in with a browser to verify.";
15
-
16
- /**
17
- * Initiates the login process for a Facebook account.
18
- *
19
- * @param {object} credentials The user's login credentials (e.g., email/password or appState cookies).
20
- * @param {object} [options={}] Optional login configurations.
21
- * @param {function} [callback] Optional callback function. If omitted, returns a Promise.
22
- * @returns {Promise|void} Returns Promise if no callback provided, otherwise void.
23
- */
24
- async function login(credentials, options, callback) {
25
- if (typeof options === "function") {
26
- callback = options;
27
- options = {};
28
- }
29
-
30
- let promiseCallback = null;
31
- let rejectFunc = null;
32
- let resolveFunc = null;
33
- let returnPromise = null;
34
-
35
- if (typeof callback !== "function") {
36
- returnPromise = new Promise(function (resolve, reject) {
37
- resolveFunc = resolve;
38
- rejectFunc = reject;
39
- });
40
- promiseCallback = function (error, api) {
41
- if (error) return rejectFunc(error);
42
- return resolveFunc(api);
43
- };
44
- callback = promiseCallback;
45
- }
46
-
47
- if ('logging' in options) {
48
- utils.logOptions(options.logging);
49
- }
50
- const defaultOptions = {
51
- selfListen: false,
52
- listenEvents: true,
53
- listenTyping: false,
54
- simulateTyping: true,
55
- updatePresence: false,
56
- forceLogin: false,
57
- autoMarkDelivery: false,
58
- autoMarkRead: true,
59
- autoReconnect: true,
60
- online: true,
61
- emitReady: false,
62
- userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36",
63
- };
64
- Object.assign(globalOptions, defaultOptions, options);
65
-
66
- await setOptionsModel(globalOptions, options);
67
-
68
- loginHelperModel(
69
- credentials,
70
- globalOptions,
71
- (loginError, loginApi) => {
72
- if (loginError) {
73
- return callback(loginError);
74
- }
75
- api = loginApi;
76
- ctx = loginApi.ctx;
77
- defaultFuncs = loginApi.defaultFuncs;
78
- return callback(null, loginApi);
79
- },
80
- setOptionsModel,
81
- buildAPIModel,
82
- api,
83
- fbLink,
84
- ERROR_RETRIEVING
85
- );
86
-
87
- return returnPromise;
88
- }
89
-
90
- module.exports = {
91
- login
92
- };