bb-fca 2.0.9 → 2.0.11

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 (84) hide show
  1. package/dist/deltas/apis/messaging/editMessage.js +13 -24
  2. package/dist/deltas/apis/messaging/editMessage.js.map +1 -1
  3. package/dist/deltas/apis/messaging/emoji.js +34 -88
  4. package/dist/deltas/apis/messaging/emoji.js.map +1 -1
  5. package/dist/deltas/apis/messaging/gcmember.js +48 -101
  6. package/dist/deltas/apis/messaging/gcmember.js.map +1 -1
  7. package/dist/deltas/apis/messaging/gcname.js +28 -79
  8. package/dist/deltas/apis/messaging/gcname.js.map +1 -1
  9. package/dist/deltas/apis/messaging/gcrule.js +47 -105
  10. package/dist/deltas/apis/messaging/gcrule.js.map +1 -1
  11. package/dist/deltas/apis/messaging/markAsDelivered.js +10 -12
  12. package/dist/deltas/apis/messaging/markAsDelivered.js.map +1 -1
  13. package/dist/deltas/apis/messaging/markAsRead.js +25 -60
  14. package/dist/deltas/apis/messaging/markAsRead.js.map +1 -1
  15. package/dist/deltas/apis/messaging/markAsReadAll.js +9 -11
  16. package/dist/deltas/apis/messaging/markAsReadAll.js.map +1 -1
  17. package/dist/deltas/apis/messaging/markAsSeen.js +10 -37
  18. package/dist/deltas/apis/messaging/markAsSeen.js.map +1 -1
  19. package/dist/deltas/apis/messaging/nickname.js +38 -98
  20. package/dist/deltas/apis/messaging/nickname.js.map +1 -1
  21. package/dist/deltas/apis/messaging/notes.js +52 -90
  22. package/dist/deltas/apis/messaging/notes.js.map +1 -1
  23. package/dist/deltas/apis/messaging/resolvePhotoUrl.js +17 -42
  24. package/dist/deltas/apis/messaging/resolvePhotoUrl.js.map +1 -1
  25. package/dist/deltas/apis/messaging/sendMessage.js +14 -15
  26. package/dist/deltas/apis/messaging/sendMessage.js.map +1 -1
  27. package/dist/deltas/apis/messaging/sendTypingIndicator.js +7 -13
  28. package/dist/deltas/apis/messaging/sendTypingIndicator.js.map +1 -1
  29. package/dist/deltas/apis/messaging/setMessageReaction.js +24 -14
  30. package/dist/deltas/apis/messaging/setMessageReaction.js.map +1 -1
  31. package/dist/deltas/apis/messaging/shareContact.js +14 -12
  32. package/dist/deltas/apis/messaging/shareContact.js.map +1 -1
  33. package/dist/deltas/apis/messaging/stickers.js +4 -5
  34. package/dist/deltas/apis/messaging/stickers.js.map +1 -1
  35. package/dist/deltas/apis/messaging/theme.js +142 -213
  36. package/dist/deltas/apis/messaging/theme.js.map +1 -1
  37. package/dist/deltas/apis/messaging/unsendMessage.js +14 -7
  38. package/dist/deltas/apis/messaging/unsendMessage.js.map +1 -1
  39. package/dist/deltas/apis/posting/group.js +440 -11
  40. package/dist/deltas/apis/posting/group.js.map +1 -1
  41. package/dist/index.d.ts +18 -0
  42. package/dist/types/deltas/apis/messaging/editMessage.d.ts +4 -5
  43. package/dist/types/deltas/apis/messaging/emoji.d.ts +7 -1
  44. package/dist/types/deltas/apis/messaging/gcmember.d.ts +7 -1
  45. package/dist/types/deltas/apis/messaging/gcname.d.ts +9 -1
  46. package/dist/types/deltas/apis/messaging/gcrule.d.ts +7 -1
  47. package/dist/types/deltas/apis/messaging/markAsDelivered.d.ts +1 -2
  48. package/dist/types/deltas/apis/messaging/markAsRead.d.ts +1 -1
  49. package/dist/types/deltas/apis/messaging/markAsReadAll.d.ts +1 -2
  50. package/dist/types/deltas/apis/messaging/markAsSeen.d.ts +1 -1
  51. package/dist/types/deltas/apis/messaging/nickname.d.ts +7 -1
  52. package/dist/types/deltas/apis/messaging/notes.d.ts +13 -11
  53. package/dist/types/deltas/apis/messaging/resolvePhotoUrl.d.ts +4 -6
  54. package/dist/types/deltas/apis/messaging/sendMessage.d.ts +1 -1
  55. package/dist/types/deltas/apis/messaging/sendTypingIndicator.d.ts +1 -1
  56. package/dist/types/deltas/apis/messaging/setMessageReaction.d.ts +6 -1
  57. package/dist/types/deltas/apis/messaging/shareContact.d.ts +1 -2
  58. package/dist/types/deltas/apis/messaging/stickers.d.ts +1 -1
  59. package/dist/types/deltas/apis/messaging/theme.d.ts +8 -1
  60. package/dist/types/deltas/apis/messaging/unsendMessage.d.ts +6 -1
  61. package/dist/types/deltas/apis/posting/group.d.ts +88 -0
  62. package/package.json +1 -1
  63. package/src/deltas/apis/messaging/editMessage.ts +16 -26
  64. package/src/deltas/apis/messaging/emoji.ts +45 -97
  65. package/src/deltas/apis/messaging/gcmember.ts +68 -113
  66. package/src/deltas/apis/messaging/gcname.ts +42 -91
  67. package/src/deltas/apis/messaging/gcrule.ts +61 -111
  68. package/src/deltas/apis/messaging/markAsDelivered.ts +19 -14
  69. package/src/deltas/apis/messaging/markAsRead.ts +45 -72
  70. package/src/deltas/apis/messaging/markAsReadAll.ts +17 -17
  71. package/src/deltas/apis/messaging/markAsSeen.ts +17 -41
  72. package/src/deltas/apis/messaging/nickname.ts +50 -116
  73. package/src/deltas/apis/messaging/notes.ts +59 -95
  74. package/src/deltas/apis/messaging/resolvePhotoUrl.ts +27 -50
  75. package/src/deltas/apis/messaging/sendMessage.ts +28 -26
  76. package/src/deltas/apis/messaging/sendTypingIndicator.ts +13 -12
  77. package/src/deltas/apis/messaging/setMessageReaction.ts +45 -20
  78. package/src/deltas/apis/messaging/shareContact.ts +25 -15
  79. package/src/deltas/apis/messaging/stickers.ts +4 -4
  80. package/src/deltas/apis/messaging/theme.ts +172 -259
  81. package/src/deltas/apis/messaging/unsendMessage.ts +23 -7
  82. package/src/deltas/apis/posting/group.ts +516 -11
  83. package/src/types/index.d.ts +18 -0
  84. package/request.txt +0 -60
