toru-fca 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/CHANGELOG.md +64 -0
- package/README.md +319 -0
- package/advancedSystem.js +95 -0
- package/build/messagix.dll +0 -0
- package/build/messagix.so +0 -0
- package/checkUpdate.js +37 -0
- package/config.json +45 -0
- package/e2ee.js +719 -0
- package/index.js +715 -0
- package/lib/index.mjs +1412 -0
- package/package.json +69 -0
- package/src/OldMessage.js +357 -0
- package/src/addExternalModule.js +25 -0
- package/src/addUserToGroup.js +117 -0
- package/src/changeAdminStatus.js +105 -0
- package/src/changeArchivedStatus.js +57 -0
- package/src/changeAvatar.js +138 -0
- package/src/changeAvatarV2.js +86 -0
- package/src/changeAvt.js +85 -0
- package/src/changeBio.js +78 -0
- package/src/changeBlockedStatus.js +51 -0
- package/src/changeBlockedStatusMqtt.js +80 -0
- package/src/changeCover.js +72 -0
- package/src/changeGroupImage.js +137 -0
- package/src/changeName.js +79 -0
- package/src/changeNickname.js +61 -0
- package/src/changeThreadColor.js +67 -0
- package/src/changeThreadEmoji.js +57 -0
- package/src/changeUsername.js +59 -0
- package/src/createCommentPost.js +230 -0
- package/src/createNewGroup.js +90 -0
- package/src/createPoll.js +73 -0
- package/src/createPost.js +276 -0
- package/src/data/getThreadInfo.json +1 -0
- package/src/deleteMessage.js +58 -0
- package/src/deleteThread.js +58 -0
- package/src/editMessage.js +81 -0
- package/src/editMessageOld.js +67 -0
- package/src/follow.js +74 -0
- package/src/forwardAttachment.js +62 -0
- package/src/friendList.js +104 -0
- package/src/getAccess.js +112 -0
- package/src/getAvatarUser.js +78 -0
- package/src/getBotInitialData.js +42 -0
- package/src/getCtx.js +5 -0
- package/src/getCurrentUserID.js +7 -0
- package/src/getEmojiUrl.js +29 -0
- package/src/getFriendsList.js +85 -0
- package/src/getMessage.js +849 -0
- package/src/getOptions.js +5 -0
- package/src/getRegion.js +7 -0
- package/src/getThreadHistory.js +682 -0
- package/src/getThreadHistoryDeprecated.js +71 -0
- package/src/getThreadInfo.js +232 -0
- package/src/getThreadInfoDeprecated.js +56 -0
- package/src/getThreadList.js +213 -0
- package/src/getThreadListDeprecated.js +46 -0
- package/src/getThreadPictures.js +59 -0
- package/src/getThreadTheme.js +81 -0
- package/src/getUID.js +119 -0
- package/src/getUserID.js +61 -0
- package/src/getUserInfo.js +66 -0
- package/src/handleFriendRequest.js +46 -0
- package/src/handleMessageRequest.js +47 -0
- package/src/httpGet.js +49 -0
- package/src/httpPost.js +48 -0
- package/src/httpPostFormData.js +70 -0
- package/src/listenMqtt.js +955 -0
- package/src/listenNotification.js +85 -0
- package/src/logout.js +19 -0
- package/src/markAsDelivered.js +47 -0
- package/src/markAsRead.js +72 -0
- package/src/markAsReadAll.js +40 -0
- package/src/markAsSeen.js +48 -0
- package/src/metaTheme.js +189 -0
- package/src/muteThread.js +45 -0
- package/src/note.js +228 -0
- package/src/pinMessage.js +59 -0
- package/src/refreshFb_dtsg.js +91 -0
- package/src/removeSuspiciousAccount.js +78 -0
- package/src/removeUserFromGroup.js +81 -0
- package/src/reply.js +442 -0
- package/src/resolvePhotoUrl.js +47 -0
- package/src/searchForThread.js +53 -0
- package/src/searchFriends.js +140 -0
- package/src/searchStickers.js +53 -0
- package/src/send.js +46 -0
- package/src/sendButtons.js +163 -0
- package/src/sendComment.js +159 -0
- package/src/sendFriendRequest.js +112 -0
- package/src/sendMessage.js +440 -0
- package/src/sendMessageMqtt.js +323 -0
- package/src/sendTypingIndicator.js +54 -0
- package/src/setActiveStatus.js +92 -0
- package/src/setMessageReaction.js +149 -0
- package/src/setMessageReactionMqtt.js +62 -0
- package/src/setPostReaction.js +114 -0
- package/src/setProfileGuard.js +44 -0
- package/src/setProfileLock.js +97 -0
- package/src/setStoryReaction.js +133 -0
- package/src/setStorySeen.js +108 -0
- package/src/setThreadTheme.js +102 -0
- package/src/setTitle.js +92 -0
- package/src/shareContact.js +110 -0
- package/src/shareLink.js +59 -0
- package/src/stopListenMqtt.js +37 -0
- package/src/storyManager.js +357 -0
- package/src/suggestFriend.js +132 -0
- package/src/threadColors.js +131 -0
- package/src/unfriend.js +54 -0
- package/src/unsendMessage.js +68 -0
- package/src/uploadAttachment.js +115 -0
- package/utils.js +3044 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var utils = require('../utils.js');
|
|
5
|
+
var log = require('npmlog');
|
|
6
|
+
|
|
7
|
+
module.exports = function (http, api, ctx) {
|
|
8
|
+
function formatData(res) {
|
|
9
|
+
return {
|
|
10
|
+
id: res.node.id,
|
|
11
|
+
image: res.node.image,
|
|
12
|
+
package: res.node.pack != null ? {
|
|
13
|
+
name: res.node.pack.name,
|
|
14
|
+
id: res.node.pack.id
|
|
15
|
+
} : {},
|
|
16
|
+
label: res.node.label
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return function searchStickers(query = '', callback) {
|
|
21
|
+
var cb;
|
|
22
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
|
23
|
+
cb = function (error, data) {
|
|
24
|
+
data ? resolve(data) : reject(error);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (typeof callback == 'function') cb = callback;
|
|
29
|
+
|
|
30
|
+
var form = {
|
|
31
|
+
fb_api_req_friendly_name: 'StickersFlyoutTagSelectorQuery',
|
|
32
|
+
variables: JSON.stringify({
|
|
33
|
+
stickerWidth: 64,
|
|
34
|
+
stickerHeight: 64,
|
|
35
|
+
stickerInterface: 'messages',
|
|
36
|
+
query
|
|
37
|
+
}),
|
|
38
|
+
doc_id: '4642836929159953'
|
|
39
|
+
}
|
|
40
|
+
http
|
|
41
|
+
.post('https://www.facebook.com/api/graphql/', ctx.jar, form)
|
|
42
|
+
.then(utils.parseAndCheckLogin(ctx, http))
|
|
43
|
+
.then(function (res) {
|
|
44
|
+
return cb(null, res.data.sticker_search.sticker_results.edges.map(formatData));
|
|
45
|
+
})
|
|
46
|
+
.catch(function (err) {
|
|
47
|
+
log.error('searchStickers', err);
|
|
48
|
+
return cb(err);
|
|
49
|
+
});
|
|
50
|
+
return returnPromise;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
package/src/send.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var utils = require("../utils");
|
|
4
|
+
var log = require("npmlog");
|
|
5
|
+
|
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
+
return async function send(text, senderID, threadID, mentionID, author, participantInfo, userID, leaverID, callback) {
|
|
8
|
+
var resolveFunc = function () { };
|
|
9
|
+
var rejectFunc = function () { };
|
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
|
11
|
+
resolveFunc = resolve;
|
|
12
|
+
rejectFunc = reject;
|
|
13
|
+
});
|
|
14
|
+
if (!callback) {
|
|
15
|
+
callback = function (err, data) {
|
|
16
|
+
if (err) return rejectFunc(err);
|
|
17
|
+
resolveFunc(data);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
let count_req = 0;
|
|
21
|
+
var form = JSON.stringify({
|
|
22
|
+
"app_id": "2220391788200892",
|
|
23
|
+
"payload": JSON.stringify({
|
|
24
|
+
tasks: [{
|
|
25
|
+
label: '359',
|
|
26
|
+
payload: JSON.stringify({
|
|
27
|
+
"contact_id": senderID,
|
|
28
|
+
"sync_group": 1,
|
|
29
|
+
"text": text || "",
|
|
30
|
+
"thread_id": threadID
|
|
31
|
+
}),
|
|
32
|
+
queue_name: 'messenger_contact_sharing',
|
|
33
|
+
task_id: Math.random() * 1001 << 0,
|
|
34
|
+
failure_count: null,
|
|
35
|
+
}],
|
|
36
|
+
epoch_id: utils.generateOfflineThreadingID(),
|
|
37
|
+
version_id: '7214102258676893',
|
|
38
|
+
}),
|
|
39
|
+
"request_id": ++count_req,
|
|
40
|
+
"type": 3
|
|
41
|
+
});
|
|
42
|
+
ctx.mqttClient.publish('/ls_req', form);
|
|
43
|
+
|
|
44
|
+
return returnPromise;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var log = require("npmlog");
|
|
4
|
+
|
|
5
|
+
const { generateOfflineThreadingID } = require('../utils');
|
|
6
|
+
|
|
7
|
+
function safeParseInt(value, fallback = 0) {
|
|
8
|
+
const parsed = parseInt(value);
|
|
9
|
+
return isNaN(parsed) ? fallback : parsed;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const SHUFFLE_SEED = 42;
|
|
13
|
+
|
|
14
|
+
function generateShufflePattern(length) {
|
|
15
|
+
const pattern = Array.from({ length }, (_, i) => i);
|
|
16
|
+
let seed = SHUFFLE_SEED;
|
|
17
|
+
for (let i = length - 1; i > 0; i--) {
|
|
18
|
+
seed = (seed * 9301 + 49297) % 233280;
|
|
19
|
+
const j = Math.floor((seed / 233280) * (i + 1));
|
|
20
|
+
[pattern[i], pattern[j]] = [pattern[j], pattern[i]];
|
|
21
|
+
}
|
|
22
|
+
return pattern;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function generateReversePattern(shufflePattern) {
|
|
26
|
+
const reversePattern = new Array(shufflePattern.length);
|
|
27
|
+
for (let i = 0; i < shufflePattern.length; i++) {
|
|
28
|
+
reversePattern[shufflePattern[i]] = i;
|
|
29
|
+
}
|
|
30
|
+
return reversePattern;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function unrearrange(rearrangedId) {
|
|
34
|
+
try {
|
|
35
|
+
if (!rearrangedId || typeof rearrangedId !== "string") {
|
|
36
|
+
log.error("Unrearrange: Invalid input");
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const pattern = generateShufflePattern(rearrangedId.length);
|
|
40
|
+
const reversePattern = generateReversePattern(pattern);
|
|
41
|
+
const original = new Array(rearrangedId.length);
|
|
42
|
+
for (let i = 0; i < rearrangedId.length; i++) {
|
|
43
|
+
original[reversePattern[i]] = rearrangedId[i];
|
|
44
|
+
}
|
|
45
|
+
return original.join("");
|
|
46
|
+
} catch (err) {
|
|
47
|
+
log.error("Unrearrange error:", err.message);
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
53
|
+
return function sendButtons(
|
|
54
|
+
call_to_actions,
|
|
55
|
+
text,
|
|
56
|
+
threadID,
|
|
57
|
+
messageID,
|
|
58
|
+
callback,
|
|
59
|
+
) {
|
|
60
|
+
let resolveFunc = () => {};
|
|
61
|
+
let rejectFunc = () => {};
|
|
62
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
|
63
|
+
resolveFunc = resolve;
|
|
64
|
+
rejectFunc = reject;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (!callback) {
|
|
68
|
+
callback = function (err, data) {
|
|
69
|
+
if (err) return rejectFunc(err);
|
|
70
|
+
resolveFunc(data);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!ctx.mqttClient) {
|
|
75
|
+
const err = new Error("Not connected to MQTT");
|
|
76
|
+
callback(err);
|
|
77
|
+
return returnPromise;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!ctx.reqCallbacks) ctx.reqCallbacks = {};
|
|
81
|
+
if (!ctx.callback_Task) ctx.callback_Task = {};
|
|
82
|
+
|
|
83
|
+
ctx.wsReqNumber += 1;
|
|
84
|
+
ctx.wsTaskNumber += 1;
|
|
85
|
+
|
|
86
|
+
const reqID = ctx.wsReqNumber;
|
|
87
|
+
const cta_id = unrearrange(call_to_actions);
|
|
88
|
+
|
|
89
|
+
if (!cta_id) {
|
|
90
|
+
const err = new Error("Failed to unrearrange messageID");
|
|
91
|
+
callback(err);
|
|
92
|
+
return returnPromise;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const taskPayload = {
|
|
96
|
+
thread_id: threadID,
|
|
97
|
+
otid: safeParseInt(generateOfflineThreadingID()),
|
|
98
|
+
source: 65544,
|
|
99
|
+
send_type: 5,
|
|
100
|
+
sync_group: 1,
|
|
101
|
+
forwarded_msg_id: cta_id,
|
|
102
|
+
strip_forwarded_msg_caption: 1,
|
|
103
|
+
skip_url_preview_gen: 0,
|
|
104
|
+
text: text || "",
|
|
105
|
+
initiating_source: 1,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
if (messageID != undefined && messageID != null) {
|
|
109
|
+
taskPayload.reply_metadata = {
|
|
110
|
+
reply_source_id: messageID,
|
|
111
|
+
reply_source_type: 1,
|
|
112
|
+
reply_type: 0,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const task = {
|
|
117
|
+
failure_count: null,
|
|
118
|
+
label: "46",
|
|
119
|
+
payload: JSON.stringify(taskPayload),
|
|
120
|
+
queue_name: `${threadID}`,
|
|
121
|
+
task_id: ctx.wsTaskNumber,
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const content = {
|
|
125
|
+
app_id: "2220391788200892",
|
|
126
|
+
payload: JSON.stringify({
|
|
127
|
+
data_trace_id: null,
|
|
128
|
+
epoch_id: safeParseInt(generateOfflineThreadingID()),
|
|
129
|
+
tasks: [task],
|
|
130
|
+
version_id: "24180904141611263",
|
|
131
|
+
}),
|
|
132
|
+
request_id: reqID,
|
|
133
|
+
type: 3,
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// Setup the callback listener
|
|
137
|
+
ctx.callback_Task[reqID] = {
|
|
138
|
+
type: "call_to_actions",
|
|
139
|
+
callback: function (err, data) {
|
|
140
|
+
if (err) return callback(err);
|
|
141
|
+
|
|
142
|
+
const messageID =
|
|
143
|
+
JSON.parse(data)?.step?.[1]?.[2]?.[2]?.[1]?.[3] || null;
|
|
144
|
+
|
|
145
|
+
const result = {
|
|
146
|
+
messageID: cta_id,
|
|
147
|
+
senderID: ctx.userID,
|
|
148
|
+
threadID: threadID,
|
|
149
|
+
action: "cta_buttons",
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
callback(null, result);
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
ctx.mqttClient.publish("/ls_req", JSON.stringify(content), {
|
|
157
|
+
qos: 1,
|
|
158
|
+
retain: false,
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return returnPromise;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
@@ -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
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ===========================================================
|
|
3
|
+
* 🧑💻 Author: HRIDOY (HRIDOY)
|
|
4
|
+
* 🔰 Owner & Developer
|
|
5
|
+
* 🌐 GitHub: https://github.com/hridoy-dev
|
|
6
|
+
* -----------------------------------------------------------
|
|
7
|
+
* 🕊️ Respect the creator & give proper credits if reused.
|
|
8
|
+
* ===========================================================
|
|
9
|
+
*/
|
|
10
|
+
"use strict";
|
|
11
|
+
|
|
12
|
+
var utils = require("../utils");
|
|
13
|
+
var log = require("npmlog");
|
|
14
|
+
|
|
15
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
16
|
+
/** Developed by HRIDOY | GitHub: hridoy-dev | Instagram: */
|
|
17
|
+
return function sendFriendRequest(userID, callback) {
|
|
18
|
+
var resolveFunc = function () { };
|
|
19
|
+
var rejectFunc = function () { };
|
|
20
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
|
21
|
+
resolveFunc = resolve;
|
|
22
|
+
rejectFunc = reject;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
if (!callback) {
|
|
26
|
+
callback = function (err, data) {
|
|
27
|
+
if (err) return rejectFunc(err);
|
|
28
|
+
resolveFunc(data);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!userID) {
|
|
33
|
+
return callback({ error: "User ID is required" });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var form = {
|
|
37
|
+
av: ctx.userID,
|
|
38
|
+
__aaid: 0,
|
|
39
|
+
__user: ctx.userID,
|
|
40
|
+
__a: 1,
|
|
41
|
+
__req: utils.getSignatureID(),
|
|
42
|
+
__hs: "20353.HYP:comet_pkg.2.1...0",
|
|
43
|
+
dpr: 1,
|
|
44
|
+
__ccg: "EXCELLENT",
|
|
45
|
+
__rev: "1027405870",
|
|
46
|
+
__s: utils.getSignatureID(),
|
|
47
|
+
__hsi: "7552782279085106329",
|
|
48
|
+
__comet_req: 15,
|
|
49
|
+
fb_dtsg: ctx.fb_dtsg,
|
|
50
|
+
jazoest: ctx.ttstamp,
|
|
51
|
+
lsd: ctx.fb_dtsg,
|
|
52
|
+
__spin_r: "1027405870",
|
|
53
|
+
__spin_b: "trunk",
|
|
54
|
+
__spin_t: Date.now(),
|
|
55
|
+
__crn: "comet.fbweb.CometFriendingRoute",
|
|
56
|
+
fb_api_caller_class: "RelayModern",
|
|
57
|
+
fb_api_req_friendly_name: "FriendingCometFriendRequestSendMutation",
|
|
58
|
+
variables: JSON.stringify({
|
|
59
|
+
input: {
|
|
60
|
+
click_correlation_id: Date.now().toString(),
|
|
61
|
+
click_proof_validation_result: '{"validated":true}',
|
|
62
|
+
friend_requestee_ids: [userID.toString()],
|
|
63
|
+
friending_channel: "FRIENDS_HOME_MAIN",
|
|
64
|
+
warn_ack_for_ids: [],
|
|
65
|
+
actor_id: ctx.userID,
|
|
66
|
+
client_mutation_id: Math.floor(Math.random() * 10).toString()
|
|
67
|
+
},
|
|
68
|
+
scale: 1
|
|
69
|
+
}),
|
|
70
|
+
server_timestamps: true,
|
|
71
|
+
doc_id: "24614631718227645"
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
defaultFuncs
|
|
75
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
76
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
77
|
+
.then(function (resData) {
|
|
78
|
+
if (resData.error) {
|
|
79
|
+
throw resData;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (resData.data && resData.data.friend_request_send) {
|
|
83
|
+
var responseData = resData.data.friend_request_send;
|
|
84
|
+
if (responseData.friend_requestees && responseData.friend_requestees.length > 0) {
|
|
85
|
+
var requestee = responseData.friend_requestees[0];
|
|
86
|
+
var result = {
|
|
87
|
+
userID: requestee.id,
|
|
88
|
+
friendshipStatus: requestee.friendship_status,
|
|
89
|
+
success: requestee.friendship_status === "OUTGOING_REQUEST"
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
if (requestee.profile_action) {
|
|
93
|
+
result.actionTitle = requestee.profile_action.title ? requestee.profile_action.title.text : "";
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return callback(null, result);
|
|
97
|
+
} else {
|
|
98
|
+
return callback({ error: "No friend request data received" });
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
return callback({ error: "Invalid response format" });
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
.catch(function (err) {
|
|
105
|
+
log.error("sendFriendRequest", err);
|
|
106
|
+
return callback(err);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return returnPromise;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
/** Developed by HRIDOY | GitHub: hridoy-dev | Please give credits if reused. */
|