fca-neokex-fix 1.0.1
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/CHANGELOG.md +220 -0
- package/LICENSE +26 -0
- package/README.md +346 -0
- package/THEME_FEATURES.md +137 -0
- package/examples/README.md +131 -0
- package/examples/apply-ai-theme.js +127 -0
- package/examples/check-current-theme.js +74 -0
- package/examples/simple-bot.js +114 -0
- package/examples/test-bot.js +752 -0
- package/examples/test-logging.js +85 -0
- package/examples/theme-usage-example.js +53 -0
- package/index.js +2 -0
- package/package.json +105 -0
- package/src/apis/addExternalModule.js +24 -0
- package/src/apis/addUserToGroup.js +108 -0
- package/src/apis/changeAdminStatus.js +148 -0
- package/src/apis/changeArchivedStatus.js +61 -0
- package/src/apis/changeAvatar.js +103 -0
- package/src/apis/changeBio.js +69 -0
- package/src/apis/changeBlockedStatus.js +54 -0
- package/src/apis/changeGroupImage.js +136 -0
- package/src/apis/changeThreadColor.js +116 -0
- package/src/apis/comment.js +207 -0
- package/src/apis/createAITheme.js +129 -0
- package/src/apis/createNewGroup.js +79 -0
- package/src/apis/createPoll.js +73 -0
- package/src/apis/deleteMessage.js +44 -0
- package/src/apis/deleteThread.js +52 -0
- package/src/apis/editMessage.js +70 -0
- package/src/apis/emoji.js +124 -0
- package/src/apis/fetchThemeData.js +65 -0
- package/src/apis/follow.js +81 -0
- package/src/apis/forwardMessage.js +52 -0
- package/src/apis/friend.js +243 -0
- package/src/apis/gcmember.js +122 -0
- package/src/apis/gcname.js +123 -0
- package/src/apis/gcrule.js +119 -0
- package/src/apis/getAccess.js +111 -0
- package/src/apis/getBotInfo.js +88 -0
- package/src/apis/getBotInitialData.js +43 -0
- package/src/apis/getFriendsList.js +79 -0
- package/src/apis/getMessage.js +423 -0
- package/src/apis/getTheme.js +104 -0
- package/src/apis/getThemeInfo.js +96 -0
- package/src/apis/getThreadHistory.js +239 -0
- package/src/apis/getThreadInfo.js +257 -0
- package/src/apis/getThreadList.js +222 -0
- package/src/apis/getThreadPictures.js +58 -0
- package/src/apis/getUserID.js +83 -0
- package/src/apis/getUserInfo.js +495 -0
- package/src/apis/getUserInfoV2.js +146 -0
- package/src/apis/handleMessageRequest.js +50 -0
- package/src/apis/httpGet.js +63 -0
- package/src/apis/httpPost.js +89 -0
- package/src/apis/httpPostFormData.js +69 -0
- package/src/apis/listenMqtt.js +796 -0
- package/src/apis/listenSpeed.js +170 -0
- package/src/apis/logout.js +63 -0
- package/src/apis/markAsDelivered.js +47 -0
- package/src/apis/markAsRead.js +95 -0
- package/src/apis/markAsReadAll.js +41 -0
- package/src/apis/markAsSeen.js +70 -0
- package/src/apis/mqttDeltaValue.js +330 -0
- package/src/apis/muteThread.js +45 -0
- package/src/apis/nickname.js +132 -0
- package/src/apis/notes.js +163 -0
- package/src/apis/pinMessage.js +141 -0
- package/src/apis/produceMetaTheme.js +180 -0
- package/src/apis/realtime.js +161 -0
- package/src/apis/removeUserFromGroup.js +117 -0
- package/src/apis/resolvePhotoUrl.js +58 -0
- package/src/apis/searchForThread.js +154 -0
- package/src/apis/sendMessage.js +281 -0
- package/src/apis/sendMessageMqtt.js +188 -0
- package/src/apis/sendTypingIndicator.js +41 -0
- package/src/apis/setMessageReaction.js +27 -0
- package/src/apis/setMessageReactionMqtt.js +61 -0
- package/src/apis/setThreadTheme.js +260 -0
- package/src/apis/setThreadThemeMqtt.js +94 -0
- package/src/apis/share.js +107 -0
- package/src/apis/shareContact.js +66 -0
- package/src/apis/stickers.js +257 -0
- package/src/apis/story.js +181 -0
- package/src/apis/theme.js +233 -0
- package/src/apis/unfriend.js +47 -0
- package/src/apis/unsendMessage.js +17 -0
- package/src/database/appStateBackup.js +189 -0
- package/src/database/models/index.js +56 -0
- package/src/database/models/thread.js +31 -0
- package/src/database/models/user.js +32 -0
- package/src/database/threadData.js +101 -0
- package/src/database/userData.js +90 -0
- package/src/engine/client.js +91 -0
- package/src/engine/models/buildAPI.js +109 -0
- package/src/engine/models/loginHelper.js +326 -0
- package/src/engine/models/setOptions.js +53 -0
- package/src/utils/auth-helpers.js +149 -0
- package/src/utils/autoReLogin.js +169 -0
- package/src/utils/axios.js +290 -0
- package/src/utils/clients.js +270 -0
- package/src/utils/constants.js +396 -0
- package/src/utils/formatters/data/formatAttachment.js +370 -0
- package/src/utils/formatters/data/formatDelta.js +153 -0
- package/src/utils/formatters/index.js +159 -0
- package/src/utils/formatters/value/formatCookie.js +91 -0
- package/src/utils/formatters/value/formatDate.js +36 -0
- package/src/utils/formatters/value/formatID.js +16 -0
- package/src/utils/formatters.js +1067 -0
- package/src/utils/headers.js +199 -0
- package/src/utils/index.js +151 -0
- package/src/utils/monitoring.js +358 -0
- package/src/utils/rateLimiter.js +380 -0
- package/src/utils/tokenRefresh.js +311 -0
- package/src/utils/user-agents.js +238 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require('../utils');
|
|
4
|
+
|
|
5
|
+
module.exports = (defaultFuncs, api, ctx) => {
|
|
6
|
+
return async function createNewGroup(participantIDs, groupTitle, 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
|
+
if (utils.getType(groupTitle) === "Function") {
|
|
23
|
+
callback = groupTitle;
|
|
24
|
+
groupTitle = null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (utils.getType(participantIDs) !== "Array") {
|
|
28
|
+
throw new Error("createNewGroup: participantIDs should be an array.");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (participantIDs.length < 2) {
|
|
32
|
+
throw new Error("createNewGroup: participantIDs should have at least 2 IDs.");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const pids = [];
|
|
36
|
+
for (const n in participantIDs) {
|
|
37
|
+
pids.push({
|
|
38
|
+
fbid: participantIDs[n]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
pids.push({ fbid: ctx.i_userID || ctx.userID });
|
|
42
|
+
|
|
43
|
+
const form = {
|
|
44
|
+
fb_api_caller_class: "RelayModern",
|
|
45
|
+
fb_api_req_friendly_name: "MessengerGroupCreateMutation",
|
|
46
|
+
av: ctx.i_userID || ctx.userID,
|
|
47
|
+
doc_id: "577041672419534",
|
|
48
|
+
variables: JSON.stringify({
|
|
49
|
+
input: {
|
|
50
|
+
entry_point: "jewel_new_group",
|
|
51
|
+
actor_id: ctx.i_userID || ctx.userID,
|
|
52
|
+
participants: pids,
|
|
53
|
+
client_mutation_id: Math.round(Math.random() * 1024).toString(),
|
|
54
|
+
thread_settings: {
|
|
55
|
+
name: groupTitle,
|
|
56
|
+
joinable_mode: "PRIVATE",
|
|
57
|
+
thread_image_fbid: null
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const res = await defaultFuncs.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
64
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs));
|
|
65
|
+
|
|
66
|
+
if (res.errors) {
|
|
67
|
+
throw res;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const threadID = res.data.messenger_group_thread_create.thread.thread_key.thread_fbid;
|
|
71
|
+
callback(null, threadID);
|
|
72
|
+
} catch (err) {
|
|
73
|
+
utils.error("createNewGroup", err);
|
|
74
|
+
callback(err);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return returnPromise;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require('../utils');
|
|
4
|
+
|
|
5
|
+
module.exports = (defaultFuncs, api, ctx) => {
|
|
6
|
+
return async function createPoll(threadID, questionText, options, 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
|
+
if (!ctx.mqttClient) {
|
|
23
|
+
throw new Error("Not connected to MQTT. Please use listenMqtt first.");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!threadID || typeof threadID !== "string") {
|
|
27
|
+
throw new Error("Invalid threadID");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!questionText || typeof questionText !== "string") {
|
|
31
|
+
throw new Error("questionText must be a string");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!Array.isArray(options) || options.length < 2) {
|
|
35
|
+
throw new Error("options must be an array with at least 2 options");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const payload = {
|
|
39
|
+
epoch_id: utils.generateOfflineThreadingID(),
|
|
40
|
+
tasks: [
|
|
41
|
+
{
|
|
42
|
+
failure_count: null,
|
|
43
|
+
label: "163",
|
|
44
|
+
payload: JSON.stringify({
|
|
45
|
+
question_text: questionText,
|
|
46
|
+
thread_key: threadID,
|
|
47
|
+
options: options,
|
|
48
|
+
sync_group: 1
|
|
49
|
+
}),
|
|
50
|
+
queue_name: "poll_creation",
|
|
51
|
+
task_id: Math.floor(Math.random() * 1001)
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
version_id: "8768858626531631"
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const form = JSON.stringify({
|
|
58
|
+
app_id: "772021112871879",
|
|
59
|
+
payload: JSON.stringify(payload),
|
|
60
|
+
request_id: ++ctx.wsReqNumber,
|
|
61
|
+
type: 3
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
ctx.mqttClient.publish("/ls_req", form);
|
|
65
|
+
callback(null, { success: true });
|
|
66
|
+
} catch (err) {
|
|
67
|
+
utils.error("createPoll", err);
|
|
68
|
+
callback(err);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return returnPromise;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require('../utils');
|
|
4
|
+
|
|
5
|
+
module.exports = (defaultFuncs, api, ctx) => {
|
|
6
|
+
return async function deleteMessage(messageID, 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
|
+
message_id: messageID
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const res = await defaultFuncs.post(
|
|
27
|
+
"https://www.facebook.com/ajax/mercury/delete_messages.php",
|
|
28
|
+
ctx.jar,
|
|
29
|
+
form
|
|
30
|
+
).then(utils.parseAndCheckLogin(ctx, defaultFuncs));
|
|
31
|
+
|
|
32
|
+
if (res && res.error) {
|
|
33
|
+
throw res;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return callback(null, { success: true });
|
|
37
|
+
} catch (err) {
|
|
38
|
+
utils.error("deleteMessage", err);
|
|
39
|
+
callback(err);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return returnPromise;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require('../utils');
|
|
4
|
+
|
|
5
|
+
module.exports = (defaultFuncs, api, ctx) => {
|
|
6
|
+
return async function deleteThread(threadOrThreads, 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
|
+
client: "mercury"
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
if (utils.getType(threadOrThreads) !== "Array") {
|
|
27
|
+
threadOrThreads = [threadOrThreads];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
for (let i = 0; i < threadOrThreads.length; i++) {
|
|
31
|
+
form["ids[" + i + "]"] = threadOrThreads[i];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const res = await defaultFuncs.post(
|
|
35
|
+
"https://www.facebook.com/ajax/mercury/delete_thread.php",
|
|
36
|
+
ctx.jar,
|
|
37
|
+
form
|
|
38
|
+
).then(utils.parseAndCheckLogin(ctx, defaultFuncs));
|
|
39
|
+
|
|
40
|
+
if (res && res.error) {
|
|
41
|
+
throw res;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
callback(null, { success: true });
|
|
45
|
+
} catch (err) {
|
|
46
|
+
utils.error("deleteThread", err);
|
|
47
|
+
callback(err);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return returnPromise;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use_strict";
|
|
2
|
+
/**
|
|
3
|
+
* @author RFS-ADRENO
|
|
4
|
+
* @rewrittenBy Isai Ivanov
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const utils = require('../utils');
|
|
8
|
+
|
|
9
|
+
function canBeCalled(func) {
|
|
10
|
+
try {
|
|
11
|
+
Reflect.apply(func, null, []);
|
|
12
|
+
return true;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A function for editing bot's messages.
|
|
20
|
+
* @param {string} text - The text with which the bot will edit its messages.
|
|
21
|
+
* @param {string} messageID - The message ID of the message the bot will edit.
|
|
22
|
+
* @param {Object} callback - Callback for the function.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
26
|
+
return function editMessage(text, messageID, callback) {
|
|
27
|
+
if (!ctx.mqttClient) {
|
|
28
|
+
throw new Error('Not connected to MQTT');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
ctx.wsReqNumber += 1;
|
|
32
|
+
ctx.wsTaskNumber += 1;
|
|
33
|
+
|
|
34
|
+
const queryPayload = {
|
|
35
|
+
message_id: messageID,
|
|
36
|
+
text
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const query = {
|
|
40
|
+
failure_count: null,
|
|
41
|
+
label: '742',
|
|
42
|
+
payload: JSON.stringify(queryPayload),
|
|
43
|
+
queue_name: 'edit_message',
|
|
44
|
+
task_id: ctx.wsTaskNumber
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const context = {
|
|
48
|
+
app_id: '2220391788200892',
|
|
49
|
+
payload: {
|
|
50
|
+
data_trace_id: null,
|
|
51
|
+
epoch_id: parseInt(utils.generateOfflineThreadingID()),
|
|
52
|
+
tasks: [query],
|
|
53
|
+
version_id: '6903494529735864'
|
|
54
|
+
},
|
|
55
|
+
request_id: ctx.wsReqNumber,
|
|
56
|
+
type: 3
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
context.payload = JSON.stringify(context.payload);
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
ctx.mqttClient.publish('/ls_req', JSON.stringify(context), {
|
|
66
|
+
qos: 1, retain: false
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
|
9
|
+
* Sets the custom emoji for a specific Facebook thread via MQTT.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} emoji The emoji character to set as the custom emoji (e.g., "👍", "❤️").
|
|
12
|
+
* @param {string} threadID The ID of the thread where the emoji will be set.
|
|
13
|
+
* @param {Function} [callback] Optional callback function to be invoked upon completion.
|
|
14
|
+
* @param {string} [initiatorID] The ID of the user who initiated the emoji change (e.g., from event.senderID).
|
|
15
|
+
* @returns {Promise<object>} A promise that resolves with a structured event object on success or rejects on error.
|
|
16
|
+
*/
|
|
17
|
+
return function emoji(emoji, threadID, callback, initiatorID) {
|
|
18
|
+
let _callback;
|
|
19
|
+
let _initiatorID;
|
|
20
|
+
|
|
21
|
+
let _resolvePromise;
|
|
22
|
+
let _rejectPromise;
|
|
23
|
+
const returnPromise = new Promise((resolve, reject) => {
|
|
24
|
+
_resolvePromise = resolve;
|
|
25
|
+
_rejectPromise = reject;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (utils.getType(callback) === "Function" || utils.getType(callback) === "AsyncFunction") {
|
|
29
|
+
_callback = callback;
|
|
30
|
+
_initiatorID = initiatorID;
|
|
31
|
+
} else if (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction") {
|
|
32
|
+
_callback = threadID;
|
|
33
|
+
threadID = null;
|
|
34
|
+
_initiatorID = callback;
|
|
35
|
+
} else if (utils.getType(callback) === "string") {
|
|
36
|
+
_initiatorID = callback;
|
|
37
|
+
_callback = undefined;
|
|
38
|
+
} else {
|
|
39
|
+
_callback = undefined;
|
|
40
|
+
_initiatorID = undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!_callback) {
|
|
44
|
+
_callback = function (__err, __data) {
|
|
45
|
+
if (__err) _rejectPromise(__err);
|
|
46
|
+
else _resolvePromise(__data);
|
|
47
|
+
};
|
|
48
|
+
} else {
|
|
49
|
+
const originalCallback = _callback;
|
|
50
|
+
_callback = function(__err, __data) {
|
|
51
|
+
if (__err) {
|
|
52
|
+
originalCallback(__err);
|
|
53
|
+
_rejectPromise(__err);
|
|
54
|
+
} else {
|
|
55
|
+
originalCallback(null, __data);
|
|
56
|
+
_resolvePromise(__data);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
_initiatorID = _initiatorID || ctx.userID;
|
|
62
|
+
|
|
63
|
+
threadID = threadID || ctx.threadID;
|
|
64
|
+
|
|
65
|
+
if (!threadID) {
|
|
66
|
+
return _callback(new Error("threadID is required to set an emoji."));
|
|
67
|
+
}
|
|
68
|
+
if (!emoji) {
|
|
69
|
+
return _callback(new Error("An emoji character is required."));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!ctx.mqttClient) {
|
|
73
|
+
return _callback(new Error("Not connected to MQTT"));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
ctx.wsReqNumber += 1;
|
|
77
|
+
ctx.wsTaskNumber += 1;
|
|
78
|
+
|
|
79
|
+
const queryPayload = {
|
|
80
|
+
thread_key: threadID.toString(),
|
|
81
|
+
custom_emoji: emoji,
|
|
82
|
+
avatar_sticker_instruction_key_id: null,
|
|
83
|
+
sync_group: 1,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const query = {
|
|
87
|
+
failure_count: null,
|
|
88
|
+
label: '100003',
|
|
89
|
+
payload: JSON.stringify(queryPayload),
|
|
90
|
+
queue_name: 'thread_quick_reaction',
|
|
91
|
+
task_id: ctx.wsTaskNumber,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const context = {
|
|
95
|
+
app_id: ctx.appID,
|
|
96
|
+
payload: {
|
|
97
|
+
epoch_id: parseInt(utils.generateOfflineThreadingID()),
|
|
98
|
+
tasks: [query],
|
|
99
|
+
version_id: '24631415369801570',
|
|
100
|
+
},
|
|
101
|
+
request_id: ctx.wsReqNumber,
|
|
102
|
+
type: 3,
|
|
103
|
+
};
|
|
104
|
+
context.payload = JSON.stringify(context.payload);
|
|
105
|
+
|
|
106
|
+
ctx.mqttClient.publish('/ls_req', JSON.stringify(context), { qos: 1, retain: false }, (err) => {
|
|
107
|
+
if (err) {
|
|
108
|
+
return _callback(new Error(`MQTT publish failed for emoji: ${err.message || err}`));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const emojiChangeEvent = {
|
|
112
|
+
type: "thread_emoji_update",
|
|
113
|
+
threadID: threadID,
|
|
114
|
+
newEmoji: emoji,
|
|
115
|
+
senderID: _initiatorID,
|
|
116
|
+
BotID: ctx.userID,
|
|
117
|
+
timestamp: Date.now(),
|
|
118
|
+
};
|
|
119
|
+
_callback(null, emojiChangeEvent);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
return returnPromise;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const log = require("npmlog");
|
|
4
|
+
const utils = require("../utils");
|
|
5
|
+
|
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
+
return function fetchThemeData(themeID, callback) {
|
|
8
|
+
let resolveFunc, rejectFunc;
|
|
9
|
+
const promise = new Promise((resolve, reject) => {
|
|
10
|
+
resolveFunc = resolve;
|
|
11
|
+
rejectFunc = reject;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const done = callback || function (err, data) {
|
|
15
|
+
if (err) return rejectFunc(err);
|
|
16
|
+
resolveFunc(data);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
if (!themeID) {
|
|
20
|
+
done({ error: "Theme ID is a required parameter" });
|
|
21
|
+
return promise;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const payload = {
|
|
25
|
+
av: ctx.userID,
|
|
26
|
+
__user: ctx.userID,
|
|
27
|
+
__a: 1,
|
|
28
|
+
__req: utils.getSignatureID(),
|
|
29
|
+
fb_dtsg: ctx.fb_dtsg,
|
|
30
|
+
lsd: ctx.fb_dtsg,
|
|
31
|
+
jazoest: ctx.jazoest,
|
|
32
|
+
fb_api_caller_class: "RelayModern",
|
|
33
|
+
fb_api_req_friendly_name: "MWPThreadThemeProviderQuery",
|
|
34
|
+
variables: JSON.stringify({ id: themeID.toString() }),
|
|
35
|
+
server_timestamps: true,
|
|
36
|
+
doc_id: "9734829906576883"
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
defaultFuncs
|
|
40
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, payload)
|
|
41
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
42
|
+
.then((res) => {
|
|
43
|
+
if (res.errors) throw res.errors;
|
|
44
|
+
|
|
45
|
+
const data = res?.data?.messenger_thread_theme;
|
|
46
|
+
if (!data) throw new Error("Theme data could not be located in the response");
|
|
47
|
+
|
|
48
|
+
const output = {
|
|
49
|
+
id: data.id,
|
|
50
|
+
name: data.accessibility_label,
|
|
51
|
+
description: data.description,
|
|
52
|
+
colors: data.gradient_colors || [data.fallback_color],
|
|
53
|
+
backgroundImage: data.background_asset?.image?.uri || null
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
done(null, output);
|
|
57
|
+
})
|
|
58
|
+
.catch((err) => {
|
|
59
|
+
log.error("fetchThemeData", err);
|
|
60
|
+
done(err);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return promise;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Author @YanMaglinte
|
|
5
|
+
* https://github.com/YANDEVA
|
|
6
|
+
* * Example:
|
|
7
|
+
* api.follow("100090794779367", true);
|
|
8
|
+
* jsdocs @ChoruOfficial
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {object} defaultFuncs The default functions for making API requests.
|
|
13
|
+
* @param {object} api The full API object.
|
|
14
|
+
* @param {object} ctx The context object.
|
|
15
|
+
* @returns {function(senderID: string, boolean: boolean, callback?: (err: any, data?: any) => void): void} The follow function.
|
|
16
|
+
*/
|
|
17
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
18
|
+
/**
|
|
19
|
+
* Follows or unfollows a user on Facebook.
|
|
20
|
+
* @param {string} senderID The ID of the user to follow or unfollow.
|
|
21
|
+
* @param {boolean} boolean Set to `true` to follow the user, `false` to unfollow.
|
|
22
|
+
* @param {(err: any, data?: any) => void} [callback] An optional callback function.
|
|
23
|
+
*/
|
|
24
|
+
return function follow(senderID, boolean, callback) {
|
|
25
|
+
let form;
|
|
26
|
+
if (boolean) {
|
|
27
|
+
form = {
|
|
28
|
+
av: ctx.userID,
|
|
29
|
+
fb_api_req_friendly_name: "CometUserFollowMutation",
|
|
30
|
+
fb_api_caller_class: "RelayModern",
|
|
31
|
+
doc_id: "25472099855769847",
|
|
32
|
+
variables: JSON.stringify({
|
|
33
|
+
input: {
|
|
34
|
+
attribution_id_v2:
|
|
35
|
+
"ProfileCometTimelineListViewRoot.react,comet.profile.timeline.list,via_cold_start,1717249218695,723451,250100865708545,,",
|
|
36
|
+
is_tracking_encrypted: true,
|
|
37
|
+
subscribe_location: "PROFILE",
|
|
38
|
+
subscribee_id: senderID,
|
|
39
|
+
tracking: null,
|
|
40
|
+
actor_id: ctx.userID,
|
|
41
|
+
client_mutation_id: "1",
|
|
42
|
+
},
|
|
43
|
+
scale: 1,
|
|
44
|
+
}),
|
|
45
|
+
};
|
|
46
|
+
} else {
|
|
47
|
+
form = {
|
|
48
|
+
av: ctx.userID,
|
|
49
|
+
fb_api_req_friendly_name: "CometUserUnfollowMutation",
|
|
50
|
+
fb_api_caller_class: "RelayModern",
|
|
51
|
+
doc_id: "25472099855769847",
|
|
52
|
+
variables: JSON.stringify({
|
|
53
|
+
action_render_location: "WWW_COMET_FRIEND_MENU",
|
|
54
|
+
input: {
|
|
55
|
+
attribution_id_v2:
|
|
56
|
+
"ProfileCometTimelineListViewRoot.react,comet.profile.timeline.list,tap_search_bar,1717294006136,602597,250100865708545,,",
|
|
57
|
+
is_tracking_encrypted: true,
|
|
58
|
+
subscribe_location: "PROFILE",
|
|
59
|
+
tracking: null,
|
|
60
|
+
unsubscribee_id: senderID,
|
|
61
|
+
actor_id: ctx.userID,
|
|
62
|
+
client_mutation_id: "10",
|
|
63
|
+
},
|
|
64
|
+
scale: 1,
|
|
65
|
+
}),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
api.httpPost("https://www.facebook.com/api/graphql/", form, (err, data) => {
|
|
70
|
+
if (err) {
|
|
71
|
+
if (typeof callback === "function") {
|
|
72
|
+
callback(err);
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
if (typeof callback === "function") {
|
|
76
|
+
callback(null, data);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require('../utils');
|
|
4
|
+
|
|
5
|
+
module.exports = (defaultFuncs, api, ctx) => {
|
|
6
|
+
return async function forwardMessage(messageID, threadIDs, 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
|
+
if (!Array.isArray(threadIDs)) {
|
|
23
|
+
threadIDs = [threadIDs];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const form = {
|
|
27
|
+
message_id: messageID
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
threadIDs.forEach(id => {
|
|
31
|
+
form[`recipient_ids[${id}]`] = id;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const res = await defaultFuncs.post(
|
|
35
|
+
"https://www.facebook.com/ajax/mercury/forward_message.php",
|
|
36
|
+
ctx.jar,
|
|
37
|
+
form
|
|
38
|
+
).then(utils.parseAndCheckLogin(ctx, defaultFuncs));
|
|
39
|
+
|
|
40
|
+
if (res && res.error) {
|
|
41
|
+
throw res;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
callback(null, { success: true, forwardedTo: threadIDs });
|
|
45
|
+
} catch (err) {
|
|
46
|
+
utils.error("forwardMessage", err);
|
|
47
|
+
callback(err);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return returnPromise;
|
|
51
|
+
};
|
|
52
|
+
};
|