@@ -1,280 +1,193 @@
1
1
  import utils = require('../../../utils');
2
2
 
3
- export default function(defaultFuncs: any, api: any, ctx: any) {
3
+ /**
4
+ * @module theme
5
+ * @description Manages or sets the custom theme for a Facebook thread. Made by Choru Official.
6
+ * @param {Object} defaultFuncs
7
+ * @param {Object} api
8
+ * @param {Object} ctx
9
+ */
10
+ export default function theme(
11
+ defaultFuncs: any,
12
+ api: any,
13
+ ctx: any,
14
+ ): Function {
4
15
  /**
5
- * Made by Choru Official
6
- * Mqtt & Graph
7
- * Manages or sets the custom theme for a Facebook thread.
8
- * If only a theme name/keyword is provided, it attempts to find and set the matching theme.
9
- * If "list" is provided as the themeName, it lists available themes.
10
- *
11
- * @param {string} themeName The name or partial name of the theme (case-insensitive), or "list" to list themes.
12
- * @param {string} threadID The ID of the thread.
13
- * @param {Function} [callback] Optional callback function.
14
- * @param {string} [initiatorID] The ID of the user who initiated the theme change (e.g., from event.senderID).
15
- * @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.
16
+ * Fetches all available messenger thread themes.
17
+ * @param {string} threadID - Used for referer header.
18
+ * @returns {Promise<Array<object>>}
16
19
  */
17
- return async function theme(themeName, threadID, callback, initiatorID) {
18
- let _callback;
19
- let _initiatorID;
20
-
21
- let _resolveFunc;
22
- let _rejectFunc;
23
- const finalReturnPromise = new Promise<any>((resolve, reject) => {
24
- _resolveFunc = resolve;
25
- _rejectFunc = reject;
26
- });
27
-
28
- if (
29
- utils.getType(callback) === 'Function' ||
30
- utils.getType(callback) === 'AsyncFunction'
31
- ) {
32
- _callback = callback;
33
- _initiatorID = initiatorID;
34
- } else if (
35
- utils.getType(threadID) === 'Function' ||
36
- utils.getType(threadID) === 'AsyncFunction'
37
- ) {
38
- _callback = threadID;
39
- threadID = null;
40
- _initiatorID = callback;
41
- } else if (utils.getType(callback) === 'string') {
42
- _initiatorID = callback;
43
- _callback = undefined;
44
- } else {
45
- _callback = undefined;
46
- _initiatorID = undefined;
47
- }
48
-
49
- if (!_callback) {
50
- _callback = function(_err, _data) {
51
- if (_err) _rejectFunc(_err);
52
- else _resolveFunc(_data);
53
- };
54
- }
55
-
56
- _initiatorID = _initiatorID || ctx.userID;
57
-
58
- threadID = threadID || ctx.threadID;
59
-
60
- if (!threadID) {
61
- return _callback(new Error('threadID is required to manage themes.'));
62
- }
63
- if (!themeName) {
64
- return _callback(new Error("themeName (or 'list') is required."));
65
- }
66
-
67
- if (!ctx.mqttClient) {
68
- return _callback(new Error('Not connected to MQTT'));
69
- }
70
-
71
- const fetchThemes = async () => {
72
- const form = {
73
- fb_api_caller_class: 'RelayModern',
74
- fb_api_req_friendly_name: 'MWPThreadThemeQuery_AllThemesQuery',
75
- variables: JSON.stringify({ version: 'default' }),
76
- server_timestamps: true,
77
- doc_id: '24474714052117636',
78
- };
79
-
80
- try {
81
- const resData = await defaultFuncs
82
- .post('https://www.facebook.com/api/graphql/', ctx.jar, form, null, {
83
- 'x-fb-friendly-name': 'MWPThreadThemeQuery_AllThemesQuery',
84
- 'x-fb-lsd': ctx.lsd,
85
- referer: `https://www.facebook.com/messages/t/${threadID}`,
86
- })
87
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs));
88
-
89
- if (resData.errors) {
90
- throw new Error(JSON.stringify(resData.errors));
91
- }
92
- if (!resData.data || !resData.data.messenger_thread_themes) {
93
- throw new Error('Could not retrieve thread themes from response.');
94
- }
95
- return resData.data.messenger_thread_themes
96
- .map((themeData) => {
97
- if (!themeData || !themeData.id) return null;
98
-
99
- return {
100
- id: themeData.id,
101
- name: themeData.accessibility_label,
102
- description: themeData.description,
103
- appColorMode: themeData.app_color_mode,
104
- composerBackgroundColor: themeData.composer_background_color,
105
- backgroundGradientColors: themeData.background_gradient_colors,
106
- titleBarButtonTintColor: themeData.title_bar_button_tint_color,
107
- inboundMessageGradientColors:
108
- themeData.inbound_message_gradient_colors,
109
- titleBarTextColor: themeData.title_bar_text_color,
110
- composerTintColor: themeData.composer_tint_color,
111
- titleBarAttributionColor: themeData.title_bar_attribution_color,
112
- composerInputBackgroundColor:
113
- themeData.composer_input_background_color,
114
- hotLikeColor: themeData.hot_like_color,
115
- backgroundImage: themeData.background_asset?.image?.uri,
116
- messageTextColor: themeData.message_text_color,
117
- inboundMessageTextColor: themeData.inbound_message_text_color,
118
- primaryButtonBackgroundColor:
119
- themeData.primary_button_background_color,
120
- titleBarBackgroundColor: themeData.title_bar_background_color,
121
- tertiaryTextColor: themeData.tertiary_text_color,
122
- reactionPillBackgroundColor:
123
- themeData.reaction_pill_background_color,
124
- secondaryTextColor: themeData.secondary_text_color,
125
- fallbackColor: themeData.fallback_color,
126
- gradientColors: themeData.gradient_colors,
127
- normalThemeId: themeData.normal_theme_id,
128
- iconAsset: themeData.icon_asset?.image?.uri,
129
- };
130
- })
131
- .filter(Boolean);
132
- } catch (fetchErr) {
133
- throw new Error(
134
- `Failed to fetch theme list: ${fetchErr.message || fetchErr}`,
135
- );
136
- }
20
+ async function fetchThemes(threadID: string): Promise<any[]> {
21
+ const form = {
22
+ fb_api_caller_class: 'RelayModern',
23
+ fb_api_req_friendly_name: 'MWPThreadThemeQuery_AllThemesQuery',
24
+ variables: JSON.stringify({ version: 'default' }),
25
+ server_timestamps: true,
26
+ doc_id: '24474714052117636',
137
27
  };
138
28
 
139
- const setThreadTheme = async (
140
- themeIDToSet,
141
- actualThemeName,
142
- initiatorID,
143
- ) => {
144
- let currentEpochId = parseInt(utils.generateOfflineThreadingID());
145
-
146
- const createAndPublish = (label, queueName, payload) => {
147
- currentEpochId = parseInt(utils.generateOfflineThreadingID());
148
- ctx.wsReqNumber += 1;
149
- ctx.wsTaskNumber += 1;
150
-
151
- const request_id = ctx.wsReqNumber;
152
-
153
- const queryPayload = {
154
- thread_key: threadID.toString(),
155
- theme_fbid: themeIDToSet.toString(),
156
- sync_group: 1,
157
- ...payload,
158
- };
159
-
160
- const query = {
161
- failure_count: null,
162
- label: label,
163
- payload: JSON.stringify(queryPayload),
164
- queue_name: queueName,
165
- task_id: ctx.wsTaskNumber,
166
- };
167
-
168
- const context: any = {
169
- app_id: ctx.appID,
170
- payload: {
171
- epoch_id: currentEpochId,
172
- tasks: [query],
173
- version_id: '24631415369801570',
174
- },
175
- request_id: request_id,
176
- type: 3,
177
- };
178
- context.payload = JSON.stringify(context.payload);
179
-
180
- return new Promise<void>((res, rej) => {
181
- ctx.mqttClient.publish(
182
- '/ls_req',
183
- JSON.stringify(context),
184
- { qos: 1, retain: false },
185
- (err) => {
186
- if (err) {
187
- return rej(
188
- new Error(
189
- `MQTT publish failed for request ${request_id}: ${err.message}`,
190
- ),
191
- );
192
- }
193
- res();
194
- },
195
- );
196
- });
197
- };
198
-
199
- try {
200
- await Promise.all([
201
- createAndPublish('1013', `ai_generated_theme`, {}),
202
- createAndPublish('1037', `msgr_custom_thread_theme`, {}),
203
- createAndPublish('1028', `thread_theme_writer`, {}),
204
- createAndPublish('43', `thread_theme`, {
205
- source: null,
206
- payload: null,
207
- }),
208
- ]);
29
+ const resData = await defaultFuncs
30
+ .post('https://www.facebook.com/api/graphql/', ctx.jar, form, null, {
31
+ 'x-fb-friendly-name': 'MWPThreadThemeQuery_AllThemesQuery',
32
+ 'x-fb-lsd': ctx.lsd,
33
+ referer: `https://www.facebook.com/messages/t/${threadID}`,
34
+ })
35
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs));
36
+
37
+ if (resData?.errors) throw new Error(JSON.stringify(resData.errors));
38
+ if (!resData?.data?.messenger_thread_themes) {
39
+ throw new Error('Could not retrieve thread themes from response.');
40
+ }
209
41
 
42
+ return resData.data.messenger_thread_themes
43
+ .map((themeData: any) => {
44
+ if (!themeData?.id) return null;
210
45
  return {
211
- type: 'thread_theme_update',
212
- threadID: threadID,
213
- themeID: themeIDToSet,
214
- themeName: actualThemeName,
215
- senderID: initiatorID,
216
- BotID: ctx.userID,
217
- timestamp: Date.now(),
46
+ id: themeData.id,
47
+ name: themeData.accessibility_label,
48
+ description: themeData.description,
49
+ appColorMode: themeData.app_color_mode,
50
+ composerBackgroundColor: themeData.composer_background_color,
51
+ backgroundGradientColors: themeData.background_gradient_colors,
52
+ titleBarButtonTintColor: themeData.title_bar_button_tint_color,
53
+ inboundMessageGradientColors: themeData.inbound_message_gradient_colors,
54
+ titleBarTextColor: themeData.title_bar_text_color,
55
+ composerTintColor: themeData.composer_tint_color,
56
+ titleBarAttributionColor: themeData.title_bar_attribution_color,
57
+ composerInputBackgroundColor: themeData.composer_input_background_color,
58
+ hotLikeColor: themeData.hot_like_color,
59
+ backgroundImage: themeData.background_asset?.image?.uri,
60
+ messageTextColor: themeData.message_text_color,
61
+ inboundMessageTextColor: themeData.inbound_message_text_color,
62
+ primaryButtonBackgroundColor: themeData.primary_button_background_color,
63
+ titleBarBackgroundColor: themeData.title_bar_background_color,
64
+ tertiaryTextColor: themeData.tertiary_text_color,
65
+ reactionPillBackgroundColor: themeData.reaction_pill_background_color,
66
+ secondaryTextColor: themeData.secondary_text_color,
67
+ fallbackColor: themeData.fallback_color,
68
+ gradientColors: themeData.gradient_colors,
69
+ normalThemeId: themeData.normal_theme_id,
70
+ iconAsset: themeData.icon_asset?.image?.uri,
218
71
  };
219
- } catch (publishErr) {
220
- throw new Error(
221
- `Failed to publish theme change MQTT messages: ${publishErr.message ||
222
- publishErr}`,
223
- );
224
- }
72
+ })
73
+ .filter(Boolean);
74
+ }
75
+
76
+ /**
77
+ * Publishes a single MQTT message to change the thread theme.
78
+ */
79
+ function publishThemeMqtt(
80
+ label: string,
81
+ queueName: string,
82
+ extraPayload: Record<string, any>,
83
+ threadID: string,
84
+ themeIDToSet: string,
85
+ ): Promise<void> {
86
+ ctx.wsReqNumber += 1;
87
+ ctx.wsTaskNumber += 1;
88
+
89
+ const queryPayload = {
90
+ thread_key: threadID.toString(),
91
+ theme_fbid: themeIDToSet.toString(),
92
+ sync_group: 1,
93
+ ...extraPayload,
225
94
  };
226
95
 
227
- try {
228
- if (themeName.toLowerCase() === 'list') {
229
- const themes = await fetchThemes();
230
- _callback(null, themes);
231
- } else {
232
- const themes = await fetchThemes();
233
- const normalizedThemeName = themeName.toLowerCase();
96
+ const query = {
97
+ failure_count: null,
98
+ label,
99
+ payload: JSON.stringify(queryPayload),
100
+ queue_name: queueName,
101
+ task_id: ctx.wsTaskNumber,
102
+ };
234
103
 
235
- let matchedTheme = null;
104
+ const context: any = {
105
+ app_id: ctx.appID,
106
+ payload: {
107
+ epoch_id: Number.parseInt(utils.generateOfflineThreadingID()),
108
+ tasks: [query],
109
+ version_id: '24631415369801570',
110
+ },
111
+ request_id: ctx.wsReqNumber,
112
+ type: 3,
113
+ };
114
+ context.payload = JSON.stringify(context.payload);
115
+
116
+ return new Promise<void>((resolve, reject) =>
117
+ ctx.mqttClient.publish(
118
+ '/ls_req',
119
+ JSON.stringify(context),
120
+ { qos: 1, retain: false },
121
+ (err) =>
122
+ err
123
+ ? reject(new Error(`MQTT publish failed for label ${label}: ${err.message ?? err}`))
124
+ : resolve(),
125
+ ),
126
+ );
127
+ }
236
128
 
237
- if (!isNaN(normalizedThemeName)) {
238
- matchedTheme = themes.find((t) => t.id === normalizedThemeName);
239
- }
240
- if (!matchedTheme) {
241
- matchedTheme = themes.find(
242
- (t) => t.name.toLowerCase() === normalizedThemeName,
243
- );
244
- }
129
+ /**
130
+ * Sends all 4 MQTT messages required to apply a theme change and returns an event object.
131
+ */
132
+ async function setThreadTheme(
133
+ themeIDToSet: string,
134
+ actualThemeName: string,
135
+ threadID: string,
136
+ initiatorID: string,
137
+ ): Promise<any> {
138
+ await Promise.all([
139
+ publishThemeMqtt('1013', 'ai_generated_theme', {}, threadID, themeIDToSet),
140
+ publishThemeMqtt('1037', 'msgr_custom_thread_theme', {}, threadID, themeIDToSet),
141
+ publishThemeMqtt('1028', 'thread_theme_writer', {}, threadID, themeIDToSet),
142
+ publishThemeMqtt('43', 'thread_theme', { source: null, payload: null }, threadID, themeIDToSet),
143
+ ]);
144
+
145
+ return {
146
+ type: 'thread_theme_update',
147
+ threadID,
148
+ themeID: themeIDToSet,
149
+ themeName: actualThemeName,
150
+ senderID: initiatorID,
151
+ BotID: ctx.userID,
152
+ timestamp: Date.now(),
153
+ };
154
+ }
245
155
 
246
- if (!matchedTheme) {
247
- matchedTheme = themes.find((t) =>
248
- t.name.toLowerCase().includes(normalizedThemeName),
249
- );
250
- }
156
+ /**
157
+ * Sets or lists thread themes.
158
+ *
159
+ * @param {string} themeName - Theme name/keyword to set, or "list" to list all available themes.
160
+ * @param {string} threadID - The ID of the thread.
161
+ * @param {string} [initiatorID] - The ID of the user initiating the change.
162
+ * @returns {Promise<object|Array<object>>}
163
+ */
164
+ return async function setTheme(
165
+ themeName: string,
166
+ threadID: string,
167
+ initiatorID?: string,
168
+ ): Promise<any> {
169
+ if (!threadID) throw new Error('threadID is required to manage themes.');
170
+ if (!themeName) throw new Error("themeName (or 'list') is required.");
171
+ if (!ctx.mqttClient) throw new Error('Not connected to MQTT');
172
+
173
+ const _initiatorID = initiatorID ?? ctx.userID;
174
+
175
+ if (themeName.toLowerCase() === 'list') {
176
+ return fetchThemes(threadID);
177
+ }
251
178
 
252
- if (!matchedTheme) {
253
- throw new Error(
254
- `Theme "${themeName}" not found. Try '/theme list' for available themes.`,
255
- );
256
- }
179
+ const themes = await fetchThemes(threadID);
180
+ const normalizedThemeName = themeName.toLowerCase();
257
181
 
258
- const themeEventObject = await setThreadTheme(
259
- matchedTheme.id,
260
- matchedTheme.name,
261
- _initiatorID,
262
- );
182
+ let matchedTheme =
183
+ themes.find((t) => t.id === normalizedThemeName) ??
184
+ themes.find((t) => t.name.toLowerCase() === normalizedThemeName) ??
185
+ themes.find((t) => t.name.toLowerCase().includes(normalizedThemeName));
263
186
 
264
- _callback(null, themeEventObject);
265
- }
266
- } catch (err) {
267
- const finalError =
268
- err instanceof Error
269
- ? err
270
- : new Error(
271
- err.message ||
272
- err.error ||
273
- 'An unknown error occurred during theme operation.',
274
- );
275
- _callback(finalError);
187
+ if (!matchedTheme) {
188
+ throw new Error(`Theme "${themeName}" not found. Try 'list' for available themes.`);
276
189
  }
277
190
 
278
- return finalReturnPromise;
191
+ return setThreadTheme(matchedTheme.id, matchedTheme.name, threadID, _initiatorID);
279
192
  };
280
193
  }
@@ -1,15 +1,31 @@
1
- import utils = require("../../../utils");
1
+ import utils = require('../../../utils');
2
2
  // @NethWs3Dev
3
3
 
4
- export default function(defaultFuncs: any, api: any, ctx: any) {
5
- return async (messageID) => {
6
- const defData = await defaultFuncs.post("https://www.facebook.com/messaging/unsend_message/", ctx.jar, {
7
- message_id: messageID
8
- })
4
+ /**
5
+ * @param {Object} defaultFuncs
6
+ * @param {Object} api
7
+ * @param {Object} ctx
8
+ */
9
+ export default function unsendMessage(
10
+ defaultFuncs: any,
11
+ api: any,
12
+ ctx: any,
13
+ ): Function {
14
+ /**
15
+ * Unsends (deletes for everyone) a message sent by the bot.
16
+ * @param {string} messageID - The ID of the message to unsend.
17
+ * @returns {Promise<any>}
18
+ */
19
+ return async function unsendMessage(messageID: string): Promise<any> {
20
+ const defData = await defaultFuncs.post(
21
+ 'https://www.facebook.com/messaging/unsend_message/',
22
+ ctx.jar,
23
+ { message_id: messageID },
24
+ );
9
25
  const resData = await utils.parseAndCheckLogin(ctx, defaultFuncs)(defData);
10
26
  if (resData.error) {
11
27
  throw new Error(resData);
12
28
  }
13
29
  return resData;
14
30
  };
15
- };
31
+ }