alicezetion 1.8.4 → 1.8.5
Sign up to get free protection for your applications and to get access to all the features.
- package/.cache/replit/__replit_disk_meta.json +1 -1
- package/.cache/replit/modules.stamp +1 -0
- package/.cache/replit/nix/env.json +1 -1
- package/index.js +375 -210
- package/leiamnash/addExternalModule.js +15 -0
- package/leiamnash/addUserToGroup.js +77 -0
- package/leiamnash/changeAdminStatus.js +47 -0
- package/leiamnash/changeArchivedStatus.js +41 -0
- package/leiamnash/changeAvatar.js +127 -0
- package/leiamnash/changeBio.js +64 -0
- package/leiamnash/changeBlockedStatus.js +36 -0
- package/leiamnash/changeGroupImage.js +105 -0
- package/leiamnash/changeNickname.js +43 -0
- package/leiamnash/changeThreadColor.js +61 -0
- package/leiamnash/changeThreadEmoji.js +41 -0
- package/{src → leiamnash}/chat.js +3 -28
- package/leiamnash/createNewGroup.js +70 -0
- package/leiamnash/createPoll.js +59 -0
- package/leiamnash/deleteMessage.js +44 -0
- package/leiamnash/deleteThread.js +42 -0
- package/leiamnash/forwardAttachment.js +47 -0
- package/leiamnash/forwardMessage.js +0 -0
- package/leiamnash/getCurrentUserID.js +7 -0
- package/leiamnash/getEmojiUrl.js +27 -0
- package/leiamnash/getFriendsList.js +73 -0
- package/leiamnash/getInfoVideo.js +134 -0
- package/leiamnash/getThreadHistory.js +537 -0
- package/leiamnash/getThreadHistoryDeprecated.js +71 -0
- package/{src → leiamnash}/getThreadInfo.js +54 -70
- package/leiamnash/getThreadInfoDeprecated.js +56 -0
- package/leiamnash/getThreadList.js +213 -0
- package/leiamnash/getThreadListDeprecated.js +46 -0
- package/leiamnash/getThreadPictures.js +59 -0
- package/leiamnash/getUserID.js +61 -0
- package/leiamnash/getUserInfo.js +66 -0
- package/leiamnash/handleFriendRequest.js +46 -0
- package/leiamnash/handleMessageRequest.js +47 -0
- package/leiamnash/httpGet.js +47 -0
- package/leiamnash/httpPost.js +47 -0
- package/leiamnash/httpPostFormData.js +42 -0
- package/{src → leiamnash}/listenMqtt.js +6 -16
- package/leiamnash/logout.js +68 -0
- package/leiamnash/markAsDelivered.js +47 -0
- package/leiamnash/markAsRead.js +70 -0
- package/leiamnash/markAsReadAll.js +40 -0
- package/leiamnash/markAsSeen.js +48 -0
- package/leiamnash/muteThread.js +45 -0
- package/leiamnash/react.js +109 -0
- package/{src → leiamnash}/refreshFb_dtsg.js +1 -1
- package/leiamnash/removeUserFromGroup.js +45 -0
- package/leiamnash/resolvePhotoUrl.js +36 -0
- package/leiamnash/searchForThread.js +42 -0
- package/leiamnash/seen.js +40 -0
- package/leiamnash/sendMessage.js +315 -0
- package/leiamnash/sendTypingIndicator.js +70 -0
- package/leiamnash/setMessageReaction.js +103 -0
- package/leiamnash/setPostReaction.js +63 -0
- package/leiamnash/setTitle.js +70 -0
- package/leiamnash/threadColors.js +41 -0
- package/leiamnash/unfriend.js +42 -0
- package/leiamnash/unsendMessage.js +39 -0
- package/leiamnash/uploadAttachment.js +96 -0
- package/package.json +3 -6
- package/replit.nix +4 -4
- package/utils.js +176 -135
- package/src/addExternalModule.js +0 -17
- package/src/addUserToGroup.js +0 -113
- package/src/changeAdminStatus.js +0 -79
- package/src/changeArchivedStatus.js +0 -55
- package/src/changeAvatar.js +0 -93
- package/src/changeBio.js +0 -77
- package/src/changeBlockedStatus.js +0 -47
- package/src/changeCover.js +0 -73
- package/src/changeGroupImage.js +0 -132
- package/src/changeName.js +0 -79
- package/src/changeNickname.js +0 -59
- package/src/changeThreadColor.js +0 -65
- package/src/changeThreadEmoji.js +0 -55
- package/src/createNewGroup.js +0 -86
- package/src/createPoll.js +0 -71
- package/src/data/getThreadInfo.json +0 -1
- package/src/deleteMessage.js +0 -56
- package/src/deleteThread.js +0 -56
- package/src/forwardAttachment.js +0 -60
- package/src/getAccess.js +0 -112
- package/src/getAvatarUser.js +0 -78
- package/src/getCurrentUserID.js +0 -7
- package/src/getEmojiUrl.js +0 -29
- package/src/getFriendsList.js +0 -83
- package/src/getThreadHistory.js +0 -666
- package/src/getThreadList.js +0 -237
- package/src/getThreadPictures.js +0 -79
- package/src/getUserID.js +0 -66
- package/src/getUserInfo.js +0 -163
- package/src/handleFriendRequest.js +0 -61
- package/src/handleMessageRequest.js +0 -65
- package/src/httpGet.js +0 -57
- package/src/httpPost.js +0 -57
- package/src/httpPostFormData.js +0 -63
- package/src/listenNotification.js +0 -88
- package/src/logout.js +0 -275
- package/src/markAsDelivered.js +0 -58
- package/src/markAsRead.js +0 -80
- package/src/markAsReadAll.js +0 -50
- package/src/markAsSeen.js +0 -59
- package/src/muteThread.js +0 -52
- package/src/react.js +0 -117
- package/src/removeUserFromGroup.js +0 -79
- package/src/resolvePhotoUrl.js +0 -45
- package/src/searchForThread.js +0 -53
- package/src/searchStickers.js +0 -52
- package/src/seen.js +0 -50
- package/src/sendMessage.js +0 -477
- package/src/sendMessageMqtt.js +0 -316
- package/src/sendTypingIndicator.js +0 -103
- package/src/setMessageReaction.js +0 -117
- package/src/setPostReaction.js +0 -109
- package/src/setTitle.js +0 -86
- package/src/threadColors.js +0 -131
- package/src/unfriend.js +0 -52
- package/src/unsendMessage.js +0 -49
- /package/{src → leiamnash}/getMessage.js +0 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const utils = require("../utils");
|
4
|
+
|
5
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
6
|
+
return function addExternalModule(moduleObj) {
|
7
|
+
if (utils.getType(moduleObj) == "Object") {
|
8
|
+
for (let apiName in moduleObj) {
|
9
|
+
if (utils.getType(moduleObj[apiName]) == "Function") api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
|
10
|
+
else throw new Error(`Item "${apiName}" in moduleObj must be a function, not ${utils.getType(moduleObj[apiName])}!`);
|
11
|
+
}
|
12
|
+
}
|
13
|
+
else throw new Error(`moduleObj must be an object, not ${utils.getType(moduleObj)}!`);
|
14
|
+
};
|
15
|
+
};
|
@@ -0,0 +1,77 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
+
return function addUserToGroup(userID, threadID, 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
|
+
|
15
|
+
if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
|
16
|
+
|
17
|
+
if (!callback) {
|
18
|
+
callback = function (err) {
|
19
|
+
if (err) return rejectFunc(err);
|
20
|
+
resolveFunc();
|
21
|
+
};
|
22
|
+
}
|
23
|
+
|
24
|
+
if (utils.getType(threadID) !== "Number" && utils.getType(threadID) !== "String") throw { error: "ThreadID should be of type Number or String and not " + utils.getType(threadID) + "." };
|
25
|
+
|
26
|
+
if (utils.getType(userID) !== "Array") userID = [userID];
|
27
|
+
|
28
|
+
var messageAndOTID = utils.generateOfflineThreadingID();
|
29
|
+
var form = {
|
30
|
+
client: "mercury",
|
31
|
+
action_type: "ma-type:log-message",
|
32
|
+
author: "fbid:" + ctx.userID,
|
33
|
+
thread_id: "",
|
34
|
+
timestamp: Date.now(),
|
35
|
+
timestamp_absolute: "Today",
|
36
|
+
timestamp_relative: utils.generateTimestampRelative(),
|
37
|
+
timestamp_time_passed: "0",
|
38
|
+
is_unread: false,
|
39
|
+
is_cleared: false,
|
40
|
+
is_forward: false,
|
41
|
+
is_filtered_content: false,
|
42
|
+
is_filtered_content_bh: false,
|
43
|
+
is_filtered_content_account: false,
|
44
|
+
is_spoof_warning: false,
|
45
|
+
source: "source:chat:web",
|
46
|
+
"source_tags[0]": "source:chat",
|
47
|
+
log_message_type: "log:subscribe",
|
48
|
+
status: "0",
|
49
|
+
offline_threading_id: messageAndOTID,
|
50
|
+
message_id: messageAndOTID,
|
51
|
+
threading_id: utils.generateThreadingID(ctx.clientID),
|
52
|
+
manual_retry_cnt: "0",
|
53
|
+
thread_fbid: threadID
|
54
|
+
};
|
55
|
+
|
56
|
+
for (var i = 0; i < userID.length; i++) {
|
57
|
+
if (utils.getType(userID[i]) !== "Number" && utils.getType(userID[i]) !== "String") throw { error: "Elements of userID should be of type Number or String and not " + utils.getType(userID[i]) + "." };
|
58
|
+
form["log_message_data[added_participants][" + i + "]"] = "fbid:" + userID[i];
|
59
|
+
}
|
60
|
+
|
61
|
+
defaultFuncs
|
62
|
+
.post("https://www.facebook.com/messaging/send/", ctx.jar, form)
|
63
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
64
|
+
.then(function (resData) {
|
65
|
+
if (!resData) throw { error: "Add to group failed." };
|
66
|
+
if (resData.error) throw resData;
|
67
|
+
|
68
|
+
return callback();
|
69
|
+
})
|
70
|
+
.catch(function (err) {
|
71
|
+
log.error("addUserToGroup", "» Cannot add user to the voice chat. Please try again after");
|
72
|
+
return callback(err);
|
73
|
+
});
|
74
|
+
|
75
|
+
return returnPromise;
|
76
|
+
};
|
77
|
+
};
|
@@ -0,0 +1,47 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const utils = require("../utils");
|
4
|
+
|
5
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
6
|
+
return function changeAdminStatus(threadID, adminID, adminStatus) {
|
7
|
+
if (utils.getType(threadID) !== "String") throw { error: "changeAdminStatus: threadID must be a string" };
|
8
|
+
if (utils.getType(adminID) !== "String" && utils.getType(adminID) !== "Array") throw { error: "changeAdminStatus: adminID must be a string or an array" };
|
9
|
+
if (utils.getType(adminStatus) !== "Boolean") throw { error: "changeAdminStatus: adminStatus must be true or false" };
|
10
|
+
|
11
|
+
let wsContent = {
|
12
|
+
request_id: 1,
|
13
|
+
type: 3,
|
14
|
+
payload: {
|
15
|
+
version_id: '3816854585040595',
|
16
|
+
tasks: [],
|
17
|
+
epoch_id: 6763184801413415579,
|
18
|
+
data_trace_id: null
|
19
|
+
},
|
20
|
+
app_id: '772021112871879'
|
21
|
+
}
|
22
|
+
|
23
|
+
if (utils.getType(adminID) === "Array") {
|
24
|
+
for (let i = 0; i < adminID.length; i++) {
|
25
|
+
wsContent.payload.tasks.push({
|
26
|
+
label: '25',
|
27
|
+
payload: JSON.stringify({ thread_key: threadID, contact_id: adminID[i], is_admin: adminStatus }),
|
28
|
+
queue_name: 'admin_status',
|
29
|
+
task_id: i + 1,
|
30
|
+
failure_count: null
|
31
|
+
});
|
32
|
+
}
|
33
|
+
}
|
34
|
+
else {
|
35
|
+
wsContent.payload.tasks.push({
|
36
|
+
label: '25',
|
37
|
+
payload: JSON.stringify({ thread_key: threadID, contact_id: adminID, is_admin: adminStatus }),
|
38
|
+
queue_name: 'admin_status',
|
39
|
+
task_id: 1,
|
40
|
+
failure_count: null
|
41
|
+
});
|
42
|
+
}
|
43
|
+
|
44
|
+
wsContent.payload = JSON.stringify(wsContent.payload);
|
45
|
+
return new Promise((resolve, reject) => ctx.mqttClient && ctx.mqttClient.publish('/ls_req', JSON.stringify(wsContent), {}, (err, _packet) => err ? reject(err) : resolve()));
|
46
|
+
};
|
47
|
+
};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
+
return function changeArchivedStatus(threadOrThreads, archive, 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
|
+
|
15
|
+
if (!callback) {
|
16
|
+
callback = function (err) {
|
17
|
+
if (err) return rejectFunc(err);
|
18
|
+
resolveFunc();
|
19
|
+
};
|
20
|
+
}
|
21
|
+
|
22
|
+
var form = {};
|
23
|
+
|
24
|
+
if (utils.getType(threadOrThreads) === "Array") for (var i = 0; i < threadOrThreads.length; i++) form["ids[" + threadOrThreads[i] + "]"] = archive;
|
25
|
+
else form["ids[" + threadOrThreads + "]"] = archive;
|
26
|
+
|
27
|
+
defaultFuncs
|
28
|
+
.post("https://www.facebook.com/ajax/mercury/change_archived_status.php", ctx.jar, form)
|
29
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
30
|
+
.then(function (resData) {
|
31
|
+
if (resData.error) throw resData;
|
32
|
+
return callback();
|
33
|
+
})
|
34
|
+
.catch(function (err) {
|
35
|
+
log.error("changeArchivedStatus", err);
|
36
|
+
return callback(err);
|
37
|
+
});
|
38
|
+
|
39
|
+
return returnPromise;
|
40
|
+
};
|
41
|
+
};
|
@@ -0,0 +1,127 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const utils = require("../utils");
|
4
|
+
const log = require("npmlog");
|
5
|
+
const bluebird = require("bluebird");
|
6
|
+
|
7
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
8
|
+
function handleUpload(image, callback) {
|
9
|
+
const uploads = [];
|
10
|
+
|
11
|
+
const form = {
|
12
|
+
profile_id: ctx.i_userID || ctx.userID,
|
13
|
+
photo_source: 57,
|
14
|
+
av: ctx.i_userID || ctx.userID,
|
15
|
+
file: image
|
16
|
+
};
|
17
|
+
|
18
|
+
uploads.push(
|
19
|
+
defaultFuncs
|
20
|
+
.postFormData(
|
21
|
+
"https://www.facebook.com/profile/picture/upload/",
|
22
|
+
ctx.jar,
|
23
|
+
form,
|
24
|
+
{}
|
25
|
+
)
|
26
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
27
|
+
.then(function (resData) {
|
28
|
+
if (resData.error) {
|
29
|
+
throw resData;
|
30
|
+
}
|
31
|
+
return resData;
|
32
|
+
})
|
33
|
+
);
|
34
|
+
|
35
|
+
// resolve all promises
|
36
|
+
bluebird
|
37
|
+
.all(uploads)
|
38
|
+
.then(function (resData) {
|
39
|
+
callback(null, resData);
|
40
|
+
})
|
41
|
+
.catch(function (err) {
|
42
|
+
log.error("handleUpload", err);
|
43
|
+
return callback(err);
|
44
|
+
});
|
45
|
+
}
|
46
|
+
|
47
|
+
return function changeAvatar(image, caption = "", timestamp = null, callback) {
|
48
|
+
let resolveFunc = function () { };
|
49
|
+
let rejectFunc = function () { };
|
50
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
51
|
+
resolveFunc = resolve;
|
52
|
+
rejectFunc = reject;
|
53
|
+
});
|
54
|
+
|
55
|
+
if (!timestamp && utils.getType(caption) === "Number") {
|
56
|
+
timestamp = caption;
|
57
|
+
caption = "";
|
58
|
+
}
|
59
|
+
|
60
|
+
if (!timestamp && !callback && (utils.getType(caption) == "Function" || utils.getType(caption) == "AsyncFunction")) {
|
61
|
+
callback = caption;
|
62
|
+
caption = "";
|
63
|
+
timestamp = null;
|
64
|
+
}
|
65
|
+
|
66
|
+
if (!callback) callback = function (err, data) {
|
67
|
+
if (err) {
|
68
|
+
return rejectFunc(err);
|
69
|
+
}
|
70
|
+
resolveFunc(data);
|
71
|
+
};
|
72
|
+
|
73
|
+
if (!utils.isReadableStream(image))
|
74
|
+
return callback("Image is not a readable stream");
|
75
|
+
|
76
|
+
handleUpload(image, function (err, payload) {
|
77
|
+
if (err) {
|
78
|
+
return callback(err);
|
79
|
+
}
|
80
|
+
|
81
|
+
const form = {
|
82
|
+
av: ctx.i_userID || ctx.userID,
|
83
|
+
fb_api_req_friendly_name: "ProfileCometProfilePictureSetMutation",
|
84
|
+
fb_api_caller_class: "RelayModern",
|
85
|
+
doc_id: "5066134240065849",
|
86
|
+
variables: JSON.stringify({
|
87
|
+
input: {
|
88
|
+
caption,
|
89
|
+
existing_photo_id: payload[0].payload.fbid,
|
90
|
+
expiration_time: timestamp,
|
91
|
+
profile_id: ctx.i_userID || ctx.userID,
|
92
|
+
profile_pic_method: "EXISTING",
|
93
|
+
profile_pic_source: "TIMELINE",
|
94
|
+
scaled_crop_rect: {
|
95
|
+
height: 1,
|
96
|
+
width: 1,
|
97
|
+
x: 0,
|
98
|
+
y: 0
|
99
|
+
},
|
100
|
+
skip_cropping: true,
|
101
|
+
actor_id: ctx.i_userID || ctx.userID,
|
102
|
+
client_mutation_id: Math.round(Math.random() * 19).toString()
|
103
|
+
},
|
104
|
+
isPage: false,
|
105
|
+
isProfile: true,
|
106
|
+
scale: 3
|
107
|
+
})
|
108
|
+
};
|
109
|
+
|
110
|
+
defaultFuncs
|
111
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
112
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
113
|
+
.then(function (resData) {
|
114
|
+
if (resData.errors) {
|
115
|
+
throw resData;
|
116
|
+
}
|
117
|
+
return callback(null, resData[0].data.profile_picture_set);
|
118
|
+
})
|
119
|
+
.catch(function (err) {
|
120
|
+
log.error("changeAvatar", err);
|
121
|
+
return callback(err);
|
122
|
+
});
|
123
|
+
});
|
124
|
+
|
125
|
+
return returnPromise;
|
126
|
+
};
|
127
|
+
};
|
@@ -0,0 +1,64 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
+
return function changeBio(bio, publish, 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
|
+
|
15
|
+
if (!callback) {
|
16
|
+
if (utils.getType(publish) == "Function" || utils.getType(publish) == "AsyncFunction") callback = publish;
|
17
|
+
else {
|
18
|
+
callback = function (err) {
|
19
|
+
if (err) return rejectFunc(err);
|
20
|
+
resolveFunc();
|
21
|
+
};
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
if (utils.getType(publish) != "Boolean") publish = false;
|
26
|
+
if (utils.getType(bio) != "String") {
|
27
|
+
bio = "";
|
28
|
+
publish = false;
|
29
|
+
}
|
30
|
+
|
31
|
+
var form = {
|
32
|
+
fb_api_caller_class: "RelayModern",
|
33
|
+
fb_api_req_friendly_name: "ProfileCometSetBioMutation",
|
34
|
+
// This doc_is is valid as of May 23, 2020
|
35
|
+
doc_id: "2725043627607610",
|
36
|
+
variables: JSON.stringify({
|
37
|
+
input: {
|
38
|
+
bio: bio,
|
39
|
+
publish_bio_feed_story: publish,
|
40
|
+
actor_id: ctx.userID,
|
41
|
+
client_mutation_id: Math.round(Math.random() * 1024).toString()
|
42
|
+
},
|
43
|
+
hasProfileTileViewID: false,
|
44
|
+
profileTileViewID: null,
|
45
|
+
scale: 1
|
46
|
+
}),
|
47
|
+
av: ctx.userID
|
48
|
+
};
|
49
|
+
|
50
|
+
defaultFuncs
|
51
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
52
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
53
|
+
.then(function (resData) {
|
54
|
+
if (resData.errors) throw resData;
|
55
|
+
return callback();
|
56
|
+
})
|
57
|
+
.catch(function (err) {
|
58
|
+
log.error("changeBio", err);
|
59
|
+
return callback(err);
|
60
|
+
});
|
61
|
+
|
62
|
+
return returnPromise;
|
63
|
+
};
|
64
|
+
};
|
@@ -0,0 +1,36 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
+
return function changeBlockedStatus(userID, block, 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
|
+
|
15
|
+
if (!callback) {
|
16
|
+
callback = function (err) {
|
17
|
+
if (err) return rejectFunc(err);
|
18
|
+
resolveFunc();
|
19
|
+
};
|
20
|
+
}
|
21
|
+
|
22
|
+
defaultFuncs
|
23
|
+
.post(`https://www.facebook.com/messaging/${block ? "" : "un"}block_messages/`, ctx.jar, { fbid: userID })
|
24
|
+
.then(utils.saveCookies(ctx.jar))
|
25
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
26
|
+
.then(function (resData) {
|
27
|
+
if (resData.error) throw resData;
|
28
|
+
return callback();
|
29
|
+
})
|
30
|
+
.catch(function (err) {
|
31
|
+
log.error("changeBlockedStatus", err);
|
32
|
+
return callback(err);
|
33
|
+
});
|
34
|
+
return returnPromise;
|
35
|
+
};
|
36
|
+
};
|
@@ -0,0 +1,105 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
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 handleUpload(image, callback) {
|
9
|
+
var uploads = [];
|
10
|
+
|
11
|
+
var form = {
|
12
|
+
images_only: "true",
|
13
|
+
"attachment[]": image
|
14
|
+
};
|
15
|
+
|
16
|
+
uploads.push(
|
17
|
+
defaultFuncs
|
18
|
+
.postFormData("https://upload.facebook.com/ajax/mercury/upload.php", ctx.jar, form, {})
|
19
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
20
|
+
.then(function (resData) {
|
21
|
+
if (resData.error) throw resData;
|
22
|
+
return resData.payload.metadata[0];
|
23
|
+
})
|
24
|
+
);
|
25
|
+
|
26
|
+
// resolve all promises
|
27
|
+
bluebird
|
28
|
+
.all(uploads)
|
29
|
+
.then(resData => callback(null, resData))
|
30
|
+
.catch(function (err) {
|
31
|
+
log.error("handleUpload", err);
|
32
|
+
return callback(err);
|
33
|
+
});
|
34
|
+
}
|
35
|
+
|
36
|
+
return function changeGroupImage(image, threadID, callback) {
|
37
|
+
if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
|
38
|
+
|
39
|
+
var resolveFunc = function () { };
|
40
|
+
var rejectFunc = function () { };
|
41
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
42
|
+
resolveFunc = resolve;
|
43
|
+
rejectFunc = reject;
|
44
|
+
});
|
45
|
+
|
46
|
+
if (!callback) {
|
47
|
+
callback = function (err) {
|
48
|
+
if (err) return rejectFunc(err);
|
49
|
+
resolveFunc();
|
50
|
+
};
|
51
|
+
}
|
52
|
+
|
53
|
+
var messageAndOTID = utils.generateOfflineThreadingID();
|
54
|
+
var form = {
|
55
|
+
client: "mercury",
|
56
|
+
action_type: "ma-type:log-message",
|
57
|
+
author: "fbid:" + ctx.userID,
|
58
|
+
author_email: "",
|
59
|
+
ephemeral_ttl_mode: "0",
|
60
|
+
is_filtered_content: false,
|
61
|
+
is_filtered_content_account: false,
|
62
|
+
is_filtered_content_bh: false,
|
63
|
+
is_filtered_content_invalid_app: false,
|
64
|
+
is_filtered_content_quasar: false,
|
65
|
+
is_forward: false,
|
66
|
+
is_spoof_warning: false,
|
67
|
+
is_unread: false,
|
68
|
+
log_message_type: "log:thread-image",
|
69
|
+
manual_retry_cnt: "0",
|
70
|
+
message_id: messageAndOTID,
|
71
|
+
offline_threading_id: messageAndOTID,
|
72
|
+
source: "source:chat:web",
|
73
|
+
"source_tags[0]": "source:chat",
|
74
|
+
status: "0",
|
75
|
+
thread_fbid: threadID,
|
76
|
+
thread_id: "",
|
77
|
+
timestamp: Date.now(),
|
78
|
+
timestamp_absolute: "Today",
|
79
|
+
timestamp_relative: utils.generateTimestampRelative(),
|
80
|
+
timestamp_time_passed: "0"
|
81
|
+
};
|
82
|
+
|
83
|
+
handleUpload(image, function (err, payload) {
|
84
|
+
if (err) return callback(err);
|
85
|
+
|
86
|
+
form["thread_image_id"] = payload[0]["image_id"];
|
87
|
+
form["thread_id"] = threadID;
|
88
|
+
|
89
|
+
defaultFuncs
|
90
|
+
.post("https://www.facebook.com/messaging/set_thread_image/", ctx.jar, form)
|
91
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
92
|
+
.then(function (resData) {
|
93
|
+
// check for errors here
|
94
|
+
if (resData.error) throw resData;
|
95
|
+
return callback();
|
96
|
+
})
|
97
|
+
.catch(function (err) {
|
98
|
+
log.error("changeGroupImage", err);
|
99
|
+
return callback(err);
|
100
|
+
});
|
101
|
+
});
|
102
|
+
|
103
|
+
return returnPromise;
|
104
|
+
};
|
105
|
+
};
|
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
+
return function changeNickname(nickname, threadID, participantID, 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) {
|
16
|
+
if (err) return rejectFunc(err);
|
17
|
+
resolveFunc();
|
18
|
+
};
|
19
|
+
}
|
20
|
+
|
21
|
+
var form = {
|
22
|
+
nickname: nickname,
|
23
|
+
participant_id: participantID,
|
24
|
+
thread_or_other_fbid: threadID
|
25
|
+
};
|
26
|
+
|
27
|
+
defaultFuncs
|
28
|
+
.post("https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1", ctx.jar, form)
|
29
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
30
|
+
.then(function (resData) {
|
31
|
+
if (resData.error === 1545014) throw { error: "Trying to change nickname of user isn't in thread" };
|
32
|
+
if (resData.error === 1357031) throw { error: "Trying to change user nickname of a thread that doesn't exist. Have at least one message in the thread before trying to change the user nickname." };
|
33
|
+
if (resData.error) throw resData;
|
34
|
+
return callback();
|
35
|
+
})
|
36
|
+
.catch(function (err) {
|
37
|
+
log.error("changeNickname", "Trying to change user nickname of a thread that doesn't exist. Have at least one message in the thread before trying to change the user nickname.");
|
38
|
+
return callback(err);
|
39
|
+
});
|
40
|
+
|
41
|
+
return returnPromise;
|
42
|
+
};
|
43
|
+
};
|
@@ -0,0 +1,61 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
+
return function changeThreadColor(color, threadID, 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
|
+
|
15
|
+
if (!callback) {
|
16
|
+
callback = function (err) {
|
17
|
+
if (err) return rejectFunc(err);
|
18
|
+
resolveFunc(err);
|
19
|
+
};
|
20
|
+
}
|
21
|
+
|
22
|
+
var validatedColor = color !== null ? color.toLowerCase() : color; // API only accepts lowercase letters in hex string
|
23
|
+
var colorList = Object.keys(api.threadColors).map(function (name) {
|
24
|
+
return api.threadColors[name];
|
25
|
+
});
|
26
|
+
if (!colorList.includes(validatedColor)) throw { error: "The color you are trying to use is not a valid thread color. Use api.threadColors to find acceptable values." };
|
27
|
+
|
28
|
+
var form = {
|
29
|
+
dpr: 1,
|
30
|
+
queries: JSON.stringify({
|
31
|
+
o0: {
|
32
|
+
//This doc_id is valid as of January 31, 2020
|
33
|
+
doc_id: "1727493033983591",
|
34
|
+
query_params: {
|
35
|
+
data: {
|
36
|
+
actor_id: ctx.userID,
|
37
|
+
client_mutation_id: "0",
|
38
|
+
source: "SETTINGS",
|
39
|
+
theme_id: validatedColor,
|
40
|
+
thread_id: threadID
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
})
|
45
|
+
};
|
46
|
+
|
47
|
+
defaultFuncs
|
48
|
+
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
49
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
50
|
+
.then(function (resData) {
|
51
|
+
if (resData[resData.length - 1].error_results > 0) throw resData[0].o0.errors;
|
52
|
+
return callback();
|
53
|
+
})
|
54
|
+
.catch(function (err) {
|
55
|
+
log.error("changeThreadColor", err);
|
56
|
+
return callback(err);
|
57
|
+
});
|
58
|
+
|
59
|
+
return returnPromise;
|
60
|
+
};
|
61
|
+
};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
+
return function changeThreadEmoji(emoji, threadID, 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
|
+
|
15
|
+
if (!callback) {
|
16
|
+
callback = function (err) {
|
17
|
+
if (err) return rejectFunc(err);
|
18
|
+
resolveFunc();
|
19
|
+
};
|
20
|
+
}
|
21
|
+
var form = {
|
22
|
+
emoji_choice: emoji,
|
23
|
+
thread_or_other_fbid: threadID
|
24
|
+
};
|
25
|
+
|
26
|
+
defaultFuncs
|
27
|
+
.post("https://www.facebook.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg", ctx.jar, form)
|
28
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
29
|
+
.then(function (resData) {
|
30
|
+
if (resData.error === 1357031) throw { error: "Trying to change emoji of a chat that doesn't exist. Have at least one message in the thread before trying to change the emoji." };
|
31
|
+
if (resData.error) throw resData;
|
32
|
+
return callback();
|
33
|
+
})
|
34
|
+
.catch(function (err) {
|
35
|
+
log.error("changeThreadEmoji", err);
|
36
|
+
return callback(err);
|
37
|
+
});
|
38
|
+
|
39
|
+
return returnPromise;
|
40
|
+
};
|
41
|
+
};
|