alicezetion 1.8.3 → 1.8.4
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/nix/env.json +1 -1
- package/index.js +210 -375
- package/package.json +6 -3
- package/replit.nix +4 -4
- package/src/addExternalModule.js +17 -0
- package/src/addUserToGroup.js +113 -0
- package/src/changeAdminStatus.js +79 -0
- package/src/changeArchivedStatus.js +55 -0
- package/src/changeAvatar.js +93 -0
- package/src/changeBio.js +77 -0
- package/src/changeBlockedStatus.js +47 -0
- package/src/changeCover.js +73 -0
- package/src/changeGroupImage.js +132 -0
- package/src/changeName.js +79 -0
- package/src/changeNickname.js +59 -0
- package/src/changeThreadColor.js +65 -0
- package/src/changeThreadEmoji.js +55 -0
- package/{leiamnash → src}/chat.js +28 -3
- package/src/createNewGroup.js +86 -0
- package/src/createPoll.js +71 -0
- package/src/data/getThreadInfo.json +1 -0
- package/src/deleteMessage.js +56 -0
- package/src/deleteThread.js +56 -0
- package/src/forwardAttachment.js +60 -0
- package/src/getAccess.js +112 -0
- package/src/getAvatarUser.js +78 -0
- package/src/getCurrentUserID.js +7 -0
- package/src/getEmojiUrl.js +29 -0
- package/src/getFriendsList.js +83 -0
- package/src/getThreadHistory.js +666 -0
- package/{leiamnash → src}/getThreadInfo.js +70 -54
- package/src/getThreadList.js +237 -0
- package/src/getThreadPictures.js +79 -0
- package/src/getUserID.js +66 -0
- package/src/getUserInfo.js +163 -0
- package/src/handleFriendRequest.js +61 -0
- package/src/handleMessageRequest.js +65 -0
- package/src/httpGet.js +57 -0
- package/src/httpPost.js +57 -0
- package/src/httpPostFormData.js +63 -0
- package/{leiamnash → src}/listenMqtt.js +16 -6
- package/src/listenNotification.js +88 -0
- package/src/logout.js +275 -0
- package/src/markAsDelivered.js +58 -0
- package/src/markAsRead.js +80 -0
- package/src/markAsReadAll.js +50 -0
- package/src/markAsSeen.js +59 -0
- package/src/muteThread.js +52 -0
- package/src/react.js +117 -0
- package/{leiamnash → src}/refreshFb_dtsg.js +1 -1
- package/src/removeUserFromGroup.js +79 -0
- package/src/resolvePhotoUrl.js +45 -0
- package/src/searchForThread.js +53 -0
- package/src/searchStickers.js +52 -0
- package/src/seen.js +50 -0
- package/src/sendMessage.js +477 -0
- package/src/sendMessageMqtt.js +316 -0
- package/src/sendTypingIndicator.js +103 -0
- package/src/setMessageReaction.js +117 -0
- package/src/setPostReaction.js +109 -0
- package/src/setTitle.js +86 -0
- package/src/threadColors.js +131 -0
- package/src/unfriend.js +52 -0
- package/src/unsendMessage.js +49 -0
- package/utils.js +135 -176
- package/.cache/replit/modules.stamp +0 -1
- package/leiamnash/addExternalModule.js +0 -15
- package/leiamnash/addUserToGroup.js +0 -77
- package/leiamnash/changeAdminStatus.js +0 -47
- package/leiamnash/changeArchivedStatus.js +0 -41
- package/leiamnash/changeAvatar.js +0 -127
- package/leiamnash/changeBio.js +0 -64
- package/leiamnash/changeBlockedStatus.js +0 -36
- package/leiamnash/changeGroupImage.js +0 -105
- package/leiamnash/changeNickname.js +0 -43
- package/leiamnash/changeThreadColor.js +0 -61
- package/leiamnash/changeThreadEmoji.js +0 -41
- package/leiamnash/createNewGroup.js +0 -70
- package/leiamnash/createPoll.js +0 -59
- package/leiamnash/deleteMessage.js +0 -44
- package/leiamnash/deleteThread.js +0 -42
- package/leiamnash/forwardAttachment.js +0 -47
- package/leiamnash/forwardMessage.js +0 -0
- package/leiamnash/getCurrentUserID.js +0 -7
- package/leiamnash/getEmojiUrl.js +0 -27
- package/leiamnash/getFriendsList.js +0 -73
- package/leiamnash/getInfoVideo.js +0 -134
- package/leiamnash/getThreadHistory.js +0 -537
- package/leiamnash/getThreadHistoryDeprecated.js +0 -71
- package/leiamnash/getThreadInfoDeprecated.js +0 -56
- package/leiamnash/getThreadList.js +0 -213
- package/leiamnash/getThreadListDeprecated.js +0 -46
- package/leiamnash/getThreadPictures.js +0 -59
- package/leiamnash/getUserID.js +0 -61
- package/leiamnash/getUserInfo.js +0 -66
- package/leiamnash/handleFriendRequest.js +0 -46
- package/leiamnash/handleMessageRequest.js +0 -47
- package/leiamnash/httpGet.js +0 -47
- package/leiamnash/httpPost.js +0 -47
- package/leiamnash/httpPostFormData.js +0 -42
- package/leiamnash/logout.js +0 -68
- package/leiamnash/markAsDelivered.js +0 -47
- package/leiamnash/markAsRead.js +0 -70
- package/leiamnash/markAsReadAll.js +0 -40
- package/leiamnash/markAsSeen.js +0 -48
- package/leiamnash/muteThread.js +0 -45
- package/leiamnash/react.js +0 -109
- package/leiamnash/removeUserFromGroup.js +0 -45
- package/leiamnash/resolvePhotoUrl.js +0 -36
- package/leiamnash/searchForThread.js +0 -42
- package/leiamnash/seen.js +0 -40
- package/leiamnash/sendMessage.js +0 -315
- package/leiamnash/sendTypingIndicator.js +0 -70
- package/leiamnash/setMessageReaction.js +0 -103
- package/leiamnash/setPostReaction.js +0 -63
- package/leiamnash/setTitle.js +0 -70
- package/leiamnash/threadColors.js +0 -41
- package/leiamnash/unfriend.js +0 -42
- package/leiamnash/unsendMessage.js +0 -39
- package/leiamnash/uploadAttachment.js +0 -96
- /package/{leiamnash → src}/getMessage.js +0 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "alicezetion",
|
3
|
-
"version": "1.8.
|
3
|
+
"version": "1.8.4",
|
4
4
|
"description": "",
|
5
5
|
"scripts": {
|
6
6
|
"start": "node index.js"
|
@@ -19,12 +19,15 @@
|
|
19
19
|
"author": "LeiamNash",
|
20
20
|
"license": "MIT",
|
21
21
|
"dependencies": {
|
22
|
-
"bluebird": "^
|
22
|
+
"bluebird": "^3.7.2",
|
23
23
|
"cheerio": "^1.0.0-rc.12",
|
24
|
-
"https-proxy-agent": "^
|
24
|
+
"https-proxy-agent": "^7.0.2",
|
25
25
|
"mqtt": "^4.3.7",
|
26
26
|
"npmlog": "^7.0.1",
|
27
|
+
"querystring": "^0.2.1",
|
27
28
|
"request": "^2.88.2",
|
29
|
+
"stream": "^0.0.2",
|
30
|
+
"url": "^0.11.3",
|
28
31
|
"websocket-stream": "^5.5.2"
|
29
32
|
}
|
30
33
|
}
|
package/replit.nix
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var utils = require('../utils');
|
4
|
+
|
5
|
+
module.exports = function (http, api, ctx) {
|
6
|
+
return function addExternalModule(moduleObj) {
|
7
|
+
if (utils.getType(moduleObj) == 'Object') {
|
8
|
+
for (let name in moduleObj) {
|
9
|
+
if (utils.getType(moduleObj[name]) == 'Function')
|
10
|
+
api[name] = moduleObj[name](http, api, ctx);
|
11
|
+
else
|
12
|
+
throw new Error(`Item "${name}" in moduleObj must be a function, not ${utils.getType(moduleObj[name])}!`);
|
13
|
+
}
|
14
|
+
} else
|
15
|
+
throw new Error(`moduleObj must be an object, not ` + utils.getType(moduleObj) + `!`);
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,113 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const utils = require("../utils");
|
4
|
+
const log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
+
return function addUserToGroup(userID, threadID, callback) {
|
8
|
+
let resolveFunc = function () { };
|
9
|
+
let rejectFunc = function () { };
|
10
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
11
|
+
resolveFunc = resolve;
|
12
|
+
rejectFunc = reject;
|
13
|
+
});
|
14
|
+
|
15
|
+
if (
|
16
|
+
!callback &&
|
17
|
+
(utils.getType(threadID) === "Function" ||
|
18
|
+
utils.getType(threadID) === "AsyncFunction")
|
19
|
+
) {
|
20
|
+
throw new utils.CustomError({ error: "please pass a threadID as a second argument." });
|
21
|
+
}
|
22
|
+
|
23
|
+
if (!callback) {
|
24
|
+
callback = function (err) {
|
25
|
+
if (err) {
|
26
|
+
return rejectFunc(err);
|
27
|
+
}
|
28
|
+
resolveFunc();
|
29
|
+
};
|
30
|
+
}
|
31
|
+
|
32
|
+
if (
|
33
|
+
utils.getType(threadID) !== "Number" &&
|
34
|
+
utils.getType(threadID) !== "String"
|
35
|
+
) {
|
36
|
+
throw new utils.CustomError({
|
37
|
+
error:
|
38
|
+
"ThreadID should be of type Number or String and not " +
|
39
|
+
utils.getType(threadID) +
|
40
|
+
"."
|
41
|
+
});
|
42
|
+
}
|
43
|
+
|
44
|
+
if (utils.getType(userID) !== "Array") {
|
45
|
+
userID = [userID];
|
46
|
+
}
|
47
|
+
|
48
|
+
const messageAndOTID = utils.generateOfflineThreadingID();
|
49
|
+
const form = {
|
50
|
+
client: "mercury",
|
51
|
+
action_type: "ma-type:log-message",
|
52
|
+
author: "fbid:" + (ctx.i_userID || ctx.userID),
|
53
|
+
thread_id: "",
|
54
|
+
timestamp: Date.now(),
|
55
|
+
timestamp_absolute: "Today",
|
56
|
+
timestamp_relative: utils.generateTimestampRelative(),
|
57
|
+
timestamp_time_passed: "0",
|
58
|
+
is_unread: false,
|
59
|
+
is_cleared: false,
|
60
|
+
is_forward: false,
|
61
|
+
is_filtered_content: false,
|
62
|
+
is_filtered_content_bh: false,
|
63
|
+
is_filtered_content_account: false,
|
64
|
+
is_spoof_warning: false,
|
65
|
+
source: "source:chat:web",
|
66
|
+
"source_tags[0]": "source:chat",
|
67
|
+
log_message_type: "log:subscribe",
|
68
|
+
status: "0",
|
69
|
+
offline_threading_id: messageAndOTID,
|
70
|
+
message_id: messageAndOTID,
|
71
|
+
threading_id: utils.generateThreadingID(ctx.clientID),
|
72
|
+
manual_retry_cnt: "0",
|
73
|
+
thread_fbid: threadID
|
74
|
+
};
|
75
|
+
|
76
|
+
for (let i = 0; i < userID.length; i++) {
|
77
|
+
if (
|
78
|
+
utils.getType(userID[i]) !== "Number" &&
|
79
|
+
utils.getType(userID[i]) !== "String"
|
80
|
+
) {
|
81
|
+
throw new utils.CustomError({
|
82
|
+
error:
|
83
|
+
"Elements of userID should be of type Number or String and not " +
|
84
|
+
utils.getType(userID[i]) +
|
85
|
+
"."
|
86
|
+
});
|
87
|
+
}
|
88
|
+
|
89
|
+
form["log_message_data[added_participants][" + i + "]"] =
|
90
|
+
"fbid:" + userID[i];
|
91
|
+
}
|
92
|
+
|
93
|
+
defaultFuncs
|
94
|
+
.post("https://www.facebook.com/messaging/send/", ctx.jar, form)
|
95
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
96
|
+
.then(function (resData) {
|
97
|
+
if (!resData) {
|
98
|
+
throw new utils.CustomError({ error: "Add to group failed." });
|
99
|
+
}
|
100
|
+
if (resData.error) {
|
101
|
+
throw new utils.CustomError(resData);
|
102
|
+
}
|
103
|
+
|
104
|
+
return callback();
|
105
|
+
})
|
106
|
+
.catch(function (err) {
|
107
|
+
log.error("addUserToGroup", err);
|
108
|
+
return callback(err);
|
109
|
+
});
|
110
|
+
|
111
|
+
return returnPromise;
|
112
|
+
};
|
113
|
+
};
|
@@ -0,0 +1,79 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const utils = require("../utils");
|
4
|
+
const log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
+
return function changeAdminStatus(threadID, adminIDs, adminStatus, callback) {
|
8
|
+
if (utils.getType(threadID) !== "String") {
|
9
|
+
throw new utils.CustomError({ error: "changeAdminStatus: threadID must be a string" });
|
10
|
+
}
|
11
|
+
|
12
|
+
if (utils.getType(adminIDs) === "String") {
|
13
|
+
adminIDs = [adminIDs];
|
14
|
+
}
|
15
|
+
|
16
|
+
if (utils.getType(adminIDs) !== "Array") {
|
17
|
+
throw new utils.CustomError({ error: "changeAdminStatus: adminIDs must be an array or string" });
|
18
|
+
}
|
19
|
+
|
20
|
+
if (utils.getType(adminStatus) !== "Boolean") {
|
21
|
+
throw new utils.CustomError({ error: "changeAdminStatus: adminStatus must be a string" });
|
22
|
+
}
|
23
|
+
|
24
|
+
let resolveFunc = function () { };
|
25
|
+
let rejectFunc = function () { };
|
26
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
27
|
+
resolveFunc = resolve;
|
28
|
+
rejectFunc = reject;
|
29
|
+
});
|
30
|
+
|
31
|
+
if (!callback) {
|
32
|
+
callback = function (err) {
|
33
|
+
if (err) {
|
34
|
+
return rejectFunc(err);
|
35
|
+
}
|
36
|
+
resolveFunc();
|
37
|
+
};
|
38
|
+
}
|
39
|
+
|
40
|
+
if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
|
41
|
+
throw new utils.CustomError({ error: "changeAdminStatus: callback is not a function" });
|
42
|
+
}
|
43
|
+
|
44
|
+
const form = {
|
45
|
+
"thread_fbid": threadID
|
46
|
+
};
|
47
|
+
|
48
|
+
let i = 0;
|
49
|
+
for (const u of adminIDs) {
|
50
|
+
form[`admin_ids[${i++}]`] = u;
|
51
|
+
}
|
52
|
+
form["add"] = adminStatus;
|
53
|
+
|
54
|
+
defaultFuncs
|
55
|
+
.post("https://www.facebook.com/messaging/save_admins/?dpr=1", ctx.jar, form)
|
56
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
57
|
+
.then(function (resData) {
|
58
|
+
if (resData.error) {
|
59
|
+
switch (resData.error) {
|
60
|
+
case 1976004:
|
61
|
+
throw new utils.CustomError({ error: "Cannot alter admin status: you are not an admin.", rawResponse: resData });
|
62
|
+
case 1357031:
|
63
|
+
throw new utils.CustomError({ error: "Cannot alter admin status: this thread is not a group chat.", rawResponse: resData });
|
64
|
+
default:
|
65
|
+
throw new utils.CustomError({ error: "Cannot alter admin status: unknown error.", rawResponse: resData });
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
callback();
|
70
|
+
})
|
71
|
+
.catch(function (err) {
|
72
|
+
log.error("changeAdminStatus", err);
|
73
|
+
return callback(err);
|
74
|
+
});
|
75
|
+
|
76
|
+
return returnPromise;
|
77
|
+
};
|
78
|
+
};
|
79
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const utils = require("../utils");
|
4
|
+
const log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
+
return function changeArchivedStatus(threadOrThreads, archive, callback) {
|
8
|
+
let resolveFunc = function () { };
|
9
|
+
let rejectFunc = function () { };
|
10
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
11
|
+
resolveFunc = resolve;
|
12
|
+
rejectFunc = reject;
|
13
|
+
});
|
14
|
+
|
15
|
+
if (!callback) {
|
16
|
+
callback = function (err) {
|
17
|
+
if (err) {
|
18
|
+
return rejectFunc(err);
|
19
|
+
}
|
20
|
+
resolveFunc();
|
21
|
+
};
|
22
|
+
}
|
23
|
+
|
24
|
+
const form = {};
|
25
|
+
|
26
|
+
if (utils.getType(threadOrThreads) === "Array") {
|
27
|
+
for (let i = 0; i < threadOrThreads.length; i++) {
|
28
|
+
form["ids[" + threadOrThreads[i] + "]"] = archive;
|
29
|
+
}
|
30
|
+
} else {
|
31
|
+
form["ids[" + threadOrThreads + "]"] = archive;
|
32
|
+
}
|
33
|
+
|
34
|
+
defaultFuncs
|
35
|
+
.post(
|
36
|
+
"https://www.facebook.com/ajax/mercury/change_archived_status.php",
|
37
|
+
ctx.jar,
|
38
|
+
form
|
39
|
+
)
|
40
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
41
|
+
.then(function (resData) {
|
42
|
+
if (resData.error) {
|
43
|
+
throw resData;
|
44
|
+
}
|
45
|
+
|
46
|
+
return callback();
|
47
|
+
})
|
48
|
+
.catch(function (err) {
|
49
|
+
log.error("changeArchivedStatus", err);
|
50
|
+
return callback(err);
|
51
|
+
});
|
52
|
+
|
53
|
+
return returnPromise;
|
54
|
+
};
|
55
|
+
};
|
@@ -0,0 +1,93 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var utils = require('../utils');
|
4
|
+
var log = require('npmlog');
|
5
|
+
|
6
|
+
module.exports = function (http, api, ctx) {
|
7
|
+
return function changeAvatar(image, caption = '', timestamp = null, callback) {
|
8
|
+
var cb;
|
9
|
+
var rt = new Promise(function (resolve, reject) {
|
10
|
+
cb = (error, url) => error ? reject(error) : resolve(url);
|
11
|
+
});
|
12
|
+
|
13
|
+
if (typeof image == 'function') {
|
14
|
+
callback = image;
|
15
|
+
image = null;
|
16
|
+
}
|
17
|
+
if (typeof caption == 'function') {
|
18
|
+
callback = caption;
|
19
|
+
caption = '';
|
20
|
+
}
|
21
|
+
if (typeof caption == 'number') {
|
22
|
+
timestamp = caption;
|
23
|
+
caption = '';
|
24
|
+
}
|
25
|
+
if (typeof timestamp == 'function') {
|
26
|
+
callback = timestamp;
|
27
|
+
timestamp = null;
|
28
|
+
}
|
29
|
+
if (typeof callback == 'function') cb = callback;
|
30
|
+
|
31
|
+
if (!utils.isReadableStream(image)) {
|
32
|
+
var error = 'image should be a readable stream, not ' + utils.getType(image);
|
33
|
+
log.error('changeAvatar', error);
|
34
|
+
cb(error);
|
35
|
+
} else {
|
36
|
+
http
|
37
|
+
.postFormData('https://www.facebook.com/profile/picture/upload/', ctx.jar, {
|
38
|
+
profile_id: ctx.userID,
|
39
|
+
photo_source: 57,
|
40
|
+
av: ctx.userID,
|
41
|
+
file: image
|
42
|
+
})
|
43
|
+
.then(utils.parseAndCheckLogin(ctx, http))
|
44
|
+
.then(function (res) {
|
45
|
+
if (res.error || res.errors || !res.payload)
|
46
|
+
throw res;
|
47
|
+
|
48
|
+
var vari = {
|
49
|
+
input: {
|
50
|
+
caption,
|
51
|
+
existing_photo_id: res.payload.fbid,
|
52
|
+
expiration_time: timestamp,
|
53
|
+
profile_id: ctx.userID,
|
54
|
+
profile_pic_method: "EXISTING",
|
55
|
+
profile_pic_source: "TIMELINE",
|
56
|
+
scaled_crop_rect: {
|
57
|
+
height: 1,
|
58
|
+
width: 1,
|
59
|
+
x: 0,
|
60
|
+
y: 0
|
61
|
+
},
|
62
|
+
skip_cropping: true,
|
63
|
+
actor_id: ctx.userID,
|
64
|
+
client_mutation_id: Math.round(Math.random() * 19).toString()
|
65
|
+
},
|
66
|
+
isPage: false,
|
67
|
+
isProfile: true,
|
68
|
+
scale: 3
|
69
|
+
}
|
70
|
+
return http
|
71
|
+
.post('https://www.facebook.com/api/graphql', ctx.jar, {
|
72
|
+
doc_id: 5066134240065849,
|
73
|
+
server_timestamps: true,
|
74
|
+
fb_api_req_friendly_name: 'ProfileCometProfilePictureSetMutation',
|
75
|
+
variables: JSON.stringify(vari)
|
76
|
+
})
|
77
|
+
.then(utils.parseAndCheckLogin(ctx, http));
|
78
|
+
})
|
79
|
+
.then(function (res) {
|
80
|
+
if (res.errors)
|
81
|
+
throw res;
|
82
|
+
|
83
|
+
return cb(null, (res[0] || res).data.profile_picture_set.profile);
|
84
|
+
})
|
85
|
+
.catch(function (err) {
|
86
|
+
log.error('changeAvatar', err);
|
87
|
+
return cb(err);
|
88
|
+
});
|
89
|
+
}
|
90
|
+
|
91
|
+
return rt;
|
92
|
+
}
|
93
|
+
}
|
package/src/changeBio.js
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const utils = require("../utils");
|
4
|
+
const log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
+
return function changeBio(bio, publish, callback) {
|
8
|
+
let resolveFunc = function () { };
|
9
|
+
let rejectFunc = function () { };
|
10
|
+
const 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") {
|
17
|
+
callback = publish;
|
18
|
+
} else {
|
19
|
+
callback = function (err) {
|
20
|
+
if (err) {
|
21
|
+
return rejectFunc(err);
|
22
|
+
}
|
23
|
+
resolveFunc();
|
24
|
+
};
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
if (utils.getType(publish) != "Boolean") {
|
29
|
+
publish = false;
|
30
|
+
}
|
31
|
+
|
32
|
+
if (utils.getType(bio) != "String") {
|
33
|
+
bio = "";
|
34
|
+
publish = false;
|
35
|
+
}
|
36
|
+
|
37
|
+
const form = {
|
38
|
+
fb_api_caller_class: "RelayModern",
|
39
|
+
fb_api_req_friendly_name: "ProfileCometSetBioMutation",
|
40
|
+
// This doc_is is valid as of May 23, 2020
|
41
|
+
doc_id: "2725043627607610",
|
42
|
+
variables: JSON.stringify({
|
43
|
+
input: {
|
44
|
+
bio: bio,
|
45
|
+
publish_bio_feed_story: publish,
|
46
|
+
actor_id: ctx.i_userID || ctx.userID,
|
47
|
+
client_mutation_id: Math.round(Math.random() * 1024).toString()
|
48
|
+
},
|
49
|
+
hasProfileTileViewID: false,
|
50
|
+
profileTileViewID: null,
|
51
|
+
scale: 1
|
52
|
+
}),
|
53
|
+
av: ctx.i_userID || ctx.userID
|
54
|
+
};
|
55
|
+
|
56
|
+
defaultFuncs
|
57
|
+
.post(
|
58
|
+
"https://www.facebook.com/api/graphql/",
|
59
|
+
ctx.jar,
|
60
|
+
form
|
61
|
+
)
|
62
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
63
|
+
.then(function (resData) {
|
64
|
+
if (resData.errors) {
|
65
|
+
throw resData;
|
66
|
+
}
|
67
|
+
|
68
|
+
return callback();
|
69
|
+
})
|
70
|
+
.catch(function (err) {
|
71
|
+
log.error("changeBio", err);
|
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
|
+
const log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
+
return function changeBlockedStatus(userID, block, callback) {
|
8
|
+
let resolveFunc = function () { };
|
9
|
+
let rejectFunc = function () { };
|
10
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
11
|
+
resolveFunc = resolve;
|
12
|
+
rejectFunc = reject;
|
13
|
+
});
|
14
|
+
|
15
|
+
if (!callback) {
|
16
|
+
callback = function (err) {
|
17
|
+
if (err) {
|
18
|
+
return rejectFunc(err);
|
19
|
+
}
|
20
|
+
resolveFunc();
|
21
|
+
};
|
22
|
+
}
|
23
|
+
|
24
|
+
defaultFuncs
|
25
|
+
.post(
|
26
|
+
`https://www.facebook.com/messaging/${block ? "" : "un"}block_messages/`,
|
27
|
+
ctx.jar,
|
28
|
+
{
|
29
|
+
fbid: userID
|
30
|
+
}
|
31
|
+
)
|
32
|
+
.then(utils.saveCookies(ctx.jar))
|
33
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
34
|
+
.then(function (resData) {
|
35
|
+
if (resData.error) {
|
36
|
+
throw resData;
|
37
|
+
}
|
38
|
+
|
39
|
+
return callback();
|
40
|
+
})
|
41
|
+
.catch(function (err) {
|
42
|
+
log.error("changeBlockedStatus", err);
|
43
|
+
return callback(err);
|
44
|
+
});
|
45
|
+
return returnPromise;
|
46
|
+
};
|
47
|
+
};
|
@@ -0,0 +1,73 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var utils = require('../utils.js');
|
4
|
+
var log = require('npmlog');
|
5
|
+
|
6
|
+
module.exports = function (http, api, ctx) {
|
7
|
+
return function changeCover(image, callback) {
|
8
|
+
var cb;
|
9
|
+
var rt = new Promise(function (resolve, reject) {
|
10
|
+
cb = (error, url) => error ? reject(error) : resolve(url);
|
11
|
+
});
|
12
|
+
|
13
|
+
if (typeof image == 'function') {
|
14
|
+
callback = image;
|
15
|
+
image = null;
|
16
|
+
}
|
17
|
+
if (typeof callback == 'function') cb = callback;
|
18
|
+
if (!utils.isReadableStream(image)) {
|
19
|
+
var error = 'image should be a readable stream, not ' + utils.getType(image);
|
20
|
+
log.error('changeCover', error);
|
21
|
+
cb(error);
|
22
|
+
}
|
23
|
+
else {
|
24
|
+
http
|
25
|
+
.postFormData('https://www.facebook.com/profile/picture/upload/', ctx.jar, {
|
26
|
+
profile_id: ctx.userID,
|
27
|
+
photo_source: 57,
|
28
|
+
av: ctx.userID,
|
29
|
+
file: image
|
30
|
+
})
|
31
|
+
.then(utils.parseAndCheckLogin(ctx, http))
|
32
|
+
.then(function (res) {
|
33
|
+
if (res.error || res.errors || !res.payload)
|
34
|
+
throw res;
|
35
|
+
|
36
|
+
var vari = {
|
37
|
+
input: {
|
38
|
+
attribution_id_v2: `ProfileCometCollectionRoot.react,comet.profile.collection.photos_by,unexpected,${Date.now()},770083,,;ProfileCometCollectionRoot.react,comet.profile.collection.photos_albums,unexpected,${Date.now()},470774,,;ProfileCometCollectionRoot.react,comet.profile.collection.photos,unexpected,${Date.now()},94740,,;ProfileCometCollectionRoot.react,comet.profile.collection.saved_reels_on_profile,unexpected,${Date.now()},89669,,;ProfileCometCollectionRoot.react,comet.profile.collection.reels_tab,unexpected,${Date.now()},152201,,`,
|
39
|
+
cover_photo_id: res.payload.fbid,
|
40
|
+
focus: {
|
41
|
+
x: 0.5,
|
42
|
+
y: 1
|
43
|
+
},
|
44
|
+
target_user_id: ctx.userID,
|
45
|
+
actor_id: ctx.userID,
|
46
|
+
client_mutation_id: Math.round(Math.random() * 19).toString()
|
47
|
+
},
|
48
|
+
scale: 1,
|
49
|
+
contextualProfileContext: null
|
50
|
+
}
|
51
|
+
return http
|
52
|
+
.post('https://www.facebook.com/api/graphql', ctx.jar, {
|
53
|
+
doc_id: 8247793861913071,
|
54
|
+
server_timestamps: true,
|
55
|
+
fb_api_req_friendly_name: 'ProfileCometCoverPhotoUpdateMutation',
|
56
|
+
variables: JSON.stringify(vari)
|
57
|
+
})
|
58
|
+
.then(utils.parseAndCheckLogin(ctx, http));
|
59
|
+
})
|
60
|
+
.then(function (res) {
|
61
|
+
if (res.errors)
|
62
|
+
throw res;
|
63
|
+
return cb(null, res.data.user_update_cover_photo.user.cover_photo.photo.url);
|
64
|
+
})
|
65
|
+
.catch(function (err) {
|
66
|
+
log.error('changeCover', err);
|
67
|
+
return cb(err);
|
68
|
+
});
|
69
|
+
}
|
70
|
+
|
71
|
+
return rt;
|
72
|
+
}
|
73
|
+
}
|