@cexy/hoonfca 1.0.0 → 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/LICENSE +3 -0
- package/README.md +451 -43
- package/examples/login-with-cookies.js +102 -0
- package/examples/verify.js +70 -0
- package/index.js +1 -466
- package/package.json +98 -6
- 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/{changeThreadEmoji.js → apis/changeThreadEmoji.js} +7 -8
- 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/e2ee.js +17 -0
- package/src/apis/editMessage.js +70 -0
- package/src/apis/emoji.js +124 -0
- package/src/apis/fetchThemeData.js +82 -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 +95 -0
- package/src/apis/getThemeInfo.js +116 -0
- package/src/apis/getThreadHistory.js +239 -0
- package/src/apis/getThreadInfo.js +267 -0
- package/src/apis/getThreadList.js +232 -0
- package/src/apis/getThreadPictures.js +58 -0
- package/src/apis/getUserID.js +117 -0
- package/src/apis/getUserInfo.js +513 -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 +1236 -0
- package/src/apis/listenSpeed.js +179 -0
- package/src/apis/logout.js +87 -0
- package/src/apis/markAsDelivered.js +47 -0
- package/src/apis/markAsRead.js +99 -0
- package/src/apis/markAsReadAll.js +40 -0
- package/src/apis/markAsSeen.js +70 -0
- package/src/apis/mqttDeltaValue.js +278 -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 +150 -0
- package/src/apis/produceMetaTheme.js +180 -0
- package/src/apis/realtime.js +182 -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 +354 -0
- package/src/apis/sendMessageMqtt.js +249 -0
- package/src/apis/sendTypingIndicator.js +91 -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/engine/client.js +92 -0
- package/src/engine/models/buildAPI.js +152 -0
- package/src/engine/models/loginHelper.js +519 -0
- package/src/engine/models/setOptions.js +88 -0
- package/src/security/e2ee.js +109 -0
- package/src/types/index.d.ts +498 -0
- package/src/utils/antiSuspension.js +506 -0
- package/src/utils/auth-helpers.js +149 -0
- package/src/utils/autoReLogin.js +336 -0
- package/src/utils/axios.js +436 -0
- package/src/utils/cache.js +54 -0
- package/src/utils/clients.js +282 -0
- package/src/utils/constants.js +410 -0
- package/src/utils/formatters/data/formatAttachment.js +370 -0
- package/src/utils/formatters/data/formatDelta.js +109 -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 +1373 -0
- package/src/utils/headers.js +230 -0
- package/src/utils/index.js +153 -0
- package/src/utils/monitoring.js +333 -0
- package/src/utils/rateLimiter.js +319 -0
- package/src/utils/tokenRefresh.js +657 -0
- package/src/utils/user-agents.js +238 -0
- package/src/utils/validation.js +157 -0
- package/replit.nix +0 -3
- package/src/addExternalModule.js +0 -25
- package/src/addUserToGroup.js +0 -98
- package/src/changeAdminStatus.js +0 -98
- package/src/changeArchivedStatus.js +0 -51
- package/src/changeAvatar.js +0 -89
- package/src/changeBio.js +0 -74
- package/src/changeBlockedStatus.js +0 -45
- package/src/changeBlockedStatusMqtt.js +0 -65
- package/src/changeCover.js +0 -92
- package/src/changeGroupImage.js +0 -110
- package/src/changeName.js +0 -106
- package/src/changeNickname.js +0 -58
- package/src/changeThreadColor.js +0 -62
- package/src/changeUsername.js +0 -80
- package/src/createCommentPost.js +0 -196
- package/src/createNewGroup.js +0 -81
- package/src/createPoll.js +0 -64
- package/src/createPost.js +0 -285
- package/src/data/getThreadInfo.json +0 -1
- package/src/deleteMessage.js +0 -55
- package/src/deleteThread.js +0 -55
- package/src/editMessage.js +0 -66
- package/src/follow.js +0 -71
- package/src/forwardAttachment.js +0 -57
- package/src/getAccess.js +0 -130
- package/src/getAvatarUser.js +0 -88
- package/src/getBotInitialData.js +0 -59
- package/src/getCtx.js +0 -5
- package/src/getCurrentUserID.js +0 -5
- package/src/getEmojiUrl.js +0 -18
- package/src/getFriendsList.js +0 -81
- package/src/getMessage.js +0 -827
- package/src/getOptions.js +0 -5
- package/src/getRegion.js +0 -7
- package/src/getThreadHistory.js +0 -496
- package/src/getThreadHistoryDeprecated.js +0 -95
- package/src/getThreadInfo.js +0 -194
- package/src/getThreadInfoDeprecated.js +0 -77
- package/src/getThreadList.js +0 -219
- package/src/getThreadListDeprecated.js +0 -86
- package/src/getThreadPictures.js +0 -85
- package/src/getUserID.js +0 -67
- package/src/getUserInfo.js +0 -89
- package/src/handleFriendRequest.js +0 -56
- package/src/handleMessageRequest.js +0 -65
- package/src/httpGet.js +0 -53
- package/src/httpPost.js +0 -53
- package/src/httpPostFormData.js +0 -58
- package/src/listenMqtt.js +0 -683
- package/src/listenNotification.js +0 -96
- package/src/logout.js +0 -77
- package/src/markAsDelivered.js +0 -53
- package/src/markAsRead.js +0 -74
- package/src/markAsReadAll.js +0 -46
- package/src/markAsSeen.js +0 -57
- package/src/muteThread.js +0 -49
- package/src/pinMessage.js +0 -60
- package/src/refreshFb_dtsg.js +0 -75
- package/src/removeUserFromGroup.js +0 -59
- package/src/resolvePhotoUrl.js +0 -47
- package/src/searchForThread.js +0 -55
- package/src/searchStickers.js +0 -59
- package/src/sendMessage.js +0 -444
- package/src/sendMessageMqtt.js +0 -326
- package/src/sendTypingIndicator.js +0 -54
- package/src/setMessageReaction.js +0 -126
- package/src/setMessageReactionMqtt.js +0 -74
- package/src/setPostReaction.js +0 -103
- package/src/setProfileGuard.js +0 -66
- package/src/setStoryReaction.js +0 -97
- package/src/setTitle.js +0 -100
- package/src/shareContact.js +0 -101
- package/src/shareLink.js +0 -105
- package/src/stopListenMqtt.js +0 -47
- package/src/threadColors.js +0 -119
- package/src/unfriend.js +0 -58
- package/src/unsendMessage.js +0 -51
- package/src/uploadAttachment.js +0 -98
- package/utils.js +0 -919
package/src/changeThreadColor.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const utils = require("../utils");
|
|
4
|
-
|
|
5
|
-
module.exports = function (defaultFuncs, api, ctx) {
|
|
6
|
-
return function changeThreadColor(color, threadID, 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 = function (err) {
|
|
16
|
-
if (err) return rejectFunc(err);
|
|
17
|
-
resolveFunc();
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// কালার ভ্যালিডেশন এবং ফরম্যাটিং (Bug Fix)
|
|
22
|
-
let validatedColor = color;
|
|
23
|
-
if (color !== null && color !== undefined) {
|
|
24
|
-
validatedColor = !isNaN(color) ? color.toString().toLowerCase() : color.toLowerCase();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const form = {
|
|
28
|
-
dpr: 1,
|
|
29
|
-
queries: JSON.stringify({
|
|
30
|
-
o0: {
|
|
31
|
-
doc_id: "1727493033983591",
|
|
32
|
-
query_params: {
|
|
33
|
-
data: {
|
|
34
|
-
actor_id: ctx.userID,
|
|
35
|
-
client_mutation_id: "0",
|
|
36
|
-
source: "SETTINGS",
|
|
37
|
-
theme_id: validatedColor,
|
|
38
|
-
thread_id: threadID,
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
}),
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
defaultFuncs
|
|
46
|
-
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
|
47
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
48
|
-
.then(function (resData) {
|
|
49
|
-
// এরর রেজাল্ট চেক করা হচ্ছে
|
|
50
|
-
if (resData[resData.length - 1]?.error_results > 0) {
|
|
51
|
-
throw new utils.CustomError(resData[0].o0.errors);
|
|
52
|
-
}
|
|
53
|
-
return callback();
|
|
54
|
-
})
|
|
55
|
-
.catch(function (err) {
|
|
56
|
-
utils.error("changeThreadColor", err);
|
|
57
|
-
return callback(err);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
return returnPromise;
|
|
61
|
-
};
|
|
62
|
-
};
|
package/src/changeUsername.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var utils = require('../utils');
|
|
4
|
-
|
|
5
|
-
module.exports = function (defaultFuncs, api, ctx) {
|
|
6
|
-
return function changeUsername(username, callback) {
|
|
7
|
-
var resolveFunc = function () {};
|
|
8
|
-
var rejectFunc = function () {};
|
|
9
|
-
var returnPromise = new Promise(function (resolve, reject) {
|
|
10
|
-
resolveFunc = resolve;
|
|
11
|
-
rejectFunc = reject;
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
// কলব্যাক ডিফাইন করা না থাকলে প্রমিজ হ্যান্ডলার সেট করা হচ্ছে
|
|
15
|
-
if (typeof callback !== 'function') {
|
|
16
|
-
callback = function (err, data) {
|
|
17
|
-
if (err) {
|
|
18
|
-
return rejectFunc(err);
|
|
19
|
-
}
|
|
20
|
-
resolveFunc(data);
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// প্রথম প্যারামিটার হিসেবে ভুলবশত ফাংশন পাস করলে তা হ্যান্ডেল করা
|
|
25
|
-
if (typeof username === 'function') {
|
|
26
|
-
var errorMsg = 'username must be a string, and not ' + utils.getType(username);
|
|
27
|
-
utils.error('changeUsername', errorMsg);
|
|
28
|
-
return username({ error: errorMsg });
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (typeof username !== 'string') {
|
|
32
|
-
var errorMsg = 'username must be a string, and not ' + utils.getType(username);
|
|
33
|
-
utils.error('changeUsername', errorMsg);
|
|
34
|
-
return callback({ error: errorMsg });
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
var form = {
|
|
38
|
-
fb_api_caller_class: 'RelayModern',
|
|
39
|
-
fb_api_req_friendly_name: 'useFXIMUpdateUsernameMutation',
|
|
40
|
-
variables: JSON.stringify({
|
|
41
|
-
client_mutation_id: utils.getGUID(),
|
|
42
|
-
family_device_id: "device_id_fetch_datr",
|
|
43
|
-
identity_ids: [ctx.userID.toString()],
|
|
44
|
-
username: username,
|
|
45
|
-
interface: "FB_WEB"
|
|
46
|
-
}),
|
|
47
|
-
server_timestamps: true,
|
|
48
|
-
doc_id: "5737739449613305" // doc_id সাধারণত স্ট্রিং হিসেবে নিরাপদ
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
defaultFuncs
|
|
52
|
-
.post('https://accountscenter.facebook.com/api/graphql/', ctx.jar, form, null, null, {
|
|
53
|
-
Origin: 'https://accountscenter.facebook.com',
|
|
54
|
-
Referer: `https://accountscenter.facebook.com/profiles/${ctx.userID}/username/?entrypoint=fb_account_center`
|
|
55
|
-
})
|
|
56
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
57
|
-
.then(function (res) {
|
|
58
|
-
if (!res) {
|
|
59
|
-
throw { error: "changeUsername returned empty response." };
|
|
60
|
-
}
|
|
61
|
-
if (res.errors) {
|
|
62
|
-
throw res;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// রেসপন্স ডাটার ভেতরের এরর অবজেক্ট সেফলি চেক করা
|
|
66
|
-
var updateResult = res.data && res.data.fxim_update_identity_username;
|
|
67
|
-
if (updateResult && updateResult.error) {
|
|
68
|
-
throw updateResult.error;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return callback(null, res);
|
|
72
|
-
})
|
|
73
|
-
.catch(function (err) {
|
|
74
|
-
utils.error('changeUsername', err);
|
|
75
|
-
return callback(err);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
return returnPromise;
|
|
79
|
-
};
|
|
80
|
-
};
|
package/src/createCommentPost.js
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const utils = require("../utils.js");
|
|
4
|
-
|
|
5
|
-
module.exports = function (defaultFuncs, api, ctx) {
|
|
6
|
-
|
|
7
|
-
// অ্যাটাচমেন্ট আপলোড করার ফাংশন
|
|
8
|
-
function handleUpload(msg, form) {
|
|
9
|
-
if (!msg.attachments || msg.attachments.length === 0) return Promise.resolve();
|
|
10
|
-
|
|
11
|
-
const uploads = msg.attachments.map(item => {
|
|
12
|
-
if (!utils.isReadableStream(item)) {
|
|
13
|
-
return Promise.reject({ error: "image should be a readable stream and not " + utils.getType(item) });
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return defaultFuncs
|
|
17
|
-
.postFormData("https://www.facebook.com/ajax/ufi/upload/", ctx.jar, {
|
|
18
|
-
profile_id: ctx.userID,
|
|
19
|
-
source: 19,
|
|
20
|
-
target_id: ctx.userID,
|
|
21
|
-
file: item
|
|
22
|
-
})
|
|
23
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
24
|
-
.then(res => {
|
|
25
|
-
if (res.errors || res.error || !res.payload) throw res;
|
|
26
|
-
return { media: { id: res.payload.fbid } };
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
return Promise.all(uploads).then(results => {
|
|
31
|
-
results.forEach(item => form.input.attachments.push(item));
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function handleURL(msg, form) {
|
|
36
|
-
if (typeof msg.url === "string") {
|
|
37
|
-
form.input.attachments = [{ link: { external: { url: msg.url } } }];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function handleMentions(msg, form) {
|
|
42
|
-
if (!msg.mentions) return;
|
|
43
|
-
for (const item of msg.mentions) {
|
|
44
|
-
const { tag, id, fromIndex } = item;
|
|
45
|
-
|
|
46
|
-
if (typeof tag !== "string") throw new Error("Mention tag must be string");
|
|
47
|
-
if (!id) throw new Error("id must be string");
|
|
48
|
-
|
|
49
|
-
const offset = msg.body.indexOf(tag, fromIndex || 0);
|
|
50
|
-
if (offset < 0) throw new Error(`Mention for "${tag}" not found in message string.`);
|
|
51
|
-
|
|
52
|
-
form.input.message.ranges.push({
|
|
53
|
-
entity: { id },
|
|
54
|
-
length: tag.length,
|
|
55
|
-
offset
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function handleSticker(msg, form) {
|
|
61
|
-
if (msg.sticker) {
|
|
62
|
-
form.input.attachments = [{ media: { id: msg.sticker } }];
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// গ্রাফকিউএল রিকোয়েস্ট সাবমিট করার ফাংশন
|
|
67
|
-
function createContent(form) {
|
|
68
|
-
return defaultFuncs
|
|
69
|
-
.post("https://www.facebook.com/api/graphql/", ctx.jar, {
|
|
70
|
-
fb_api_caller_class: "RelayModern",
|
|
71
|
-
fb_api_req_friendly_name: "useCometUFICreateCommentMutation",
|
|
72
|
-
variables: JSON.stringify(form),
|
|
73
|
-
server_timestamps: true,
|
|
74
|
-
doc_id: 6993516810709754
|
|
75
|
-
})
|
|
76
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
77
|
-
.then(res => {
|
|
78
|
-
if (res.errors) throw res;
|
|
79
|
-
const node = res.data.comment_create;
|
|
80
|
-
return {
|
|
81
|
-
id: node.feedback_comment_edge.node.id,
|
|
82
|
-
url: node.feedback_comment_edge.node.feedback.url,
|
|
83
|
-
count: node.feedback.total_comment_count
|
|
84
|
-
};
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return function createCommentPost(msg, postID, callback, replyCommentID) {
|
|
89
|
-
let cb;
|
|
90
|
-
const returnPromise = new Promise((resolve, reject) => {
|
|
91
|
-
cb = (error, info) => (info ? resolve(info) : reject(error));
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
// ইনপুট ভ্যালিডেশন
|
|
95
|
-
if (typeof msg === "function") {
|
|
96
|
-
const error = "Message must be a string or object!!";
|
|
97
|
-
utils.error("createCommentPost", error);
|
|
98
|
-
msg(error);
|
|
99
|
-
return returnPromise;
|
|
100
|
-
}
|
|
101
|
-
if (typeof postID === "function") {
|
|
102
|
-
const error = "postID must be a string!!";
|
|
103
|
-
utils.error("createCommentPost", error);
|
|
104
|
-
postID(error);
|
|
105
|
-
return returnPromise;
|
|
106
|
-
}
|
|
107
|
-
if (typeof callback === "string") {
|
|
108
|
-
replyCommentID = callback;
|
|
109
|
-
callback = null;
|
|
110
|
-
}
|
|
111
|
-
if (typeof callback === "function") {
|
|
112
|
-
cb = callback;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const messageType = utils.getType(msg);
|
|
116
|
-
|
|
117
|
-
if (messageType === "String") {
|
|
118
|
-
msg = {
|
|
119
|
-
body: msg,
|
|
120
|
-
attachments: [],
|
|
121
|
-
mentions: [],
|
|
122
|
-
sticker: null,
|
|
123
|
-
url: null
|
|
124
|
-
};
|
|
125
|
-
} else if (messageType === "Object") {
|
|
126
|
-
msg.mentions = msg.mentions ? (Array.isArray(msg.mentions) ? msg.mentions : [msg.mentions]) : [];
|
|
127
|
-
msg.attachments = msg.attachments ? (Array.isArray(msg.attachments) ? msg.attachments : [msg.attachments]) : [];
|
|
128
|
-
if (isNaN(msg.sticker)) msg.sticker = null;
|
|
129
|
-
if (msg.body && typeof msg.body === "object") msg.body = JSON.stringify(msg.body);
|
|
130
|
-
if (!msg.body) msg.body = "";
|
|
131
|
-
} else {
|
|
132
|
-
const error = "Message must be a string or object!!";
|
|
133
|
-
utils.error("createCommentPost", error);
|
|
134
|
-
cb(error);
|
|
135
|
-
return returnPromise;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (typeof postID !== "string") {
|
|
139
|
-
const error = "postID must be a string!!";
|
|
140
|
-
utils.error("createCommentPost", error);
|
|
141
|
-
cb(error);
|
|
142
|
-
return returnPromise;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (typeof replyCommentID !== "string") replyCommentID = null;
|
|
146
|
-
|
|
147
|
-
// ফর্ম অবজেক্ট ডিক্লেয়ারেশন
|
|
148
|
-
const form = {
|
|
149
|
-
feedLocation: "NEWSFEED",
|
|
150
|
-
feedbackSource: 1,
|
|
151
|
-
groupID: null,
|
|
152
|
-
input: {
|
|
153
|
-
client_mutation_id: Math.round(Math.random() * 19).toString(),
|
|
154
|
-
actor_id: ctx.userID,
|
|
155
|
-
attachments: [],
|
|
156
|
-
feedback_id: Buffer.from("feedback:" + postID).toString("base64"),
|
|
157
|
-
formatting_style: null,
|
|
158
|
-
message: {
|
|
159
|
-
ranges: [],
|
|
160
|
-
text: msg.body
|
|
161
|
-
},
|
|
162
|
-
reply_comment_parent_fbid: replyCommentID
|
|
163
|
-
? (isNaN(replyCommentID) ? replyCommentID : Buffer.from("comment:" + postID + "_" + replyCommentID).toString("base64"))
|
|
164
|
-
: null,
|
|
165
|
-
reply_target_clicked: !!replyCommentID,
|
|
166
|
-
attribution_id_v2: "CometHomeRoot.react,comet.home,via_cold_start," + Date.now() + ",156248,4748854339,,",
|
|
167
|
-
vod_video_timestamp: null,
|
|
168
|
-
feedback_referrer: "/",
|
|
169
|
-
is_tracking_encrypted: true,
|
|
170
|
-
tracking: [],
|
|
171
|
-
feedback_source: "NEWS_FEED",
|
|
172
|
-
idempotence_token: "client:" + utils.getGUID(),
|
|
173
|
-
session_id: utils.getGUID()
|
|
174
|
-
},
|
|
175
|
-
inviteShortLinkKey: null,
|
|
176
|
-
renderLocation: null,
|
|
177
|
-
scale: 1,
|
|
178
|
-
useDefaultActor: false,
|
|
179
|
-
focusCommentID: null
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
// প্রমিজ চেইন এক্সিকিউশন
|
|
183
|
-
handleUpload(msg, form)
|
|
184
|
-
.then(() => handleURL(msg, form))
|
|
185
|
-
.then(() => handleMentions(msg, form))
|
|
186
|
-
.then(() => handleSticker(msg, form))
|
|
187
|
-
.then(() => createContent(form))
|
|
188
|
-
.then(info => cb(null, info))
|
|
189
|
-
.catch(err => {
|
|
190
|
-
utils.error("createCommentPost", err);
|
|
191
|
-
return cb(err); // বাগ ফিক্স করা হয়েছে
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
return returnPromise;
|
|
195
|
-
};
|
|
196
|
-
};
|
package/src/createNewGroup.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const utils = require("../utils");
|
|
4
|
-
|
|
5
|
-
module.exports = function (defaultFuncs, api, ctx) {
|
|
6
|
-
return function createNewGroup(participantIDs, groupTitle, callback) {
|
|
7
|
-
// groupTitle-এর জায়গায় ফাংশন পাস করলে তা কলব্যাক হিসেবে সেট হচ্ছে
|
|
8
|
-
if (utils.getType(groupTitle) === "Function") {
|
|
9
|
-
callback = groupTitle;
|
|
10
|
-
groupTitle = null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (utils.getType(participantIDs) !== "Array") {
|
|
14
|
-
throw { error: "createNewGroup: participantIDs should be an array." };
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (participantIDs.length < 2) {
|
|
18
|
-
throw {
|
|
19
|
-
error: "createNewGroup: participantIDs should have at least 2 IDs.",
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
let resolveFunc = () => {};
|
|
24
|
-
let rejectFunc = () => {};
|
|
25
|
-
const returnPromise = new Promise((resolve, reject) => {
|
|
26
|
-
resolveFunc = resolve;
|
|
27
|
-
rejectFunc = reject;
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
if (!callback) {
|
|
31
|
-
callback = function (err, threadID) {
|
|
32
|
-
if (err) return rejectFunc(err);
|
|
33
|
-
resolveFunc(threadID);
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// map() ব্যবহার করে দ্রুত এবং ক্লিন উপায়ে পার্টিসিপেন্ট অবজেক্ট অ্যারে তৈরি
|
|
38
|
-
const pids = participantIDs.map(id => ({ fbid: id }));
|
|
39
|
-
pids.push({ fbid: ctx.userID }); // বটের নিজের আইডি যুক্ত করা হলো
|
|
40
|
-
|
|
41
|
-
const form = {
|
|
42
|
-
fb_api_caller_class: "RelayModern",
|
|
43
|
-
fb_api_req_friendly_name: "MessengerGroupCreateMutation",
|
|
44
|
-
av: ctx.userID,
|
|
45
|
-
doc_id: "577041672419534",
|
|
46
|
-
variables: JSON.stringify({
|
|
47
|
-
input: {
|
|
48
|
-
entry_point: "jewel_new_group",
|
|
49
|
-
actor_id: ctx.userID,
|
|
50
|
-
participants: pids,
|
|
51
|
-
client_mutation_id: Math.round(Math.random() * 1024).toString(),
|
|
52
|
-
thread_settings: {
|
|
53
|
-
name: groupTitle,
|
|
54
|
-
joinable_mode: "PRIVATE",
|
|
55
|
-
thread_image_fbid: null,
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
}),
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
defaultFuncs
|
|
62
|
-
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
63
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
64
|
-
.then(function (resData) {
|
|
65
|
-
if (resData.errors) {
|
|
66
|
-
throw resData;
|
|
67
|
-
}
|
|
68
|
-
// সফলভাবে গ্রুপ তৈরি হলে নতুন থ্রেড আইডি (Thread ID) রিটার্ন করা হচ্ছে
|
|
69
|
-
return callback(
|
|
70
|
-
null,
|
|
71
|
-
resData.data.messenger_group_thread_create.thread.thread_key.thread_fbid
|
|
72
|
-
);
|
|
73
|
-
})
|
|
74
|
-
.catch(function (err) {
|
|
75
|
-
utils.error("createNewGroup", err);
|
|
76
|
-
return callback(err);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
return returnPromise;
|
|
80
|
-
};
|
|
81
|
-
};
|
package/src/createPoll.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const utils = require("../utils");
|
|
4
|
-
|
|
5
|
-
module.exports = function (defaultFuncs, api, ctx) {
|
|
6
|
-
return function createPoll(title, threadID, options, callback) {
|
|
7
|
-
let resolveFunc = () => {};
|
|
8
|
-
let rejectFunc = () => {};
|
|
9
|
-
const returnPromise = new Promise((resolve, reject) => {
|
|
10
|
-
resolveFunc = resolve;
|
|
11
|
-
rejectFunc = reject;
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const optionsType = utils.getType(options);
|
|
15
|
-
|
|
16
|
-
// কলব্যাক ও অপশন হ্যান্ডলিং
|
|
17
|
-
if (!callback) {
|
|
18
|
-
if (optionsType === "Function" || optionsType === "AsyncFunction") {
|
|
19
|
-
callback = options;
|
|
20
|
-
options = null;
|
|
21
|
-
} else {
|
|
22
|
-
callback = function (err) {
|
|
23
|
-
if (err) return rejectFunc(err);
|
|
24
|
-
resolveFunc();
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!options) {
|
|
30
|
-
options = {};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const form = {
|
|
34
|
-
target_id: threadID,
|
|
35
|
-
question_text: title,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// Object.entries ব্যবহার করে দ্রুত এবং ক্লিন উপায়ে অপশন লোড করা হচ্ছে
|
|
39
|
-
Object.entries(options).forEach(([opt, isSelected], ind) => {
|
|
40
|
-
form[`option_text_array[${ind}]`] = opt;
|
|
41
|
-
form[`option_is_selected_array[${ind}]`] = isSelected ? "1" : "0";
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
defaultFuncs
|
|
45
|
-
.post(
|
|
46
|
-
"https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1",
|
|
47
|
-
ctx.jar,
|
|
48
|
-
form
|
|
49
|
-
)
|
|
50
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
51
|
-
.then(function (resData) {
|
|
52
|
-
if (resData.payload?.status !== "success") {
|
|
53
|
-
throw resData;
|
|
54
|
-
}
|
|
55
|
-
return callback();
|
|
56
|
-
})
|
|
57
|
-
.catch(function (err) {
|
|
58
|
-
utils.error("createPoll", err);
|
|
59
|
-
return callback(err);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
return returnPromise;
|
|
63
|
-
};
|
|
64
|
-
};
|