bb-fca 2.0.8 → 2.0.10
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.
- package/dist/core/models/buildAPI.js +3 -3
- package/dist/core/models/buildAPI.js.map +1 -1
- package/dist/core/models/loginHelper.js +29 -28
- package/dist/core/models/loginHelper.js.map +1 -1
- package/dist/deltas/apis/create.js +9 -0
- package/dist/deltas/apis/create.js.map +1 -1
- package/dist/deltas/apis/messaging/editMessage.js +13 -24
- package/dist/deltas/apis/messaging/editMessage.js.map +1 -1
- package/dist/deltas/apis/messaging/emoji.js +34 -88
- package/dist/deltas/apis/messaging/emoji.js.map +1 -1
- package/dist/deltas/apis/messaging/gcmember.js +48 -101
- package/dist/deltas/apis/messaging/gcmember.js.map +1 -1
- package/dist/deltas/apis/messaging/gcname.js +28 -79
- package/dist/deltas/apis/messaging/gcname.js.map +1 -1
- package/dist/deltas/apis/messaging/gcrule.js +47 -105
- package/dist/deltas/apis/messaging/gcrule.js.map +1 -1
- package/dist/deltas/apis/messaging/markAsDelivered.js +10 -12
- package/dist/deltas/apis/messaging/markAsDelivered.js.map +1 -1
- package/dist/deltas/apis/messaging/markAsRead.js +25 -60
- package/dist/deltas/apis/messaging/markAsRead.js.map +1 -1
- package/dist/deltas/apis/messaging/markAsReadAll.js +9 -11
- package/dist/deltas/apis/messaging/markAsReadAll.js.map +1 -1
- package/dist/deltas/apis/messaging/markAsSeen.js +10 -37
- package/dist/deltas/apis/messaging/markAsSeen.js.map +1 -1
- package/dist/deltas/apis/messaging/nickname.js +38 -98
- package/dist/deltas/apis/messaging/nickname.js.map +1 -1
- package/dist/deltas/apis/messaging/notes.js +52 -90
- package/dist/deltas/apis/messaging/notes.js.map +1 -1
- package/dist/deltas/apis/messaging/resolvePhotoUrl.js +17 -42
- package/dist/deltas/apis/messaging/resolvePhotoUrl.js.map +1 -1
- package/dist/deltas/apis/messaging/sendMessage.js +14 -15
- package/dist/deltas/apis/messaging/sendMessage.js.map +1 -1
- package/dist/deltas/apis/messaging/sendTypingIndicator.js +7 -13
- package/dist/deltas/apis/messaging/sendTypingIndicator.js.map +1 -1
- package/dist/deltas/apis/messaging/setMessageReaction.js +24 -14
- package/dist/deltas/apis/messaging/setMessageReaction.js.map +1 -1
- package/dist/deltas/apis/messaging/shareContact.js +14 -12
- package/dist/deltas/apis/messaging/shareContact.js.map +1 -1
- package/dist/deltas/apis/messaging/stickers.js +4 -5
- package/dist/deltas/apis/messaging/stickers.js.map +1 -1
- package/dist/deltas/apis/messaging/theme.js +142 -213
- package/dist/deltas/apis/messaging/theme.js.map +1 -1
- package/dist/deltas/apis/messaging/unsendMessage.js +14 -7
- package/dist/deltas/apis/messaging/unsendMessage.js.map +1 -1
- package/dist/deltas/apis/posting/group.js +22 -129
- package/dist/deltas/apis/posting/group.js.map +1 -1
- package/dist/deltas/apis/posting/post.js +805 -12
- package/dist/deltas/apis/posting/post.js.map +1 -1
- package/dist/index.d.ts +35 -58
- package/dist/types/deltas/apis/create.d.ts +9 -0
- package/dist/types/deltas/apis/messaging/editMessage.d.ts +4 -5
- package/dist/types/deltas/apis/messaging/emoji.d.ts +7 -1
- package/dist/types/deltas/apis/messaging/gcmember.d.ts +7 -1
- package/dist/types/deltas/apis/messaging/gcname.d.ts +9 -1
- package/dist/types/deltas/apis/messaging/gcrule.d.ts +7 -1
- package/dist/types/deltas/apis/messaging/markAsDelivered.d.ts +1 -2
- package/dist/types/deltas/apis/messaging/markAsRead.d.ts +1 -1
- package/dist/types/deltas/apis/messaging/markAsReadAll.d.ts +1 -2
- package/dist/types/deltas/apis/messaging/markAsSeen.d.ts +1 -1
- package/dist/types/deltas/apis/messaging/nickname.d.ts +7 -1
- package/dist/types/deltas/apis/messaging/notes.d.ts +13 -11
- package/dist/types/deltas/apis/messaging/resolvePhotoUrl.d.ts +4 -6
- package/dist/types/deltas/apis/messaging/sendMessage.d.ts +1 -1
- package/dist/types/deltas/apis/messaging/sendTypingIndicator.d.ts +1 -1
- package/dist/types/deltas/apis/messaging/setMessageReaction.d.ts +6 -1
- package/dist/types/deltas/apis/messaging/shareContact.d.ts +1 -2
- package/dist/types/deltas/apis/messaging/stickers.d.ts +1 -1
- package/dist/types/deltas/apis/messaging/theme.d.ts +8 -1
- package/dist/types/deltas/apis/messaging/unsendMessage.d.ts +6 -1
- package/dist/types/deltas/apis/posting/group.d.ts +1 -23
- package/dist/types/deltas/apis/posting/post.d.ts +23 -0
- package/dist/types/utils/constants.d.ts +26 -16
- package/dist/utils/constants.js +42 -29
- package/dist/utils/constants.js.map +1 -1
- package/package.json +1 -1
- package/src/core/models/buildAPI.ts +3 -3
- package/src/core/models/loginHelper.ts +32 -30
- package/src/deltas/apis/create.ts +10 -0
- package/src/deltas/apis/messaging/editMessage.ts +16 -26
- package/src/deltas/apis/messaging/emoji.ts +45 -97
- package/src/deltas/apis/messaging/gcmember.ts +68 -113
- package/src/deltas/apis/messaging/gcname.ts +42 -91
- package/src/deltas/apis/messaging/gcrule.ts +61 -111
- package/src/deltas/apis/messaging/markAsDelivered.ts +19 -14
- package/src/deltas/apis/messaging/markAsRead.ts +45 -72
- package/src/deltas/apis/messaging/markAsReadAll.ts +17 -17
- package/src/deltas/apis/messaging/markAsSeen.ts +17 -41
- package/src/deltas/apis/messaging/nickname.ts +50 -116
- package/src/deltas/apis/messaging/notes.ts +59 -95
- package/src/deltas/apis/messaging/resolvePhotoUrl.ts +27 -50
- package/src/deltas/apis/messaging/sendMessage.ts +28 -26
- package/src/deltas/apis/messaging/sendTypingIndicator.ts +13 -12
- package/src/deltas/apis/messaging/setMessageReaction.ts +45 -20
- package/src/deltas/apis/messaging/shareContact.ts +25 -15
- package/src/deltas/apis/messaging/stickers.ts +4 -4
- package/src/deltas/apis/messaging/theme.ts +172 -259
- package/src/deltas/apis/messaging/unsendMessage.ts +23 -7
- package/src/deltas/apis/posting/group.ts +56 -172
- package/src/deltas/apis/posting/post.ts +932 -33
- package/src/types/index.d.ts +35 -58
- package/src/utils/constants.ts +84 -57
- package/a.html +0 -537
- package/a.json +0 -5915
- package/src/utils/formatters.old.ts +0 -1049
- package/task.txt +0 -24
|
@@ -1,227 +1,156 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default =
|
|
3
|
+
exports.default = theme;
|
|
4
4
|
const utils = require("../../../utils");
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @module theme
|
|
7
|
+
* @description Manages or sets the custom theme for a Facebook thread. Made by Choru Official.
|
|
8
|
+
* @param {Object} defaultFuncs
|
|
9
|
+
* @param {Object} api
|
|
10
|
+
* @param {Object} ctx
|
|
11
|
+
*/
|
|
12
|
+
function theme(defaultFuncs, api, ctx) {
|
|
6
13
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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.
|
|
14
|
+
* Fetches all available messenger thread themes.
|
|
15
|
+
* @param {string} threadID - Used for referer header.
|
|
16
|
+
* @returns {Promise<Array<object>>}
|
|
18
17
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
else if (utils.getType(callback) === 'string') {
|
|
40
|
-
_initiatorID = callback;
|
|
41
|
-
_callback = undefined;
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
_callback = undefined;
|
|
45
|
-
_initiatorID = undefined;
|
|
46
|
-
}
|
|
47
|
-
if (!_callback) {
|
|
48
|
-
_callback = function (_err, _data) {
|
|
49
|
-
if (_err)
|
|
50
|
-
_rejectFunc(_err);
|
|
51
|
-
else
|
|
52
|
-
_resolveFunc(_data);
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
_initiatorID = _initiatorID || ctx.userID;
|
|
56
|
-
threadID = threadID || ctx.threadID;
|
|
57
|
-
if (!threadID) {
|
|
58
|
-
return _callback(new Error('threadID is required to manage themes.'));
|
|
59
|
-
}
|
|
60
|
-
if (!themeName) {
|
|
61
|
-
return _callback(new Error("themeName (or 'list') is required."));
|
|
62
|
-
}
|
|
63
|
-
if (!ctx.mqttClient) {
|
|
64
|
-
return _callback(new Error('Not connected to MQTT'));
|
|
18
|
+
async function fetchThemes(threadID) {
|
|
19
|
+
const form = {
|
|
20
|
+
fb_api_caller_class: 'RelayModern',
|
|
21
|
+
fb_api_req_friendly_name: 'MWPThreadThemeQuery_AllThemesQuery',
|
|
22
|
+
variables: JSON.stringify({ version: 'default' }),
|
|
23
|
+
server_timestamps: true,
|
|
24
|
+
doc_id: '24474714052117636',
|
|
25
|
+
};
|
|
26
|
+
const resData = await defaultFuncs
|
|
27
|
+
.post('https://www.facebook.com/api/graphql/', ctx.jar, form, null, {
|
|
28
|
+
'x-fb-friendly-name': 'MWPThreadThemeQuery_AllThemesQuery',
|
|
29
|
+
'x-fb-lsd': ctx.lsd,
|
|
30
|
+
referer: `https://www.facebook.com/messages/t/${threadID}`,
|
|
31
|
+
})
|
|
32
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs));
|
|
33
|
+
if (resData?.errors)
|
|
34
|
+
throw new Error(JSON.stringify(resData.errors));
|
|
35
|
+
if (!resData?.data?.messenger_thread_themes) {
|
|
36
|
+
throw new Error('Could not retrieve thread themes from response.');
|
|
65
37
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
38
|
+
return resData.data.messenger_thread_themes
|
|
39
|
+
.map((themeData) => {
|
|
40
|
+
if (!themeData?.id)
|
|
41
|
+
return null;
|
|
42
|
+
return {
|
|
43
|
+
id: themeData.id,
|
|
44
|
+
name: themeData.accessibility_label,
|
|
45
|
+
description: themeData.description,
|
|
46
|
+
appColorMode: themeData.app_color_mode,
|
|
47
|
+
composerBackgroundColor: themeData.composer_background_color,
|
|
48
|
+
backgroundGradientColors: themeData.background_gradient_colors,
|
|
49
|
+
titleBarButtonTintColor: themeData.title_bar_button_tint_color,
|
|
50
|
+
inboundMessageGradientColors: themeData.inbound_message_gradient_colors,
|
|
51
|
+
titleBarTextColor: themeData.title_bar_text_color,
|
|
52
|
+
composerTintColor: themeData.composer_tint_color,
|
|
53
|
+
titleBarAttributionColor: themeData.title_bar_attribution_color,
|
|
54
|
+
composerInputBackgroundColor: themeData.composer_input_background_color,
|
|
55
|
+
hotLikeColor: themeData.hot_like_color,
|
|
56
|
+
backgroundImage: themeData.background_asset?.image?.uri,
|
|
57
|
+
messageTextColor: themeData.message_text_color,
|
|
58
|
+
inboundMessageTextColor: themeData.inbound_message_text_color,
|
|
59
|
+
primaryButtonBackgroundColor: themeData.primary_button_background_color,
|
|
60
|
+
titleBarBackgroundColor: themeData.title_bar_background_color,
|
|
61
|
+
tertiaryTextColor: themeData.tertiary_text_color,
|
|
62
|
+
reactionPillBackgroundColor: themeData.reaction_pill_background_color,
|
|
63
|
+
secondaryTextColor: themeData.secondary_text_color,
|
|
64
|
+
fallbackColor: themeData.fallback_color,
|
|
65
|
+
gradientColors: themeData.gradient_colors,
|
|
66
|
+
normalThemeId: themeData.normal_theme_id,
|
|
67
|
+
iconAsset: themeData.icon_asset?.image?.uri,
|
|
73
68
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return resData.data.messenger_thread_themes
|
|
89
|
-
.map((themeData) => {
|
|
90
|
-
if (!themeData || !themeData.id)
|
|
91
|
-
return null;
|
|
92
|
-
return {
|
|
93
|
-
id: themeData.id,
|
|
94
|
-
name: themeData.accessibility_label,
|
|
95
|
-
description: themeData.description,
|
|
96
|
-
appColorMode: themeData.app_color_mode,
|
|
97
|
-
composerBackgroundColor: themeData.composer_background_color,
|
|
98
|
-
backgroundGradientColors: themeData.background_gradient_colors,
|
|
99
|
-
titleBarButtonTintColor: themeData.title_bar_button_tint_color,
|
|
100
|
-
inboundMessageGradientColors: themeData.inbound_message_gradient_colors,
|
|
101
|
-
titleBarTextColor: themeData.title_bar_text_color,
|
|
102
|
-
composerTintColor: themeData.composer_tint_color,
|
|
103
|
-
titleBarAttributionColor: themeData.title_bar_attribution_color,
|
|
104
|
-
composerInputBackgroundColor: themeData.composer_input_background_color,
|
|
105
|
-
hotLikeColor: themeData.hot_like_color,
|
|
106
|
-
backgroundImage: themeData.background_asset?.image?.uri,
|
|
107
|
-
messageTextColor: themeData.message_text_color,
|
|
108
|
-
inboundMessageTextColor: themeData.inbound_message_text_color,
|
|
109
|
-
primaryButtonBackgroundColor: themeData.primary_button_background_color,
|
|
110
|
-
titleBarBackgroundColor: themeData.title_bar_background_color,
|
|
111
|
-
tertiaryTextColor: themeData.tertiary_text_color,
|
|
112
|
-
reactionPillBackgroundColor: themeData.reaction_pill_background_color,
|
|
113
|
-
secondaryTextColor: themeData.secondary_text_color,
|
|
114
|
-
fallbackColor: themeData.fallback_color,
|
|
115
|
-
gradientColors: themeData.gradient_colors,
|
|
116
|
-
normalThemeId: themeData.normal_theme_id,
|
|
117
|
-
iconAsset: themeData.icon_asset?.image?.uri,
|
|
118
|
-
};
|
|
119
|
-
})
|
|
120
|
-
.filter(Boolean);
|
|
121
|
-
}
|
|
122
|
-
catch (fetchErr) {
|
|
123
|
-
throw new Error(`Failed to fetch theme list: ${fetchErr.message || fetchErr}`);
|
|
124
|
-
}
|
|
69
|
+
})
|
|
70
|
+
.filter(Boolean);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Publishes a single MQTT message to change the thread theme.
|
|
74
|
+
*/
|
|
75
|
+
function publishThemeMqtt(label, queueName, extraPayload, threadID, themeIDToSet) {
|
|
76
|
+
ctx.wsReqNumber += 1;
|
|
77
|
+
ctx.wsTaskNumber += 1;
|
|
78
|
+
const queryPayload = {
|
|
79
|
+
thread_key: threadID.toString(),
|
|
80
|
+
theme_fbid: themeIDToSet.toString(),
|
|
81
|
+
sync_group: 1,
|
|
82
|
+
...extraPayload,
|
|
125
83
|
};
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
try {
|
|
167
|
-
await Promise.all([
|
|
168
|
-
createAndPublish('1013', `ai_generated_theme`, {}),
|
|
169
|
-
createAndPublish('1037', `msgr_custom_thread_theme`, {}),
|
|
170
|
-
createAndPublish('1028', `thread_theme_writer`, {}),
|
|
171
|
-
createAndPublish('43', `thread_theme`, {
|
|
172
|
-
source: null,
|
|
173
|
-
payload: null,
|
|
174
|
-
}),
|
|
175
|
-
]);
|
|
176
|
-
return {
|
|
177
|
-
type: 'thread_theme_update',
|
|
178
|
-
threadID: threadID,
|
|
179
|
-
themeID: themeIDToSet,
|
|
180
|
-
themeName: actualThemeName,
|
|
181
|
-
senderID: initiatorID,
|
|
182
|
-
BotID: ctx.userID,
|
|
183
|
-
timestamp: Date.now(),
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
catch (publishErr) {
|
|
187
|
-
throw new Error(`Failed to publish theme change MQTT messages: ${publishErr.message ||
|
|
188
|
-
publishErr}`);
|
|
189
|
-
}
|
|
84
|
+
const query = {
|
|
85
|
+
failure_count: null,
|
|
86
|
+
label,
|
|
87
|
+
payload: JSON.stringify(queryPayload),
|
|
88
|
+
queue_name: queueName,
|
|
89
|
+
task_id: ctx.wsTaskNumber,
|
|
90
|
+
};
|
|
91
|
+
const context = {
|
|
92
|
+
app_id: ctx.appID,
|
|
93
|
+
payload: {
|
|
94
|
+
epoch_id: Number.parseInt(utils.generateOfflineThreadingID()),
|
|
95
|
+
tasks: [query],
|
|
96
|
+
version_id: '24631415369801570',
|
|
97
|
+
},
|
|
98
|
+
request_id: ctx.wsReqNumber,
|
|
99
|
+
type: 3,
|
|
100
|
+
};
|
|
101
|
+
context.payload = JSON.stringify(context.payload);
|
|
102
|
+
return new Promise((resolve, reject) => ctx.mqttClient.publish('/ls_req', JSON.stringify(context), { qos: 1, retain: false }, (err) => err
|
|
103
|
+
? reject(new Error(`MQTT publish failed for label ${label}: ${err.message ?? err}`))
|
|
104
|
+
: resolve()));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Sends all 4 MQTT messages required to apply a theme change and returns an event object.
|
|
108
|
+
*/
|
|
109
|
+
async function setThreadTheme(themeIDToSet, actualThemeName, threadID, initiatorID) {
|
|
110
|
+
await Promise.all([
|
|
111
|
+
publishThemeMqtt('1013', 'ai_generated_theme', {}, threadID, themeIDToSet),
|
|
112
|
+
publishThemeMqtt('1037', 'msgr_custom_thread_theme', {}, threadID, themeIDToSet),
|
|
113
|
+
publishThemeMqtt('1028', 'thread_theme_writer', {}, threadID, themeIDToSet),
|
|
114
|
+
publishThemeMqtt('43', 'thread_theme', { source: null, payload: null }, threadID, themeIDToSet),
|
|
115
|
+
]);
|
|
116
|
+
return {
|
|
117
|
+
type: 'thread_theme_update',
|
|
118
|
+
threadID,
|
|
119
|
+
themeID: themeIDToSet,
|
|
120
|
+
themeName: actualThemeName,
|
|
121
|
+
senderID: initiatorID,
|
|
122
|
+
BotID: ctx.userID,
|
|
123
|
+
timestamp: Date.now(),
|
|
190
124
|
};
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
throw new Error(`Theme "${themeName}" not found. Try '/theme list' for available themes.`);
|
|
211
|
-
}
|
|
212
|
-
const themeEventObject = await setThreadTheme(matchedTheme.id, matchedTheme.name, _initiatorID);
|
|
213
|
-
_callback(null, themeEventObject);
|
|
214
|
-
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Sets or lists thread themes.
|
|
128
|
+
*
|
|
129
|
+
* @param {string} themeName - Theme name/keyword to set, or "list" to list all available themes.
|
|
130
|
+
* @param {string} threadID - The ID of the thread.
|
|
131
|
+
* @param {string} [initiatorID] - The ID of the user initiating the change.
|
|
132
|
+
* @returns {Promise<object|Array<object>>}
|
|
133
|
+
*/
|
|
134
|
+
return async function setTheme(themeName, threadID, initiatorID) {
|
|
135
|
+
if (!threadID)
|
|
136
|
+
throw new Error('threadID is required to manage themes.');
|
|
137
|
+
if (!themeName)
|
|
138
|
+
throw new Error("themeName (or 'list') is required.");
|
|
139
|
+
if (!ctx.mqttClient)
|
|
140
|
+
throw new Error('Not connected to MQTT');
|
|
141
|
+
const _initiatorID = initiatorID ?? ctx.userID;
|
|
142
|
+
if (themeName.toLowerCase() === 'list') {
|
|
143
|
+
return fetchThemes(threadID);
|
|
215
144
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
145
|
+
const themes = await fetchThemes(threadID);
|
|
146
|
+
const normalizedThemeName = themeName.toLowerCase();
|
|
147
|
+
let matchedTheme = themes.find((t) => t.id === normalizedThemeName) ??
|
|
148
|
+
themes.find((t) => t.name.toLowerCase() === normalizedThemeName) ??
|
|
149
|
+
themes.find((t) => t.name.toLowerCase().includes(normalizedThemeName));
|
|
150
|
+
if (!matchedTheme) {
|
|
151
|
+
throw new Error(`Theme "${themeName}" not found. Try 'list' for available themes.`);
|
|
223
152
|
}
|
|
224
|
-
return
|
|
153
|
+
return setThreadTheme(matchedTheme.id, matchedTheme.name, threadID, _initiatorID);
|
|
225
154
|
};
|
|
226
155
|
}
|
|
227
156
|
//# sourceMappingURL=theme.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../../../src/deltas/apis/messaging/theme.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../../../src/deltas/apis/messaging/theme.ts"],"names":[],"mappings":";;AASA,wBAuLC;AAhMD,wCAAyC;AAEzC;;;;;;GAMG;AACH,SAAwB,KAAK,CAC3B,YAAiB,EACjB,GAAQ,EACR,GAAQ;IAER;;;;OAIG;IACH,KAAK,UAAU,WAAW,CAAC,QAAgB;QACzC,MAAM,IAAI,GAAG;YACX,mBAAmB,EAAE,aAAa;YAClC,wBAAwB,EAAE,oCAAoC;YA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AI,CAAC,WAAW,EAAE,KAAK,mBAAmB,CAAC;YAChE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC;QAEzE,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,UAAU,SAAS,+CAA+C,CAAC,CAAC;QACtF,CAAC;QAED,OAAO,cAAc,CAAC,YAAY,CAAC,EAAE,EAAE,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;IACpF,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default =
|
|
3
|
+
exports.default = unsendMessage;
|
|
4
4
|
const utils = require("../../../utils");
|
|
5
5
|
// @NethWs3Dev
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @param {Object} defaultFuncs
|
|
8
|
+
* @param {Object} api
|
|
9
|
+
* @param {Object} ctx
|
|
10
|
+
*/
|
|
11
|
+
function unsendMessage(defaultFuncs, api, ctx) {
|
|
12
|
+
/**
|
|
13
|
+
* Unsends (deletes for everyone) a message sent by the bot.
|
|
14
|
+
* @param {string} messageID - The ID of the message to unsend.
|
|
15
|
+
* @returns {Promise<any>}
|
|
16
|
+
*/
|
|
17
|
+
return async function unsendMessage(messageID) {
|
|
18
|
+
const defData = await defaultFuncs.post('https://www.facebook.com/messaging/unsend_message/', ctx.jar, { message_id: messageID });
|
|
11
19
|
const resData = await utils.parseAndCheckLogin(ctx, defaultFuncs)(defData);
|
|
12
20
|
if (resData.error) {
|
|
13
21
|
throw new Error(resData);
|
|
@@ -15,5 +23,4 @@ function default_1(defaultFuncs, api, ctx) {
|
|
|
15
23
|
return resData;
|
|
16
24
|
};
|
|
17
25
|
}
|
|
18
|
-
;
|
|
19
26
|
//# sourceMappingURL=unsendMessage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsendMessage.js","sourceRoot":"","sources":["../../../../src/deltas/apis/messaging/unsendMessage.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"unsendMessage.js","sourceRoot":"","sources":["../../../../src/deltas/apis/messaging/unsendMessage.ts"],"names":[],"mappings":";;AAQA,gCAsBC;AA9BD,wCAAyC;AACzC,cAAc;AAEd;;;;GAIG;AACH,SAAwB,aAAa,CACnC,YAAiB,EACjB,GAAQ,EACR,GAAQ;IAER;;;;OAIG;IACH,OAAO,KAAK,UAAU,aAAa,CAAC,SAAiB;QACnD,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,IAAI,CACrC,oDAAoD,EACpD,GAAG,CAAC,GAAG,EACP,EAAE,UAAU,EAAE,SAAS,EAAE,CAC1B,CAAC;QACF,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,kBAAkB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC;QAC3E,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC"}
|