stfca 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-MIT +4 -0
- package/README.md +325 -0
- package/index.d.ts +615 -0
- package/index.js +1 -0
- package/module/config.js +33 -0
- package/module/login.js +48 -0
- package/module/loginHelper.js +722 -0
- package/module/options.js +44 -0
- package/package.json +69 -0
- package/src/api/action/addExternalModule.js +25 -0
- package/src/api/action/changeAvatar.js +137 -0
- package/src/api/action/changeBio.js +75 -0
- package/src/api/action/getCurrentUserID.js +7 -0
- package/src/api/action/handleFriendRequest.js +57 -0
- package/src/api/action/logout.js +76 -0
- package/src/api/action/refreshFb_dtsg.js +71 -0
- package/src/api/action/setPostReaction.js +106 -0
- package/src/api/action/unfriend.js +54 -0
- package/src/api/http/httpGet.js +46 -0
- package/src/api/http/httpPost.js +52 -0
- package/src/api/http/postFormData.js +47 -0
- package/src/api/messaging/addUserToGroup.js +68 -0
- package/src/api/messaging/changeAdminStatus.js +122 -0
- package/src/api/messaging/changeArchivedStatus.js +55 -0
- package/src/api/messaging/changeBlockedStatus.js +48 -0
- package/src/api/messaging/changeGroupImage.js +90 -0
- package/src/api/messaging/changeNickname.js +70 -0
- package/src/api/messaging/changeThreadColor.js +79 -0
- package/src/api/messaging/changeThreadEmoji.js +106 -0
- package/src/api/messaging/createNewGroup.js +88 -0
- package/src/api/messaging/createPoll.js +43 -0
- package/src/api/messaging/deleteMessage.js +56 -0
- package/src/api/messaging/deleteThread.js +56 -0
- package/src/api/messaging/editMessage.js +68 -0
- package/src/api/messaging/forwardAttachment.js +51 -0
- package/src/api/messaging/getEmojiUrl.js +29 -0
- package/src/api/messaging/getFriendsList.js +82 -0
- package/src/api/messaging/getMessage.js +829 -0
- package/src/api/messaging/handleMessageRequest.js +65 -0
- package/src/api/messaging/markAsDelivered.js +57 -0
- package/src/api/messaging/markAsRead.js +88 -0
- package/src/api/messaging/markAsReadAll.js +49 -0
- package/src/api/messaging/markAsSeen.js +61 -0
- package/src/api/messaging/muteThread.js +50 -0
- package/src/api/messaging/removeUserFromGroup.js +105 -0
- package/src/api/messaging/resolvePhotoUrl.js +43 -0
- package/src/api/messaging/searchForThread.js +52 -0
- package/src/api/messaging/sendMessage.js +379 -0
- package/src/api/messaging/sendMessageMqtt.js +323 -0
- package/src/api/messaging/sendTypingIndicator.js +67 -0
- package/src/api/messaging/setMessageReaction.js +75 -0
- package/src/api/messaging/setTitle.js +119 -0
- package/src/api/messaging/shareContact.js +49 -0
- package/src/api/messaging/threadColors.js +128 -0
- package/src/api/messaging/unsendMessage.js +81 -0
- package/src/api/messaging/uploadAttachment.js +95 -0
- package/src/api/socket/core/connectMqtt.js +179 -0
- package/src/api/socket/core/getSeqID.js +25 -0
- package/src/api/socket/core/getTaskResponseData.js +22 -0
- package/src/api/socket/core/markDelivery.js +12 -0
- package/src/api/socket/core/parseDelta.js +351 -0
- package/src/api/socket/detail/buildStream.js +208 -0
- package/src/api/socket/detail/constants.js +24 -0
- package/src/api/socket/listenMqtt.js +133 -0
- package/src/api/threads/getThreadHistory.js +664 -0
- package/src/api/threads/getThreadInfo.js +358 -0
- package/src/api/threads/getThreadList.js +248 -0
- package/src/api/threads/getThreadPictures.js +78 -0
- package/src/api/users/getUserID.js +65 -0
- package/src/api/users/getUserInfo.js +319 -0
- package/src/api/users/getUserInfoV2.js +133 -0
- package/src/core/sendReqMqtt.js +63 -0
- package/src/database/models/index.js +49 -0
- package/src/database/models/thread.js +31 -0
- package/src/database/models/user.js +32 -0
- package/src/database/threadData.js +98 -0
- package/src/database/userData.js +89 -0
- package/src/utils/client.js +214 -0
- package/src/utils/constants.js +23 -0
- package/src/utils/format.js +1111 -0
- package/src/utils/headers.js +41 -0
- package/src/utils/request.js +215 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { getType } = require("../../utils/format.js");
|
|
3
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
4
|
+
return function sendTyping(threadID, isTyping, options, callback) {
|
|
5
|
+
var resolveFunc = function () { };
|
|
6
|
+
var rejectFunc = function () { };
|
|
7
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
|
8
|
+
resolveFunc = resolve;
|
|
9
|
+
rejectFunc = reject;
|
|
10
|
+
});
|
|
11
|
+
if (getType(options) == "Function" || getType(options) == "AsyncFunction") {
|
|
12
|
+
callback = options;
|
|
13
|
+
options = {};
|
|
14
|
+
}
|
|
15
|
+
options = options || {};
|
|
16
|
+
if (!callback || getType(callback) != "Function" && getType(callback) != "AsyncFunction") {
|
|
17
|
+
callback = function (err, data) {
|
|
18
|
+
if (err) return rejectFunc(err);
|
|
19
|
+
resolveFunc(data);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (!threadID) {
|
|
23
|
+
return callback(new Error("threadID is required"));
|
|
24
|
+
}
|
|
25
|
+
const threadIDs = Array.isArray(threadID) ? threadID : [threadID];
|
|
26
|
+
threadIDs.forEach(tid => {
|
|
27
|
+
var isGroupThread = getType(tid) === "Array" ? 0 : 1;
|
|
28
|
+
var threadType = isGroupThread ? 2 : 1;
|
|
29
|
+
var duration = options.duration || 10000;
|
|
30
|
+
var autoStop = options.autoStop !== false;
|
|
31
|
+
var attribution = options.type || 0;
|
|
32
|
+
const publishTypingStatus = (isTypingStatus) => {
|
|
33
|
+
ctx.mqttClient.publish('/ls_req',
|
|
34
|
+
JSON.stringify({
|
|
35
|
+
app_id: "772021112871879",
|
|
36
|
+
payload: JSON.stringify({
|
|
37
|
+
label: "3",
|
|
38
|
+
payload: JSON.stringify({
|
|
39
|
+
"thread_key": parseInt(tid),
|
|
40
|
+
"is_group_thread": isGroupThread,
|
|
41
|
+
"is_typing": isTypingStatus ? 1 : 0,
|
|
42
|
+
"attribution": attribution,
|
|
43
|
+
"sync_group": 1,
|
|
44
|
+
"thread_type": threadType
|
|
45
|
+
}),
|
|
46
|
+
version: "8965252033599983"
|
|
47
|
+
}),
|
|
48
|
+
request_id: ++ctx.req_ID,
|
|
49
|
+
type: 4
|
|
50
|
+
}),
|
|
51
|
+
{
|
|
52
|
+
qos: 1,
|
|
53
|
+
retain: false,
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
publishTypingStatus(isTyping);
|
|
58
|
+
if (isTyping && autoStop) {
|
|
59
|
+
setTimeout(() => {
|
|
60
|
+
publishTypingStatus(false);
|
|
61
|
+
}, duration);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
callback(null, true);
|
|
65
|
+
return returnPromise;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { generateOfflineThreadingID, getCurrentTimestamp } = require("../../utils/format");
|
|
4
|
+
|
|
5
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
6
|
+
return function setMessageReaction(reaction, messageID, threadID, callback) {
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
if (!ctx.mqttClient) {
|
|
9
|
+
const err = new Error("MQTT client not connected");
|
|
10
|
+
if (typeof callback === 'function') callback(err);
|
|
11
|
+
return reject(err);
|
|
12
|
+
}
|
|
13
|
+
if (!reaction || !messageID || !threadID) {
|
|
14
|
+
const err = new Error("Missing required parameters");
|
|
15
|
+
if (typeof callback === 'function') callback(err);
|
|
16
|
+
return reject(err);
|
|
17
|
+
}
|
|
18
|
+
const reqID = ++ctx.wsReqNumber;
|
|
19
|
+
const taskID = ++ctx.wsTaskNumber;
|
|
20
|
+
const taskPayload = {
|
|
21
|
+
thread_key: threadID,
|
|
22
|
+
timestamp_ms: getCurrentTimestamp(),
|
|
23
|
+
message_id: messageID,
|
|
24
|
+
reaction: reaction,
|
|
25
|
+
actor_id: ctx.userID,
|
|
26
|
+
reaction_style: null,
|
|
27
|
+
sync_group: 1,
|
|
28
|
+
send_attribution: 65537,
|
|
29
|
+
dataclass_params: null,
|
|
30
|
+
attachment_fbid: null
|
|
31
|
+
};
|
|
32
|
+
const task = {
|
|
33
|
+
failure_count: null,
|
|
34
|
+
label: "29",
|
|
35
|
+
payload: JSON.stringify(taskPayload),
|
|
36
|
+
queue_name: JSON.stringify(["reaction", messageID]),
|
|
37
|
+
task_id: taskID,
|
|
38
|
+
};
|
|
39
|
+
const mqttForm = {
|
|
40
|
+
app_id: "772021112871879",
|
|
41
|
+
payload: JSON.stringify({
|
|
42
|
+
data_trace_id: null,
|
|
43
|
+
epoch_id: parseInt(generateOfflineThreadingID()),
|
|
44
|
+
tasks: [task],
|
|
45
|
+
version_id: "25376272951962053"
|
|
46
|
+
}),
|
|
47
|
+
request_id: reqID,
|
|
48
|
+
type: 3
|
|
49
|
+
};
|
|
50
|
+
const handleResponse = (topic, message) => {
|
|
51
|
+
if (topic !== "/ls_resp") return;
|
|
52
|
+
let json;
|
|
53
|
+
try {
|
|
54
|
+
json = JSON.parse(message.toString());
|
|
55
|
+
json.payload = JSON.parse(json.payload);
|
|
56
|
+
} catch {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (json.request_id !== reqID) return;
|
|
60
|
+
ctx.mqttClient.removeListener("message", handleResponse);
|
|
61
|
+
if (typeof callback === 'function') callback(null, { success: true });
|
|
62
|
+
return resolve({ success: true });
|
|
63
|
+
};
|
|
64
|
+
ctx.mqttClient.on("message", handleResponse);
|
|
65
|
+
ctx.mqttClient.publish("/ls_req", JSON.stringify(mqttForm), { qos: 1, retain: false }, (err) => {
|
|
66
|
+
if (err) {
|
|
67
|
+
ctx.mqttClient.removeListener("message", handleResponse);
|
|
68
|
+
console.error("[FCA-ERROR] setMessageReaction" + err);
|
|
69
|
+
if (typeof callback === 'function') callback(err);
|
|
70
|
+
return reject(err);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { getType, generateOfflineThreadingID, generateTimestampRelative, generateThreadingID, getCurrentTimestamp } = require("../../utils/format");
|
|
4
|
+
const { parseAndCheckLogin } = require("../../utils/client");
|
|
5
|
+
const log = require("npmlog");
|
|
6
|
+
|
|
7
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
8
|
+
function setTitleNoMqtt(newTitle, threadID, callback) {
|
|
9
|
+
if (!callback && (getType(threadID) === "Function" || getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
|
|
10
|
+
var resolveFunc = function () { };
|
|
11
|
+
var rejectFunc = function () { };
|
|
12
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
|
13
|
+
resolveFunc = resolve;
|
|
14
|
+
rejectFunc = reject;
|
|
15
|
+
});
|
|
16
|
+
if (!callback) {
|
|
17
|
+
callback = function (err, data) {
|
|
18
|
+
if (err) return rejectFunc(err);
|
|
19
|
+
resolveFunc(data);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
var messageAndOTID = generateOfflineThreadingID();
|
|
23
|
+
var form = {
|
|
24
|
+
client: "mercury",
|
|
25
|
+
action_type: "ma-type:log-message",
|
|
26
|
+
author: "fbid:" + ctx.userID,
|
|
27
|
+
author_email: "",
|
|
28
|
+
coordinates: "",
|
|
29
|
+
timestamp: Date.now(),
|
|
30
|
+
timestamp_absolute: "Today",
|
|
31
|
+
timestamp_relative: generateTimestampRelative(),
|
|
32
|
+
timestamp_time_passed: "0",
|
|
33
|
+
is_unread: false,
|
|
34
|
+
is_cleared: false,
|
|
35
|
+
is_forward: false,
|
|
36
|
+
is_filtered_content: false,
|
|
37
|
+
is_spoof_warning: false,
|
|
38
|
+
source: "source:chat:web",
|
|
39
|
+
"source_tags[0]": "source:chat",
|
|
40
|
+
status: "0",
|
|
41
|
+
offline_threading_id: messageAndOTID,
|
|
42
|
+
message_id: messageAndOTID,
|
|
43
|
+
threading_id: generateThreadingID(ctx.clientID),
|
|
44
|
+
manual_retry_cnt: "0",
|
|
45
|
+
thread_fbid: threadID,
|
|
46
|
+
thread_name: newTitle,
|
|
47
|
+
thread_id: threadID,
|
|
48
|
+
log_message_type: "log:thread-name"
|
|
49
|
+
};
|
|
50
|
+
defaultFuncs
|
|
51
|
+
.post("https://www.facebook.com/messaging/set_thread_name/", ctx.jar, form)
|
|
52
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
|
53
|
+
.then(function (resData) {
|
|
54
|
+
if (resData.error && resData.error === 1545012) throw { error: "Cannot change chat title: Not member of chat." };
|
|
55
|
+
if (resData.error && resData.error === 1545003) throw { error: "Cannot set title of single-user chat." };
|
|
56
|
+
if (resData.error) throw resData;
|
|
57
|
+
return callback();
|
|
58
|
+
})
|
|
59
|
+
.catch(function (err) {
|
|
60
|
+
log.error("setTitle", err);
|
|
61
|
+
return callback(err);
|
|
62
|
+
});
|
|
63
|
+
return returnPromise;
|
|
64
|
+
};
|
|
65
|
+
function setTitleMqtt(newTitle, threadID, callback) {
|
|
66
|
+
if (!ctx.mqttClient) {
|
|
67
|
+
throw new Error("Not connected to MQTT");
|
|
68
|
+
}
|
|
69
|
+
var resolveFunc = function () { };
|
|
70
|
+
var rejectFunc = function () { };
|
|
71
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
|
72
|
+
resolveFunc = resolve;
|
|
73
|
+
rejectFunc = reject;
|
|
74
|
+
});
|
|
75
|
+
if (!callback) {
|
|
76
|
+
callback = function (err, data) {
|
|
77
|
+
if (err) return rejectFunc(err);
|
|
78
|
+
resolveFunc(data);
|
|
79
|
+
data
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
let count_req = 0
|
|
83
|
+
var form = JSON.stringify({
|
|
84
|
+
"app_id": "2220391788200892",
|
|
85
|
+
"payload": JSON.stringify({
|
|
86
|
+
epoch_id: generateOfflineThreadingID(),
|
|
87
|
+
tasks: [
|
|
88
|
+
{
|
|
89
|
+
failure_count: null,
|
|
90
|
+
label: '32',
|
|
91
|
+
payload: JSON.stringify({
|
|
92
|
+
"thread_key": threadID,
|
|
93
|
+
"thread_name": newTitle,
|
|
94
|
+
"sync_group": 1
|
|
95
|
+
}),
|
|
96
|
+
queue_name: threadID,
|
|
97
|
+
task_id: Math.random() * 1001 << 0
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
version_id: '8798795233522156'
|
|
101
|
+
}),
|
|
102
|
+
"request_id": ++count_req,
|
|
103
|
+
"type": 3
|
|
104
|
+
});
|
|
105
|
+
mqttClient.publish('/ls_req', form);
|
|
106
|
+
return returnPromise;
|
|
107
|
+
};
|
|
108
|
+
return function setTitle(newTitle, threadID, callback) {
|
|
109
|
+
if (ctx.mqttClient) {
|
|
110
|
+
try {
|
|
111
|
+
setTitleMqtt(newTitle, threadID, callback);
|
|
112
|
+
} catch (e) {
|
|
113
|
+
setTitleNoMqtt(newTitle, threadID, callback);
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
setTitleNoMqtt(newTitle, threadID, callback);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { generateOfflineThreadingID } = require("../../utils/format");
|
|
4
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
|
5
|
+
return function shareContact(text, senderID, threadID, callback) {
|
|
6
|
+
if (!text) {
|
|
7
|
+
text = "";
|
|
8
|
+
}
|
|
9
|
+
var resolveFunc = function() {};
|
|
10
|
+
var rejectFunc = function() {};
|
|
11
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
|
12
|
+
resolveFunc = resolve;
|
|
13
|
+
rejectFunc = reject;
|
|
14
|
+
});
|
|
15
|
+
if (!callback) {
|
|
16
|
+
callback = function(err, data) {
|
|
17
|
+
if (err) return rejectFunc(err);
|
|
18
|
+
resolveFunc(data);
|
|
19
|
+
data;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
let count_req = 0;
|
|
23
|
+
var form = JSON.stringify({
|
|
24
|
+
app_id: "2220391788200892",
|
|
25
|
+
payload: JSON.stringify({
|
|
26
|
+
tasks: [
|
|
27
|
+
{
|
|
28
|
+
label: "359",
|
|
29
|
+
payload: JSON.stringify({
|
|
30
|
+
contact_id: senderID,
|
|
31
|
+
sync_group: 1,
|
|
32
|
+
text: text || "",
|
|
33
|
+
thread_id: threadID
|
|
34
|
+
}),
|
|
35
|
+
queue_name: "messenger_contact_sharing",
|
|
36
|
+
task_id: (Math.random() * 1001) << 0,
|
|
37
|
+
failure_count: null
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
epoch_id: generateOfflineThreadingID(),
|
|
41
|
+
version_id: "7214102258676893"
|
|
42
|
+
}),
|
|
43
|
+
request_id: ++count_req,
|
|
44
|
+
type: 3
|
|
45
|
+
});
|
|
46
|
+
mqttClient.publish("/ls_req", form);
|
|
47
|
+
return returnPromise;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = function(_defaultFuncs, _api, _ctx) {
|
|
4
|
+
// Currently the only colors that can be passed to api.changeThreadColor(); may change if Facebook adds more
|
|
5
|
+
return {
|
|
6
|
+
//Old hex colors.
|
|
7
|
+
////MessengerBlue: null,
|
|
8
|
+
////Viking: "#44bec7",
|
|
9
|
+
////GoldenPoppy: "#ffc300",
|
|
10
|
+
////RadicalRed: "#fa3c4c",
|
|
11
|
+
////Shocking: "#d696bb",
|
|
12
|
+
////PictonBlue: "#6699cc",
|
|
13
|
+
////FreeSpeechGreen: "#13cf13",
|
|
14
|
+
////Pumpkin: "#ff7e29",
|
|
15
|
+
////LightCoral: "#e68585",
|
|
16
|
+
////MediumSlateBlue: "#7646ff",
|
|
17
|
+
////DeepSkyBlue: "#20cef5",
|
|
18
|
+
////Fern: "#67b868",
|
|
19
|
+
////Cameo: "#d4a88c",
|
|
20
|
+
////BrilliantRose: "#ff5ca1",
|
|
21
|
+
////BilobaFlower: "#a695c7"
|
|
22
|
+
|
|
23
|
+
//#region This part is for backward compatibly
|
|
24
|
+
//trying to match the color one-by-one. kill me plz
|
|
25
|
+
MessengerBlue: "196241301102133", //DefaultBlue
|
|
26
|
+
Viking: "1928399724138152", //TealBlue
|
|
27
|
+
GoldenPoppy: "174636906462322", //Yellow
|
|
28
|
+
RadicalRed: "2129984390566328", //Red
|
|
29
|
+
Shocking: "2058653964378557", //LavenderPurple
|
|
30
|
+
FreeSpeechGreen: "2136751179887052", //Green
|
|
31
|
+
Pumpkin: "175615189761153", //Orange
|
|
32
|
+
LightCoral: "980963458735625", //CoralPink
|
|
33
|
+
MediumSlateBlue: "234137870477637", //BrightPurple
|
|
34
|
+
DeepSkyBlue: "2442142322678320", //AquaBlue
|
|
35
|
+
BrilliantRose: "169463077092846", //HotPink
|
|
36
|
+
DefaultBlue: "196241301102133",
|
|
37
|
+
HotPink: "169463077092846",
|
|
38
|
+
AquaBlue: "2442142322678320",
|
|
39
|
+
BrightPurple: "234137870477637",
|
|
40
|
+
CoralPink: "980963458735625",
|
|
41
|
+
Orange: "175615189761153",
|
|
42
|
+
Green: "2136751179887052",
|
|
43
|
+
LavenderPurple: "2058653964378557",
|
|
44
|
+
Red: "2129984390566328",
|
|
45
|
+
Yellow: "174636906462322",
|
|
46
|
+
TealBlue: "1928399724138152",
|
|
47
|
+
Aqua: "417639218648241",
|
|
48
|
+
Mango: "930060997172551",
|
|
49
|
+
Berry: "164535220883264",
|
|
50
|
+
Citrus: "370940413392601",
|
|
51
|
+
Candy: "205488546921017",
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* July 06, 2022
|
|
55
|
+
* added by @NTKhang
|
|
56
|
+
*/
|
|
57
|
+
Earth: "1833559466821043",
|
|
58
|
+
Support: "365557122117011",
|
|
59
|
+
Music: "339021464972092",
|
|
60
|
+
Pride: "1652456634878319",
|
|
61
|
+
DoctorStrange: "538280997628317",
|
|
62
|
+
LoFi: "1060619084701625",
|
|
63
|
+
Sky: "3190514984517598",
|
|
64
|
+
LunarNewYear: "357833546030778",
|
|
65
|
+
Celebration: "627144732056021",
|
|
66
|
+
Chill: "390127158985345",
|
|
67
|
+
StrangerThings: "1059859811490132",
|
|
68
|
+
Dune: "1455149831518874",
|
|
69
|
+
Care: "275041734441112",
|
|
70
|
+
Astrology: "3082966625307060",
|
|
71
|
+
JBalvin: "184305226956268",
|
|
72
|
+
Birthday: "621630955405500",
|
|
73
|
+
Cottagecore: "539927563794799",
|
|
74
|
+
Ocean: "736591620215564",
|
|
75
|
+
Love: "741311439775765",
|
|
76
|
+
TieDye: "230032715012014",
|
|
77
|
+
Monochrome: "788274591712841",
|
|
78
|
+
Default: "3259963564026002",
|
|
79
|
+
Rocket: "582065306070020",
|
|
80
|
+
Berry2: "724096885023603",
|
|
81
|
+
Candy2: "624266884847972",
|
|
82
|
+
Unicorn: "273728810607574",
|
|
83
|
+
Tropical: "262191918210707",
|
|
84
|
+
Maple: "2533652183614000",
|
|
85
|
+
Sushi: "909695489504566",
|
|
86
|
+
Citrus2: "557344741607350",
|
|
87
|
+
Lollipop: "280333826736184",
|
|
88
|
+
Shadow: "271607034185782",
|
|
89
|
+
Rose: "1257453361255152",
|
|
90
|
+
Lavender: "571193503540759",
|
|
91
|
+
Tulip: "2873642949430623",
|
|
92
|
+
Classic: "3273938616164733",
|
|
93
|
+
Peach: "3022526817824329",
|
|
94
|
+
Honey: "672058580051520",
|
|
95
|
+
Kiwi: "3151463484918004",
|
|
96
|
+
Grape: "193497045377796",
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* July 15, 2022
|
|
100
|
+
* added by @NTKhang
|
|
101
|
+
*/
|
|
102
|
+
NonBinary: "737761000603635",
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* November 25, 2022
|
|
106
|
+
* added by @NTKhang
|
|
107
|
+
*/
|
|
108
|
+
ThankfulForFriends: "1318983195536293",
|
|
109
|
+
Transgender: "504518465021637",
|
|
110
|
+
TaylorSwift: "769129927636836",
|
|
111
|
+
NationalComingOutDay: "788102625833584",
|
|
112
|
+
Autumn: "822549609168155",
|
|
113
|
+
Cyberpunk2077: "780962576430091",
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* May 13, 2023
|
|
117
|
+
*/
|
|
118
|
+
MothersDay: "1288506208402340",
|
|
119
|
+
APAHM: "121771470870245",
|
|
120
|
+
Parenthood: "810978360551741",
|
|
121
|
+
StarWars: "1438011086532622",
|
|
122
|
+
GuardianOfTheGalaxy: "101275642962533",
|
|
123
|
+
Bloom: "158263147151440",
|
|
124
|
+
BubbleTea: "195296273246380",
|
|
125
|
+
Basketball: "6026716157422736",
|
|
126
|
+
ElephantsAndFlowers: "693996545771691"
|
|
127
|
+
};
|
|
128
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { generateOfflineThreadingID } = require("../../utils/format.js");
|
|
4
|
+
const log = require("npmlog");
|
|
5
|
+
|
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
+
return function unsendMessage(messageID, threadID, callback) {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
if (!ctx.mqttClient) {
|
|
10
|
+
const err = new Error("Not connected to MQTT");
|
|
11
|
+
callback?.(err);
|
|
12
|
+
return reject(err);
|
|
13
|
+
}
|
|
14
|
+
const reqID = ++ctx.wsReqNumber;
|
|
15
|
+
const taskID = ++ctx.wsTaskNumber;
|
|
16
|
+
const taskPayload = {
|
|
17
|
+
message_id: messageID,
|
|
18
|
+
thread_key: threadID,
|
|
19
|
+
sync_group: 1,
|
|
20
|
+
};
|
|
21
|
+
const task = {
|
|
22
|
+
failure_count: null,
|
|
23
|
+
label: "33",
|
|
24
|
+
payload: JSON.stringify(taskPayload),
|
|
25
|
+
queue_name: "unsend_message",
|
|
26
|
+
task_id: taskID,
|
|
27
|
+
};
|
|
28
|
+
const content = {
|
|
29
|
+
app_id: "2220391788200892",
|
|
30
|
+
payload: JSON.stringify({
|
|
31
|
+
tasks: [task],
|
|
32
|
+
epoch_id: parseInt(generateOfflineThreadingID()),
|
|
33
|
+
version_id: "25393437286970779",
|
|
34
|
+
}),
|
|
35
|
+
request_id: reqID,
|
|
36
|
+
type: 3,
|
|
37
|
+
};
|
|
38
|
+
try {
|
|
39
|
+
ctx.mqttClient.publish("/ls_req", JSON.stringify(content), {
|
|
40
|
+
qos: 1,
|
|
41
|
+
retain: false
|
|
42
|
+
});
|
|
43
|
+
} catch (err) {
|
|
44
|
+
log.error("unsendMessage (MQTT publish failed)", err);
|
|
45
|
+
callback?.(err);
|
|
46
|
+
return reject(err);
|
|
47
|
+
}
|
|
48
|
+
const handleRes = (topic, message) => {
|
|
49
|
+
if (topic !== "/ls_resp") return;
|
|
50
|
+
let jsonMsg;
|
|
51
|
+
try {
|
|
52
|
+
jsonMsg = JSON.parse(message.toString());
|
|
53
|
+
jsonMsg.payload = JSON.parse(jsonMsg.payload);
|
|
54
|
+
} catch (err) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (jsonMsg.request_id !== reqID) return;
|
|
58
|
+
ctx.mqttClient.removeListener("message", handleRes);
|
|
59
|
+
try {
|
|
60
|
+
const msgID = jsonMsg.payload.step?.[1]?.[2]?.[2]?.[1]?.[2];
|
|
61
|
+
const msgReplace = jsonMsg.payload.step?.[1]?.[2]?.[2]?.[1]?.[4];
|
|
62
|
+
if (msgID && msgReplace) {
|
|
63
|
+
const bodies = {
|
|
64
|
+
body: msgReplace,
|
|
65
|
+
messageID: msgID
|
|
66
|
+
};
|
|
67
|
+
callback?.(null, bodies);
|
|
68
|
+
return resolve(bodies);
|
|
69
|
+
} else {
|
|
70
|
+
callback?.(null, { success: true });
|
|
71
|
+
return resolve({ success: true });
|
|
72
|
+
}
|
|
73
|
+
} catch (err) {
|
|
74
|
+
callback?.(null, { success: true });
|
|
75
|
+
return resolve({ success: true });
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
ctx.mqttClient.on("message", handleRes);
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const log = require("npmlog");
|
|
3
|
+
const { parseAndCheckLogin } = require("../../utils/client");
|
|
4
|
+
const { getType } = require("../../utils/format");
|
|
5
|
+
const { isReadableStream } = require("../../utils/constants");
|
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
|
7
|
+
function upload(attachments, callback) {
|
|
8
|
+
callback = callback || function() {};
|
|
9
|
+
const uploads = [];
|
|
10
|
+
|
|
11
|
+
// create an array of promises
|
|
12
|
+
for (let i = 0; i < attachments.length; i++) {
|
|
13
|
+
if (!isReadableStream(attachments[i])) {
|
|
14
|
+
throw {
|
|
15
|
+
error:
|
|
16
|
+
"Attachment should be a readable stream and not " +
|
|
17
|
+
getType(attachments[i]) +
|
|
18
|
+
"."
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const form = {
|
|
23
|
+
upload_1024: attachments[i],
|
|
24
|
+
voice_clip: "true"
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
uploads.push(
|
|
28
|
+
defaultFuncs
|
|
29
|
+
.postFormData(
|
|
30
|
+
"https://upload.facebook.com/ajax/mercury/upload.php",
|
|
31
|
+
ctx.jar,
|
|
32
|
+
form,
|
|
33
|
+
{}
|
|
34
|
+
)
|
|
35
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
|
36
|
+
.then(function(resData) {
|
|
37
|
+
if (resData.error) {
|
|
38
|
+
throw resData;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// We have to return the data unformatted unless we want to change it
|
|
42
|
+
// back in sendMessage.
|
|
43
|
+
return resData.payload.metadata[0];
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// resolve all promises
|
|
49
|
+
Promise.all(uploads)
|
|
50
|
+
.then(function(resData) {
|
|
51
|
+
callback(null, resData);
|
|
52
|
+
})
|
|
53
|
+
.catch(function(err) {
|
|
54
|
+
log.error("uploadAttachment", err);
|
|
55
|
+
return callback(err);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return function uploadAttachment(attachments, callback) {
|
|
60
|
+
if (
|
|
61
|
+
!attachments &&
|
|
62
|
+
!isReadableStream(attachments) &&
|
|
63
|
+
!getType(attachments) === "Array" &&
|
|
64
|
+
getType(attachments) === "Array" && !attachments.length
|
|
65
|
+
)
|
|
66
|
+
throw { error: "Please pass an attachment or an array of attachments." };
|
|
67
|
+
|
|
68
|
+
let resolveFunc = function() {};
|
|
69
|
+
let rejectFunc = function() {};
|
|
70
|
+
const returnPromise = new Promise(function(resolve, reject) {
|
|
71
|
+
resolveFunc = resolve;
|
|
72
|
+
rejectFunc = reject;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
if (!callback) {
|
|
76
|
+
callback = function(err, info) {
|
|
77
|
+
if (err) {
|
|
78
|
+
return rejectFunc(err);
|
|
79
|
+
}
|
|
80
|
+
resolveFunc(info);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (getType(attachments) !== "Array") attachments = [attachments];
|
|
85
|
+
|
|
86
|
+
upload(attachments, (err, info) => {
|
|
87
|
+
if (err) {
|
|
88
|
+
return callback(err);
|
|
89
|
+
}
|
|
90
|
+
callback(null, info);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
return returnPromise;
|
|
94
|
+
};
|
|
95
|
+
};
|