shadowx-fca 8.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/README.md +1066 -0
- package/build/messagix.dll +0 -0
- package/build/messagix.so +0 -0
- package/checkUpdate.js +393 -0
- package/config.json +17 -0
- package/e2ee.js +563 -0
- package/e2eetest.js +356 -0
- package/index.js +611 -0
- package/lib/index.mjs +1412 -0
- package/logger.js +500 -0
- package/package.json +65 -0
- package/src/GetBotInfo.js +66 -0
- package/src/OldMessage.js +182 -0
- package/src/Screenshot.js +83 -0
- package/src/addExternalModule.js +13 -0
- package/src/addUserToGroup.js +33 -0
- package/src/approveGroupJoinRequests.js +18 -0
- package/src/changeAdminStatus.js +16 -0
- package/src/changeArchivedStatus.js +17 -0
- package/src/changeAvatar.js +136 -0
- package/src/changeAvatarV2.js +86 -0
- package/src/changeAvt.js +85 -0
- package/src/changeBio.js +76 -0
- package/src/changeBlockedStatus.js +20 -0
- package/src/changeBlockedStatusMqtt.js +80 -0
- package/src/changeCover.js +72 -0
- package/src/changeGroupImage.js +16 -0
- package/src/changeName.js +79 -0
- package/src/changeNickname.js +16 -0
- package/src/changeThreadColor.js +15 -0
- package/src/changeThreadEmoji.js +15 -0
- package/src/changeThreadMemberNickname.js +6 -0
- package/src/changeUsername.js +59 -0
- package/src/createCommentPost.js +230 -0
- package/src/createNewGroup.js +38 -0
- package/src/createNote.js +35 -0
- package/src/createPoll.js +27 -0
- package/src/createPost.js +276 -0
- package/src/createThemeAI.js +129 -0
- package/src/data/cache/system/data.json +4 -0
- package/src/data/cache/system/datahandle.js +21 -0
- package/src/data/getThreadInfo.json +1 -0
- package/src/deleteComment.js +23 -0
- package/src/deleteMessage.js +15 -0
- package/src/deleteThread.js +15 -0
- package/src/denyGroupJoinRequests.js +18 -0
- package/src/e2ee/crypto.js +173 -0
- package/src/e2ee/index.js +144 -0
- package/src/e2ee/proto/ArmadilloApplication.proto +281 -0
- package/src/e2ee/proto/ArmadilloICDC.proto +14 -0
- package/src/e2ee/proto/ConsumerApplication.proto +232 -0
- package/src/e2ee/proto/MessageApplication.proto +82 -0
- package/src/e2ee/proto/MessageTransport.proto +77 -0
- package/src/e2ee/proto/WACommon.proto +66 -0
- package/src/e2ee/proto/WAMediaTransport.proto +176 -0
- package/src/e2ee/proto/proto-writer.ts +76 -0
- package/src/e2ee/protocol.js +196 -0
- package/src/e2ee/ratchet.js +219 -0
- package/src/e2ee/store.js +182 -0
- package/src/e2ee.js +8 -0
- package/src/editMessage.js +56 -0
- package/src/editMessageOld.js +67 -0
- package/src/enableReactions.js +24 -0
- package/src/follow.js +74 -0
- package/src/followUser.js +23 -0
- package/src/forwardAttachment.js +16 -0
- package/src/friendList.js +98 -0
- package/src/getAccess.js +112 -0
- package/src/getAppState.js +13 -0
- package/src/getAvatarUser.js +11 -0
- package/src/getBio.js +24 -0
- package/src/getBotInitialData.js +42 -0
- package/src/getCtx.js +5 -0
- package/src/getCurrentUserID.js +6 -0
- package/src/getEmojiUrl.js +29 -0
- package/src/getFriendsList.js +36 -0
- package/src/getMessage.js +37 -0
- package/src/getNotes.js +17 -0
- package/src/getOptions.js +5 -0
- package/src/getPinnedMessages.js +33 -0
- package/src/getPostInfo.js +17 -0
- package/src/getProfileInfo.js +17 -0
- package/src/getPublicData.js +25 -0
- package/src/getRegion.js +7 -0
- package/src/getRepInfo.js +17 -0
- package/src/getStickerPacks.js +25 -0
- package/src/getStickers.js +39 -0
- package/src/getStoryReactions.js +18 -0
- package/src/getThreadHistory.js +45 -0
- package/src/getThreadHistoryDeprecated.js +71 -0
- package/src/getThreadInfo.js +73 -0
- package/src/getThreadInfoDeprecated.js +56 -0
- package/src/getThreadList.js +76 -0
- package/src/getThreadListDeprecated.js +46 -0
- package/src/getThreadPictures.js +59 -0
- package/src/getThreadTheme.js +77 -0
- package/src/getUID.js +17 -0
- package/src/getUserID.js +17 -0
- package/src/getUserInfo.js +28 -0
- package/src/handleFriendRequest.js +21 -0
- package/src/handleMessageRequest.js +15 -0
- package/src/httpGet.js +13 -0
- package/src/httpPost.js +12 -0
- package/src/httpPostFormData.js +12 -0
- package/src/listenE2EE.js +75 -0
- package/src/listenMqtt.js +802 -0
- package/src/listenNotification.js +85 -0
- package/src/logout.js +22 -0
- package/src/markAsDelivered.js +17 -0
- package/src/markAsRead.js +14 -0
- package/src/markAsReadAll.js +15 -0
- package/src/markAsSeen.js +15 -0
- package/src/metaTheme.js +185 -0
- package/src/muteThread.js +52 -0
- package/src/note.js +228 -0
- package/src/pin.js +53 -0
- package/src/pinMessage.js +6 -0
- package/src/postComment.js +29 -0
- package/src/postFormData.js +46 -0
- package/src/reactToComment.js +31 -0
- package/src/reactToPost.js +32 -0
- package/src/refreshFb_dtsg.js +31 -0
- package/src/removeSuspiciousAccount.js +74 -0
- package/src/removeUserFromGroup.js +15 -0
- package/src/reply.js +442 -0
- package/src/resolvePhotoUrl.js +15 -0
- package/src/searchForThread.js +20 -0
- package/src/searchFriends.js +28 -0
- package/src/searchStickers.js +53 -0
- package/src/send.js +46 -0
- package/src/sendAudio.js +8 -0
- package/src/sendBroadcast.js +93 -0
- package/src/sendButtons.js +161 -0
- package/src/sendComment.js +159 -0
- package/src/sendEmoji.js +10 -0
- package/src/sendFile.js +9 -0
- package/src/sendFriendRequest.js +33 -0
- package/src/sendGif.js +24 -0
- package/src/sendImage.js +9 -0
- package/src/sendLocation.js +9 -0
- package/src/sendMessage.js +487 -0
- package/src/sendMessage1.js +309 -0
- package/src/sendMessageMqtt.js +68 -0
- package/src/sendSticker.js +8 -0
- package/src/sendTypingIndicator.js +36 -0
- package/src/sendTypingIndicatorV2.js +28 -0
- package/src/sendVideo.js +9 -0
- package/src/sessionGuard.js +130 -0
- package/src/setActiveStatus.js +16 -0
- package/src/setMessageReaction.js +61 -0
- package/src/setMessageReactionMqtt.js +62 -0
- package/src/setOptions.js +22 -0
- package/src/setPollVote.js +17 -0
- package/src/setPostReaction.js +112 -0
- package/src/setProfileGuard.js +44 -0
- package/src/setProfileLock.js +93 -0
- package/src/setStoryReaction.js +129 -0
- package/src/setStorySeen.js +99 -0
- package/src/setThreadTheme.js +17 -0
- package/src/setTitle.js +15 -0
- package/src/shareContact.js +33 -0
- package/src/shareLink.js +8 -0
- package/src/sharePost.js +31 -0
- package/src/stopListenMqtt.js +23 -0
- package/src/storyManager.js +353 -0
- package/src/suggestFriend.js +128 -0
- package/src/threadColors.js +131 -0
- package/src/unfollowUser.js +23 -0
- package/src/unfriend.js +15 -0
- package/src/unpinMessage.js +6 -0
- package/src/unsendMessage.js +14 -0
- package/src/uploadAttachment.js +58 -0
- package/src/uploadImageToImgbb.js +29 -0
- package/utils.js +2945 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var logger = require("../logger");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* sendBroadcast — Send a message to multiple threads in parallel
|
|
7
|
+
* with rate limiting and per-thread delivery tracking.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* api.sendBroadcast(msg, threadIDs, [options], [callback])
|
|
11
|
+
*
|
|
12
|
+
* Options:
|
|
13
|
+
* delay {number} ms between each send (default: 1000)
|
|
14
|
+
* parallel {number} max concurrent sends (default: 3)
|
|
15
|
+
* onEach {function(err, result, threadID)} called after each individual send
|
|
16
|
+
*
|
|
17
|
+
* Returns:
|
|
18
|
+
* Promise<{ sent: string[], failed: { id, error }[], total: number }>
|
|
19
|
+
*/
|
|
20
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
21
|
+
return function sendBroadcast(msg, threadIDs, options, callback) {
|
|
22
|
+
if (typeof options === "function") {
|
|
23
|
+
callback = options;
|
|
24
|
+
options = {};
|
|
25
|
+
}
|
|
26
|
+
options = options || {};
|
|
27
|
+
|
|
28
|
+
var delay = typeof options.delay === "number" ? options.delay : 1000;
|
|
29
|
+
var parallel = typeof options.parallel === "number" ? options.parallel : 3;
|
|
30
|
+
var onEach = typeof options.onEach === "function" ? options.onEach : null;
|
|
31
|
+
|
|
32
|
+
if (!Array.isArray(threadIDs) || threadIDs.length === 0) {
|
|
33
|
+
var err = new Error("sendBroadcast: threadIDs must be a non-empty array.");
|
|
34
|
+
if (typeof callback === "function") return callback(err);
|
|
35
|
+
return Promise.reject(err);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var sent = [];
|
|
39
|
+
var failed = [];
|
|
40
|
+
var ids = threadIDs.slice();
|
|
41
|
+
|
|
42
|
+
logger.info("Broadcast", "Sending to " + ids.length + " threads [parallel=" + parallel + " delay=" + delay + "ms]");
|
|
43
|
+
|
|
44
|
+
function sleep(ms) {
|
|
45
|
+
return new Promise(function (res) { setTimeout(res, ms); });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function sendOne(id) {
|
|
49
|
+
try {
|
|
50
|
+
var info = await api.sendMessage(msg, String(id));
|
|
51
|
+
sent.push(String(id));
|
|
52
|
+
if (onEach) onEach(null, info, id);
|
|
53
|
+
logger.success("Broadcast", "→ " + id + " [" + sent.length + "/" + ids.length + "]");
|
|
54
|
+
} catch (e) {
|
|
55
|
+
failed.push({ id: String(id), error: e.message || String(e) });
|
|
56
|
+
if (onEach) onEach(e, null, id);
|
|
57
|
+
logger.warn("Broadcast", "✘ " + id + ": " + (e.message || e));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
var promise = (async function () {
|
|
62
|
+
var i = 0;
|
|
63
|
+
while (i < ids.length) {
|
|
64
|
+
var batch = ids.slice(i, i + parallel);
|
|
65
|
+
var tasks = batch.map(function (id, idx) {
|
|
66
|
+
return sleep(idx * delay).then(function () { return sendOne(id); });
|
|
67
|
+
});
|
|
68
|
+
await Promise.all(tasks);
|
|
69
|
+
i += parallel;
|
|
70
|
+
if (i < ids.length) await sleep(delay);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var result = {
|
|
74
|
+
sent: sent,
|
|
75
|
+
failed: failed,
|
|
76
|
+
total: ids.length
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
logger.success(
|
|
80
|
+
"Broadcast",
|
|
81
|
+
"Done — " + sent.length + " sent, " + failed.length + " failed out of " + ids.length
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return result;
|
|
85
|
+
})();
|
|
86
|
+
|
|
87
|
+
if (typeof callback === "function") {
|
|
88
|
+
promise.then(function (r) { callback(null, r); }).catch(function (e) { callback(e); });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return promise;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { generateOfflineThreadingID } = require('../utils');
|
|
4
|
+
|
|
5
|
+
function safeParseInt(value, fallback = 0) {
|
|
6
|
+
const parsed = parseInt(value);
|
|
7
|
+
return isNaN(parsed) ? fallback : parsed;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const SHUFFLE_SEED = 42;
|
|
11
|
+
|
|
12
|
+
function generateShufflePattern(length) {
|
|
13
|
+
const pattern = Array.from({ length }, (_, i) => i);
|
|
14
|
+
let seed = SHUFFLE_SEED;
|
|
15
|
+
for (let i = length - 1; i > 0; i--) {
|
|
16
|
+
seed = (seed * 9301 + 49297) % 233280;
|
|
17
|
+
const j = Math.floor((seed / 233280) * (i + 1));
|
|
18
|
+
[pattern[i], pattern[j]] = [pattern[j], pattern[i]];
|
|
19
|
+
}
|
|
20
|
+
return pattern;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function generateReversePattern(shufflePattern) {
|
|
24
|
+
const reversePattern = new Array(shufflePattern.length);
|
|
25
|
+
for (let i = 0; i < shufflePattern.length; i++) {
|
|
26
|
+
reversePattern[shufflePattern[i]] = i;
|
|
27
|
+
}
|
|
28
|
+
return reversePattern;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function unrearrange(rearrangedId) {
|
|
32
|
+
try {
|
|
33
|
+
if (!rearrangedId || typeof rearrangedId !== "string") {
|
|
34
|
+
console.error("Unrearrange: Invalid input");
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const pattern = generateShufflePattern(rearrangedId.length);
|
|
38
|
+
const reversePattern = generateReversePattern(pattern);
|
|
39
|
+
const original = new Array(rearrangedId.length);
|
|
40
|
+
for (let i = 0; i < rearrangedId.length; i++) {
|
|
41
|
+
original[reversePattern[i]] = rearrangedId[i];
|
|
42
|
+
}
|
|
43
|
+
return original.join("");
|
|
44
|
+
} catch (err) {
|
|
45
|
+
console.error("Unrearrange error:", err.message);
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
51
|
+
return function sendButtons(
|
|
52
|
+
call_to_actions,
|
|
53
|
+
text,
|
|
54
|
+
threadID,
|
|
55
|
+
messageID,
|
|
56
|
+
callback,
|
|
57
|
+
) {
|
|
58
|
+
let resolveFunc = () => {};
|
|
59
|
+
let rejectFunc = () => {};
|
|
60
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
|
61
|
+
resolveFunc = resolve;
|
|
62
|
+
rejectFunc = reject;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (!callback) {
|
|
66
|
+
callback = function (err, data) {
|
|
67
|
+
if (err) return rejectFunc(err);
|
|
68
|
+
resolveFunc(data);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!ctx.mqttClient) {
|
|
73
|
+
const err = new Error("Not connected to MQTT");
|
|
74
|
+
callback(err);
|
|
75
|
+
return returnPromise;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!ctx.reqCallbacks) ctx.reqCallbacks = {};
|
|
79
|
+
if (!ctx.callback_Task) ctx.callback_Task = {};
|
|
80
|
+
|
|
81
|
+
ctx.wsReqNumber += 1;
|
|
82
|
+
ctx.wsTaskNumber += 1;
|
|
83
|
+
|
|
84
|
+
const reqID = ctx.wsReqNumber;
|
|
85
|
+
const cta_id = unrearrange(call_to_actions);
|
|
86
|
+
|
|
87
|
+
if (!cta_id) {
|
|
88
|
+
const err = new Error("Failed to unrearrange messageID");
|
|
89
|
+
callback(err);
|
|
90
|
+
return returnPromise;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const taskPayload = {
|
|
94
|
+
thread_id: threadID,
|
|
95
|
+
otid: safeParseInt(generateOfflineThreadingID()),
|
|
96
|
+
source: 65544,
|
|
97
|
+
send_type: 5,
|
|
98
|
+
sync_group: 1,
|
|
99
|
+
forwarded_msg_id: cta_id,
|
|
100
|
+
strip_forwarded_msg_caption: 1,
|
|
101
|
+
skip_url_preview_gen: 0,
|
|
102
|
+
text: text || "",
|
|
103
|
+
initiating_source: 1,
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
if (messageID != undefined && messageID != null) {
|
|
107
|
+
taskPayload.reply_metadata = {
|
|
108
|
+
reply_source_id: messageID,
|
|
109
|
+
reply_source_type: 1,
|
|
110
|
+
reply_type: 0,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const task = {
|
|
115
|
+
failure_count: null,
|
|
116
|
+
label: "46",
|
|
117
|
+
payload: JSON.stringify(taskPayload),
|
|
118
|
+
queue_name: `${threadID}`,
|
|
119
|
+
task_id: ctx.wsTaskNumber,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const content = {
|
|
123
|
+
app_id: "2220391788200892",
|
|
124
|
+
payload: JSON.stringify({
|
|
125
|
+
data_trace_id: null,
|
|
126
|
+
epoch_id: safeParseInt(generateOfflineThreadingID()),
|
|
127
|
+
tasks: [task],
|
|
128
|
+
version_id: "24180904141611263",
|
|
129
|
+
}),
|
|
130
|
+
request_id: reqID,
|
|
131
|
+
type: 3,
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// Setup the callback listener
|
|
135
|
+
ctx.callback_Task[reqID] = {
|
|
136
|
+
type: "call_to_actions",
|
|
137
|
+
callback: function (err, data) {
|
|
138
|
+
if (err) return callback(err);
|
|
139
|
+
|
|
140
|
+
const messageID =
|
|
141
|
+
JSON.parse(data)?.step?.[1]?.[2]?.[2]?.[1]?.[3] || null;
|
|
142
|
+
|
|
143
|
+
const result = {
|
|
144
|
+
messageID: cta_id,
|
|
145
|
+
senderID: ctx.userID,
|
|
146
|
+
threadID: threadID,
|
|
147
|
+
action: "cta_buttons",
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
callback(null, result);
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
ctx.mqttClient.publish("/ls_req", JSON.stringify(content), {
|
|
155
|
+
qos: 1,
|
|
156
|
+
retain: false,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
return returnPromise;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//added by jonell Magallanes hshs
|
|
3
|
+
var utils = require("../utils");
|
|
4
|
+
var log = require("npmlog");
|
|
5
|
+
var bluebird = require("bluebird");
|
|
6
|
+
|
|
7
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
8
|
+
function getGUID() {
|
|
9
|
+
let _0x161e32 = Date.now(),
|
|
10
|
+
_0x4ec135 = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
|
|
11
|
+
/[xy]/g,
|
|
12
|
+
function (_0x32f946) {
|
|
13
|
+
let _0x141041 = Math.floor((_0x161e32 + Math.random() * 16) % 16);
|
|
14
|
+
_0x161e32 = Math.floor(_0x161e32 / 16);
|
|
15
|
+
let _0x31fcdd = (
|
|
16
|
+
_0x32f946 == "x" ? _0x141041 : (_0x141041 & 0x3) | 0x8
|
|
17
|
+
).toString(16);
|
|
18
|
+
return _0x31fcdd;
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
return _0x4ec135;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function uploadAttachment(attachment, callback) {
|
|
25
|
+
var uploads = [];
|
|
26
|
+
|
|
27
|
+
// create an array of promises
|
|
28
|
+
if (!utils.isReadableStream(attachment)) {
|
|
29
|
+
throw {
|
|
30
|
+
error:
|
|
31
|
+
"Attachment should be a readable stream and not " +
|
|
32
|
+
utils.getType(attachment) +
|
|
33
|
+
".",
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var form = {
|
|
38
|
+
file: attachment,
|
|
39
|
+
av: api.getCurrentUserID(),
|
|
40
|
+
profile_id: api.getCurrentUserID(),
|
|
41
|
+
source: "19",
|
|
42
|
+
target_id: api.getCurrentUserID(),
|
|
43
|
+
__user: api.getCurrentUserID(),
|
|
44
|
+
__a: "1",
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
uploads.push(
|
|
48
|
+
defaultFuncs
|
|
49
|
+
.postFormData(
|
|
50
|
+
"https://www.facebook.com/ajax/ufi/upload",
|
|
51
|
+
ctx.jar,
|
|
52
|
+
form,
|
|
53
|
+
{},
|
|
54
|
+
)
|
|
55
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
56
|
+
.then(function (resData) {
|
|
57
|
+
if (resData.error) {
|
|
58
|
+
throw resData;
|
|
59
|
+
}
|
|
60
|
+
return resData.payload;
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
// resolve all promises
|
|
65
|
+
bluebird
|
|
66
|
+
.all(uploads)
|
|
67
|
+
.then(function (resData) {
|
|
68
|
+
callback(null, resData);
|
|
69
|
+
})
|
|
70
|
+
.catch(function (err) {
|
|
71
|
+
log.error("uploadAttachment", err);
|
|
72
|
+
return callback(err);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function sendCommentToFb(postId, text, fileID) {
|
|
77
|
+
const feedback_id = Buffer.from("feedback:" + postId).toString("base64");
|
|
78
|
+
|
|
79
|
+
const ss1 = getGUID();
|
|
80
|
+
const ss2 = getGUID();
|
|
81
|
+
|
|
82
|
+
const form = {
|
|
83
|
+
av: api.getCurrentUserID(),
|
|
84
|
+
fb_api_req_friendly_name: "CometUFICreateCommentMutation",
|
|
85
|
+
fb_api_caller_class: "RelayModern",
|
|
86
|
+
doc_id: "4744517358977326",
|
|
87
|
+
variables: JSON.stringify({
|
|
88
|
+
displayCommentsFeedbackContext: null,
|
|
89
|
+
displayCommentsContextEnableComment: null,
|
|
90
|
+
displayCommentsContextIsAdPreview: null,
|
|
91
|
+
displayCommentsContextIsAggregatedShare: null,
|
|
92
|
+
displayCommentsContextIsStorySet: null,
|
|
93
|
+
feedLocation: "TIMELINE",
|
|
94
|
+
feedbackSource: 0,
|
|
95
|
+
focusCommentID: null,
|
|
96
|
+
includeNestedComments: false,
|
|
97
|
+
input: {
|
|
98
|
+
attachments: fileID ? [{ media: { id: fileID } }] : null,
|
|
99
|
+
feedback_id: feedback_id,
|
|
100
|
+
formatting_style: null,
|
|
101
|
+
message: {
|
|
102
|
+
ranges: [],
|
|
103
|
+
text: text,
|
|
104
|
+
},
|
|
105
|
+
is_tracking_encrypted: true,
|
|
106
|
+
tracking: [],
|
|
107
|
+
feedback_source: "PROFILE",
|
|
108
|
+
idempotence_token: "client:" + ss1,
|
|
109
|
+
session_id: ss2,
|
|
110
|
+
actor_id: api.getCurrentUserID(),
|
|
111
|
+
client_mutation_id: Math.round(Math.random() * 19),
|
|
112
|
+
},
|
|
113
|
+
scale: 3,
|
|
114
|
+
useDefaultActor: false,
|
|
115
|
+
UFI2CommentsProvider_commentsKey: "ProfileCometTimelineRoute",
|
|
116
|
+
}),
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const res = JSON.parse(
|
|
120
|
+
await api.httpPost("https://www.facebook.com/api/graphql/", form),
|
|
121
|
+
);
|
|
122
|
+
return res;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return async function sendComment(content, postId, callback) {
|
|
126
|
+
if (typeof content === "object") {
|
|
127
|
+
var text = content.body || "";
|
|
128
|
+
if (content.attachment) {
|
|
129
|
+
if (!utils.isReadableStream(content.attachment)) {
|
|
130
|
+
throw new Error("Attachment must be a ReadableStream");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
uploadAttachment(content.attachment, async function (err, files) {
|
|
134
|
+
if (err) {
|
|
135
|
+
return callback(err);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
await sendCommentToFb(postId, text, files[0].fbid)
|
|
139
|
+
.then((res) => {
|
|
140
|
+
return callback(null, res);
|
|
141
|
+
})
|
|
142
|
+
.catch((err) => {
|
|
143
|
+
return callback(err);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
} else if (typeof content === "string") {
|
|
148
|
+
var text = content;
|
|
149
|
+
await sendCommentToFb(postId, text, null)
|
|
150
|
+
.then((res) => {
|
|
151
|
+
return callback(null, res);
|
|
152
|
+
})
|
|
153
|
+
.catch((_) => {
|
|
154
|
+
return;
|
|
155
|
+
});
|
|
156
|
+
} else throw new Error("Invalid content");
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
// example usage
|
package/src/sendEmoji.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
3
|
+
return function sendEmoji(emoji, emojiSize, threadID, callback) {
|
|
4
|
+
if (typeof emojiSize === "string" && !["small","medium","large"].includes(emojiSize)) {
|
|
5
|
+
callback = threadID; threadID = emojiSize; emojiSize = "medium";
|
|
6
|
+
}
|
|
7
|
+
if (typeof emojiSize === "function") { callback = emojiSize; emojiSize = "medium"; threadID = emoji; }
|
|
8
|
+
return api.sendMessage({ emoji, emojiSize: emojiSize || "medium" }, threadID, callback);
|
|
9
|
+
};
|
|
10
|
+
};
|
package/src/sendFile.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var fs = require("fs");
|
|
3
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
4
|
+
return function sendFile(filePath, threadID, caption, callback) {
|
|
5
|
+
if (typeof caption === "function") { callback = caption; caption = ""; }
|
|
6
|
+
var stream = typeof filePath === "string" ? fs.createReadStream(filePath) : filePath;
|
|
7
|
+
return api.sendMessage({ attachment: stream, body: caption || "" }, threadID, callback);
|
|
8
|
+
};
|
|
9
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var utils = require("../utils");
|
|
3
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
4
|
+
return function sendFriendRequest(userID, callback) {
|
|
5
|
+
var { promise, callback: cb } = utils.wrapCallback(callback);
|
|
6
|
+
defaultFuncs.post("https://www.facebook.com/api/graphql/", ctx.jar, {
|
|
7
|
+
fb_api_caller_class: "RelayModern",
|
|
8
|
+
fb_api_req_friendly_name: "FriendingCometFriendRequestSendMutation",
|
|
9
|
+
variables: JSON.stringify({
|
|
10
|
+
input: {
|
|
11
|
+
click_correlation_id: String(Date.now()),
|
|
12
|
+
click_proof_validation_result: '{"validated":true}',
|
|
13
|
+
friend_requestee_ids: [String(userID)],
|
|
14
|
+
friending_channel: "FRIENDS_HOME_MAIN",
|
|
15
|
+
warn_ack_for_ids: [],
|
|
16
|
+
actor_id: ctx.userID,
|
|
17
|
+
client_mutation_id: String(Math.floor(Math.random() * 10))
|
|
18
|
+
},
|
|
19
|
+
scale: 1
|
|
20
|
+
}),
|
|
21
|
+
server_timestamps: true,
|
|
22
|
+
doc_id: "24614631718227645"
|
|
23
|
+
})
|
|
24
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
25
|
+
.then(resData => {
|
|
26
|
+
if (resData.error) throw resData;
|
|
27
|
+
var result = resData.data && resData.data.friend_request_send;
|
|
28
|
+
cb(null, result || true);
|
|
29
|
+
})
|
|
30
|
+
.catch(err => cb(err));
|
|
31
|
+
return promise;
|
|
32
|
+
};
|
|
33
|
+
};
|
package/src/sendGif.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var utils = require("../utils");
|
|
3
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
4
|
+
return function sendGif(gifSrc, threadID, callback) {
|
|
5
|
+
var { promise, callback: cb } = utils.wrapCallback(callback);
|
|
6
|
+
defaultFuncs.post("https://www.facebook.com/api/graphql/", ctx.jar, {
|
|
7
|
+
fb_api_req_friendly_name: "MessengerGifAttachmentMutation",
|
|
8
|
+
fb_api_caller_class: "RelayModern",
|
|
9
|
+
doc_id: "3748987661800341",
|
|
10
|
+
variables: JSON.stringify({
|
|
11
|
+
input: {
|
|
12
|
+
thread_id: String(threadID),
|
|
13
|
+
src: gifSrc,
|
|
14
|
+
actor_id: ctx.userID,
|
|
15
|
+
client_mutation_id: String(ctx.clientMutationId++)
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
20
|
+
.then(resData => { if (resData.error) throw resData; cb(null, resData); })
|
|
21
|
+
.catch(err => cb(err));
|
|
22
|
+
return promise;
|
|
23
|
+
};
|
|
24
|
+
};
|
package/src/sendImage.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var fs = require("fs");
|
|
3
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
4
|
+
return function sendImage(imagePath, threadID, caption, callback) {
|
|
5
|
+
if (typeof caption === "function") { callback = caption; caption = ""; }
|
|
6
|
+
var stream = typeof imagePath === "string" ? fs.createReadStream(imagePath) : imagePath;
|
|
7
|
+
return api.sendMessage({ attachment: stream, body: caption || "" }, threadID, callback);
|
|
8
|
+
};
|
|
9
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
3
|
+
return function sendLocation(latitude, longitude, threadID, isCurrentLocation, callback) {
|
|
4
|
+
if (typeof isCurrentLocation === "function") { callback = isCurrentLocation; isCurrentLocation = true; }
|
|
5
|
+
return api.sendMessage({
|
|
6
|
+
location: { latitude, longitude, current: isCurrentLocation !== false }
|
|
7
|
+
}, threadID, callback);
|
|
8
|
+
};
|
|
9
|
+
};
|