alicezetion 1.7.1 → 1.7.2
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/Extra/Database/index.js +399 -0
- package/Extra/Database/methods.js +286 -0
- package/Extra/ExtraAddons.js +213 -0
- package/Extra/ExtraGetThread.js +1 -0
- package/Extra/ExtraUptimeRobot.js +59 -0
- package/Extra/PM2/ecosystem.config.js +23 -0
- package/Extra/Src/Last-Run.js +48 -0
- package/Language/index.json +151 -0
- package/StateCrypt.js +22 -0
- package/broadcast.js +42 -0
- package/index.js +654 -119
- package/logger.js +21 -0
- package/package.json +37 -25
- package/replit.nix +3 -4
- package/src/addExternalModule.js +13 -5
- package/src/addUserToGroup.js +36 -12
- package/src/changeAdminStatus.js +85 -37
- package/src/changeArchivedStatus.js +15 -9
- package/src/changeAvt.js +91 -0
- package/src/changeBio.js +13 -8
- package/src/changeBlockedStatus.js +14 -8
- package/src/changeGroupImage.js +28 -13
- package/src/changeNickname.js +22 -11
- package/src/changeThreadColor.js +16 -10
- package/src/changeThreadEmoji.js +18 -9
- package/src/chat.js +401 -280
- package/src/createNewGroup.js +18 -10
- package/src/createPoll.js +17 -11
- package/src/deleteMessage.js +17 -10
- package/src/deleteThread.js +17 -10
- package/src/forwardAttachment.js +15 -9
- package/src/getAccessToken.js +32 -0
- package/src/getCurrentUserID.js +1 -1
- package/src/getEmojiUrl.js +3 -2
- package/src/getFriendsList.js +18 -10
- package/src/getMessage.js +84 -0
- package/src/getThreadHistory.js +156 -59
- package/src/getThreadHistoryDeprecated.js +26 -15
- package/src/getThreadInfo.js +68 -42
- package/src/getThreadInfoDeprecated.js +25 -13
- package/src/getThreadList.js +112 -53
- package/src/getThreadListDeprecated.js +30 -12
- package/src/getThreadPictures.js +25 -13
- package/src/getUserID.js +9 -7
- package/src/getUserInfo.js +12 -10
- package/src/getUserInfoV2.js +35 -0
- package/src/handleFriendRequest.js +36 -35
- package/src/handleMessageRequest.js +18 -10
- package/src/httpGet.js +20 -13
- package/src/httpPost.js +19 -13
- package/src/httpPostFormData.js +46 -0
- package/src/listenMqtt.js +1224 -621
- package/src/logout.js +18 -13
- package/src/markAsDelivered.js +17 -10
- package/src/markAsRead.js +36 -24
- package/src/markAsSeen.js +22 -12
- package/src/muteThread.js +15 -9
- package/src/{setMessageReaction.js → react.js} +20 -9
- package/src/removeUserFromGroup.js +38 -11
- package/src/resolvePhotoUrl.js +9 -6
- package/src/searchForThread.js +14 -8
- package/src/{markAsReadAll.js → seen.js} +17 -10
- package/src/sendTypingIndicator.js +44 -19
- package/src/setPostReaction.js +63 -22
- package/src/setTitle.js +22 -12
- package/src/threadColors.js +17 -19
- package/src/unfriend.js +15 -9
- package/src/{unsendMessage.js → unsend.js} +9 -8
- package/utils.js +120 -27
- package/.travis.yml +0 -6
- package/src/forwardMessage.js +0 -0
- package/src/listen.js +0 -553
- package/src/listenMqtt-Test.js +0 -687
- package/src/sendMessage.js +0 -315
- package/test/data/shareAttach.js +0 -146
- package/test/data/something.mov +0 -0
- package/test/data/test.png +0 -0
- package/test/data/test.txt +0 -7
- package/test/example-config.json +0 -18
- package/test/test-page.js +0 -140
- package/test/test.js +0 -385
package/logger.js
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
/* eslint-disable linebreak-style */
|
2
|
+
|
3
|
+
const chalk = require('chalk');
|
4
|
+
var log = require("npmlog");
|
5
|
+
var isHexcolor = require('is-hexcolor');
|
6
|
+
var getText = require('gettext.js')();
|
7
|
+
const languageFile = require('./Language/index.json');
|
8
|
+
|
9
|
+
module.exports = (str, end) => {
|
10
|
+
if (isHexcolor(require("../../FastConfigFca.json").MainColor || "#00CCCC") != true) {
|
11
|
+
var Language = languageFile.find(i => i.Language == require("../../FastConfigFca.json").Language).Folder.Index;
|
12
|
+
log.warn("FastConfig-MainColor", getText.gettext(Language.InvaildMainColor,require("../../FastConfigFca.json").MainColor));
|
13
|
+
process.exit(0);
|
14
|
+
}
|
15
|
+
console.log(chalk.hex(require("../../FastConfigFca.json").MainColor || "00CCCC").bold(`${end || '[ ALICIZATION ]'} > `) + str);
|
16
|
+
};
|
17
|
+
|
18
|
+
module.exports.onLogger = (str,end) => console.log(chalk.hex('#00CCCC').bold(`${end || '[ FCA-SUS ]'} > `) + str);
|
19
|
+
|
20
|
+
module.exports.Error = () => console.log(chalk.bold.red('There was an error, Please Contact: Facebook.com/Lazic.Kanzu'));
|
21
|
+
|
package/package.json
CHANGED
@@ -1,46 +1,60 @@
|
|
1
1
|
{
|
2
2
|
"name": "alicezetion",
|
3
|
-
"version": "1.7.
|
3
|
+
"version": "1.7.2",
|
4
4
|
"description": "",
|
5
5
|
"scripts": {
|
6
6
|
"test": "mocha",
|
7
|
-
"lint": "
|
7
|
+
"lint": "eslint **.js",
|
8
8
|
"prettier": "prettier utils.js src/* --write"
|
9
9
|
},
|
10
10
|
"repository": {
|
11
11
|
"type": "git",
|
12
|
-
"url": "
|
12
|
+
"url": ""
|
13
13
|
},
|
14
14
|
"keywords": [
|
15
|
-
"
|
16
|
-
"
|
15
|
+
"alice",
|
16
|
+
"leiamnash"
|
17
17
|
],
|
18
18
|
"bugs": {
|
19
19
|
"url": ""
|
20
20
|
},
|
21
|
-
"author": "
|
21
|
+
"author": "leiamnash",
|
22
22
|
"license": "MIT",
|
23
23
|
"dependencies": {
|
24
|
+
"@replit/database": "latest",
|
25
|
+
"aes-js": "latest",
|
26
|
+
"assert": "latest",
|
27
|
+
"better-sqlite3": "latest",
|
24
28
|
"bluebird": "^2.11.0",
|
25
|
-
"
|
26
|
-
"
|
27
|
-
"
|
28
|
-
"
|
29
|
-
"
|
30
|
-
"
|
29
|
+
"chalk": "^4.1.2",
|
30
|
+
"cheerio": "latest",
|
31
|
+
"crypto": "latest",
|
32
|
+
"gettext.js": "^1.1.1",
|
33
|
+
"got": "^11.8.3",
|
34
|
+
"https-proxy-agent": "latest",
|
35
|
+
"is-hexcolor": "^1.0.0",
|
36
|
+
"lodash": "",
|
37
|
+
"mqtt": "^4.3.7",
|
38
|
+
"node-superfetch": "^0.2.3",
|
39
|
+
"npmlog": "latest",
|
40
|
+
"path": "latest",
|
41
|
+
"pretty-ms": "latest",
|
42
|
+
"request": "latest",
|
43
|
+
"semver": "latest",
|
44
|
+
"sus-support": "git+https://github.com/amogusdevlol/sus-support.git",
|
45
|
+
"websocket-stream": "latest"
|
31
46
|
},
|
32
47
|
"engines": {
|
33
48
|
"node": ">=10.x"
|
34
49
|
},
|
35
50
|
"devDependencies": {
|
36
|
-
"eslint": "
|
37
|
-
"mocha": "
|
38
|
-
"prettier": "
|
51
|
+
"eslint": "latest",
|
52
|
+
"mocha": "latest",
|
53
|
+
"prettier": "1.11.1"
|
39
54
|
},
|
40
55
|
"eslintConfig": {
|
41
56
|
"env": {
|
42
57
|
"es6": true,
|
43
|
-
"es2017": true,
|
44
58
|
"node": true
|
45
59
|
},
|
46
60
|
"extends": "eslint:recommended",
|
@@ -59,16 +73,14 @@
|
|
59
73
|
"no-unused-vars": [
|
60
74
|
1,
|
61
75
|
{
|
62
|
-
"argsIgnorePattern": "^_"
|
63
|
-
"varsIgnorePattern": "^_"
|
64
|
-
}
|
65
|
-
],
|
66
|
-
"no-empty": [
|
67
|
-
"error",
|
68
|
-
{
|
69
|
-
"allowEmptyCatch": true
|
76
|
+
"argsIgnorePattern": "^_"
|
70
77
|
}
|
71
78
|
]
|
72
79
|
}
|
80
|
+
},
|
81
|
+
"homepage": "",
|
82
|
+
"main": "index.js",
|
83
|
+
"directories": {
|
84
|
+
"test": "test"
|
73
85
|
}
|
74
|
-
}
|
86
|
+
}
|
package/replit.nix
CHANGED
package/src/addExternalModule.js
CHANGED
@@ -2,14 +2,22 @@
|
|
2
2
|
|
3
3
|
const utils = require("../utils");
|
4
4
|
|
5
|
-
module.exports = function
|
5
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
6
6
|
return function addExternalModule(moduleObj) {
|
7
7
|
if (utils.getType(moduleObj) == "Object") {
|
8
8
|
for (let apiName in moduleObj) {
|
9
|
-
if (utils.getType(moduleObj[apiName]) == "Function")
|
10
|
-
|
9
|
+
if (utils.getType(moduleObj[apiName]) == "Function")
|
10
|
+
api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
|
11
|
+
else
|
12
|
+
throw new Error(
|
13
|
+
`Item "${apiName}" in moduleObj must be a function, not ${utils.getType(
|
14
|
+
moduleObj[apiName]
|
15
|
+
)}!`
|
16
|
+
);
|
11
17
|
}
|
12
|
-
}
|
13
|
-
|
18
|
+
} else
|
19
|
+
throw new Error(
|
20
|
+
`moduleObj must be an object, not ${utils.getType(moduleObj)}!`
|
21
|
+
);
|
14
22
|
};
|
15
23
|
};
|
package/src/addUserToGroup.js
CHANGED
@@ -3,25 +3,39 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function addUserToGroup(userID, threadID, callback) {
|
8
|
-
var resolveFunc = function
|
9
|
-
var rejectFunc = function
|
10
|
-
var returnPromise = new Promise(function
|
8
|
+
var resolveFunc = function() {};
|
9
|
+
var rejectFunc = function() {};
|
10
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
13
13
|
});
|
14
14
|
|
15
|
-
if (
|
15
|
+
if (
|
16
|
+
!callback &&
|
17
|
+
(utils.getType(threadID) === "Function" ||
|
18
|
+
utils.getType(threadID) === "AsyncFunction")
|
19
|
+
)
|
20
|
+
throw { error: "please pass a threadID as a second argument." };
|
16
21
|
|
17
22
|
if (!callback) {
|
18
|
-
callback = function
|
23
|
+
callback = function(err) {
|
19
24
|
if (err) return rejectFunc(err);
|
20
25
|
resolveFunc();
|
21
26
|
};
|
22
27
|
}
|
23
28
|
|
24
|
-
if (
|
29
|
+
if (
|
30
|
+
utils.getType(threadID) !== "Number" &&
|
31
|
+
utils.getType(threadID) !== "String"
|
32
|
+
)
|
33
|
+
throw {
|
34
|
+
error:
|
35
|
+
"ThreadID should be of type Number or String and not " +
|
36
|
+
utils.getType(threadID) +
|
37
|
+
"."
|
38
|
+
};
|
25
39
|
|
26
40
|
if (utils.getType(userID) !== "Array") userID = [userID];
|
27
41
|
|
@@ -54,21 +68,31 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
54
68
|
};
|
55
69
|
|
56
70
|
for (var i = 0; i < userID.length; i++) {
|
57
|
-
if (
|
58
|
-
|
71
|
+
if (
|
72
|
+
utils.getType(userID[i]) !== "Number" &&
|
73
|
+
utils.getType(userID[i]) !== "String"
|
74
|
+
)
|
75
|
+
throw {
|
76
|
+
error:
|
77
|
+
"Elements of userID should be of type Number or String and not " +
|
78
|
+
utils.getType(userID[i]) +
|
79
|
+
"."
|
80
|
+
};
|
81
|
+
form["log_message_data[added_participants][" + i + "]"] =
|
82
|
+
"fbid:" + userID[i];
|
59
83
|
}
|
60
84
|
|
61
85
|
defaultFuncs
|
62
86
|
.post("https://www.facebook.com/messaging/send/", ctx.jar, form)
|
63
87
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
64
|
-
.then(function
|
88
|
+
.then(function(resData) {
|
65
89
|
if (!resData) throw { error: "Add to group failed." };
|
66
90
|
if (resData.error) throw resData;
|
67
91
|
|
68
92
|
return callback();
|
69
93
|
})
|
70
|
-
.catch(function
|
71
|
-
log.error("addUserToGroup",
|
94
|
+
.catch(function(err) {
|
95
|
+
log.error("addUserToGroup", err);
|
72
96
|
return callback(err);
|
73
97
|
});
|
74
98
|
|
package/src/changeAdminStatus.js
CHANGED
@@ -1,47 +1,95 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
const utils = require("../utils");
|
4
|
+
const log = require("npmlog");
|
4
5
|
|
5
|
-
module.exports = function
|
6
|
-
return function changeAdminStatus(threadID,
|
7
|
-
if (utils.getType(threadID) !== "String")
|
8
|
-
|
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'
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
+
return function changeAdminStatus(threadID, adminIDs, adminStatus, callback) {
|
8
|
+
if (utils.getType(threadID) !== "String") {
|
9
|
+
throw { error: "changeAdminStatus: threadID must be a string" };
|
21
10
|
}
|
22
11
|
|
23
|
-
if (utils.getType(
|
24
|
-
|
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
|
-
}
|
12
|
+
if (utils.getType(adminIDs) === "String") {
|
13
|
+
adminIDs = [adminIDs];
|
33
14
|
}
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
});
|
15
|
+
|
16
|
+
if (utils.getType(adminIDs) !== "Array") {
|
17
|
+
throw { error: "changeAdminStatus: adminIDs must be an array or string" };
|
18
|
+
}
|
19
|
+
|
20
|
+
if (utils.getType(adminStatus) !== "Boolean") {
|
21
|
+
throw { error: "changeAdminStatus: adminStatus must be a string" };
|
42
22
|
}
|
43
23
|
|
44
|
-
|
45
|
-
|
24
|
+
var resolveFunc = function() {};
|
25
|
+
var rejectFunc = function() {};
|
26
|
+
var 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 (
|
41
|
+
utils.getType(callback) !== "Function" &&
|
42
|
+
utils.getType(callback) !== "AsyncFunction"
|
43
|
+
) {
|
44
|
+
throw { error: "changeAdminStatus: callback is not a function" };
|
45
|
+
}
|
46
|
+
|
47
|
+
let form = {
|
48
|
+
thread_fbid: threadID
|
49
|
+
};
|
50
|
+
|
51
|
+
let i = 0;
|
52
|
+
for (let u of adminIDs) {
|
53
|
+
form[`admin_ids[${i++}]`] = u;
|
54
|
+
}
|
55
|
+
form["add"] = adminStatus;
|
56
|
+
|
57
|
+
defaultFuncs
|
58
|
+
.post(
|
59
|
+
"https://www.facebook.com/messaging/save_admins/?dpr=1",
|
60
|
+
ctx.jar,
|
61
|
+
form
|
62
|
+
)
|
63
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
64
|
+
.then(function(resData) {
|
65
|
+
if (resData.error) {
|
66
|
+
switch (resData.error) {
|
67
|
+
case 1976004:
|
68
|
+
throw {
|
69
|
+
error: "Cannot alter admin status: you are not an admin.",
|
70
|
+
rawResponse: resData
|
71
|
+
};
|
72
|
+
case 1357031:
|
73
|
+
throw {
|
74
|
+
error:
|
75
|
+
"Cannot alter admin status: this thread is not a group chat.",
|
76
|
+
rawResponse: resData
|
77
|
+
};
|
78
|
+
default:
|
79
|
+
throw {
|
80
|
+
error: "Cannot alter admin status: unknown error.",
|
81
|
+
rawResponse: resData
|
82
|
+
};
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
callback();
|
87
|
+
})
|
88
|
+
.catch(function(err) {
|
89
|
+
log.error("changeAdminStatus", err);
|
90
|
+
return callback(err);
|
91
|
+
});
|
92
|
+
|
93
|
+
return returnPromise;
|
46
94
|
};
|
47
|
-
};
|
95
|
+
};
|
@@ -3,17 +3,17 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function changeArchivedStatus(threadOrThreads, archive, callback) {
|
8
|
-
var resolveFunc = function
|
9
|
-
var rejectFunc = function
|
10
|
-
var returnPromise = new Promise(function
|
8
|
+
var resolveFunc = function() {};
|
9
|
+
var rejectFunc = function() {};
|
10
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
13
13
|
});
|
14
14
|
|
15
15
|
if (!callback) {
|
16
|
-
callback = function
|
16
|
+
callback = function(err) {
|
17
17
|
if (err) return rejectFunc(err);
|
18
18
|
resolveFunc();
|
19
19
|
};
|
@@ -21,17 +21,23 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
21
21
|
|
22
22
|
var form = {};
|
23
23
|
|
24
|
-
if (utils.getType(threadOrThreads) === "Array")
|
24
|
+
if (utils.getType(threadOrThreads) === "Array")
|
25
|
+
for (var i = 0; i < threadOrThreads.length; i++)
|
26
|
+
form["ids[" + threadOrThreads[i] + "]"] = archive;
|
25
27
|
else form["ids[" + threadOrThreads + "]"] = archive;
|
26
28
|
|
27
29
|
defaultFuncs
|
28
|
-
.post(
|
30
|
+
.post(
|
31
|
+
"https://www.facebook.com/ajax/mercury/change_archived_status.php",
|
32
|
+
ctx.jar,
|
33
|
+
form
|
34
|
+
)
|
29
35
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
30
|
-
.then(function
|
36
|
+
.then(function(resData) {
|
31
37
|
if (resData.error) throw resData;
|
32
38
|
return callback();
|
33
39
|
})
|
34
|
-
.catch(function
|
40
|
+
.catch(function(err) {
|
35
41
|
log.error("changeArchivedStatus", err);
|
36
42
|
return callback(err);
|
37
43
|
});
|
package/src/changeAvt.js
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
/**
|
6
|
+
* It posts an image to a Facebook profile
|
7
|
+
* @param Api - The API object
|
8
|
+
* @param BotID - The ID of the bot you want to post the image to.
|
9
|
+
* @param form - The form data that you want to send.
|
10
|
+
* @returns The JSON.parse(Data.split("for (;;);")[1]); is returning the following:
|
11
|
+
* {"__ar":1,"payload":null,"jsmods":{"require":[["ImageUploader","uploadPhoto",[{"__m":"__elem_0"},{"__m":"__elem_1"},{"__m":"__elem_2"},{"__m":"__
|
12
|
+
*/
|
13
|
+
async function postImage(Api, BotID, form) {
|
14
|
+
var Data = await Api.httpPostFormData(
|
15
|
+
`https://www.facebook.com/profile/picture/upload/?profile_id=${BotID}&photo_source=57&av=${BotID}`,
|
16
|
+
form
|
17
|
+
);
|
18
|
+
return JSON.parse(Data.split("for (;;);")[1]);
|
19
|
+
}
|
20
|
+
|
21
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
22
|
+
/* Changing the profile picture of the bot. */
|
23
|
+
return function changeAvt(link, caption, callback) {
|
24
|
+
var resolveFunc = function () { };
|
25
|
+
var rejectFunc = function () { };
|
26
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
27
|
+
resolveFunc = resolve;
|
28
|
+
rejectFunc = reject;
|
29
|
+
});
|
30
|
+
|
31
|
+
if (!callback) {
|
32
|
+
callback = function (err, data) {
|
33
|
+
if (err) return rejectFunc(err);
|
34
|
+
resolveFunc(data);
|
35
|
+
};
|
36
|
+
}
|
37
|
+
try {
|
38
|
+
var Fetch = require("axios");
|
39
|
+
Fetch.get(link, { responseType: "stream" }).then(data => {
|
40
|
+
postImage(api, ctx.userID, { file: data.data }).then(data => {
|
41
|
+
if (data.error)
|
42
|
+
throw new Error({
|
43
|
+
error: data.error,
|
44
|
+
des: data.error.errorDescription
|
45
|
+
});
|
46
|
+
var form = {
|
47
|
+
av: ctx.userID,
|
48
|
+
fb_api_req_friendly_name: "ProfileCometProfilePictureSetMutation",
|
49
|
+
fb_api_caller_class: "RelayModern",
|
50
|
+
doc_id: "5066134240065849",
|
51
|
+
variables: JSON.stringify({
|
52
|
+
input: {
|
53
|
+
caption: caption || "",
|
54
|
+
existing_photo_id: data.payload.fbid,
|
55
|
+
expiration_time: null,
|
56
|
+
profile_id: ctx.userID,
|
57
|
+
profile_pic_method: "EXISTING",
|
58
|
+
profile_pic_source: "TIMELINE",
|
59
|
+
scaled_crop_rect: {
|
60
|
+
height: 1,
|
61
|
+
width: 1,
|
62
|
+
x: 0,
|
63
|
+
y: 0
|
64
|
+
},
|
65
|
+
skip_cropping: true,
|
66
|
+
actor_id: ctx.userID,
|
67
|
+
client_mutation_id: Math.round(Math.random() * 19).toString()
|
68
|
+
},
|
69
|
+
isPage: false,
|
70
|
+
isProfile: true,
|
71
|
+
scale: 3
|
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) throw resData;
|
79
|
+
else return callback(null, true);
|
80
|
+
})
|
81
|
+
.catch(function (err) {
|
82
|
+
return callback(err);
|
83
|
+
});
|
84
|
+
});
|
85
|
+
});
|
86
|
+
} catch (e) {
|
87
|
+
throw e;
|
88
|
+
}
|
89
|
+
return returnPromise;
|
90
|
+
};
|
91
|
+
};
|
package/src/changeBio.js
CHANGED
@@ -3,19 +3,23 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function changeBio(bio, publish, callback) {
|
8
|
-
var resolveFunc = function
|
9
|
-
var rejectFunc = function
|
10
|
-
var returnPromise = new Promise(function
|
8
|
+
var resolveFunc = function() {};
|
9
|
+
var rejectFunc = function() {};
|
10
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
13
13
|
});
|
14
14
|
|
15
15
|
if (!callback) {
|
16
|
-
if (
|
16
|
+
if (
|
17
|
+
utils.getType(publish) == "Function" ||
|
18
|
+
utils.getType(publish) == "AsyncFunction"
|
19
|
+
)
|
20
|
+
callback = publish;
|
17
21
|
else {
|
18
|
-
callback = function
|
22
|
+
callback = function(err) {
|
19
23
|
if (err) return rejectFunc(err);
|
20
24
|
resolveFunc();
|
21
25
|
};
|
@@ -50,11 +54,12 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
50
54
|
defaultFuncs
|
51
55
|
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
52
56
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
53
|
-
.then(function
|
57
|
+
.then(function(resData) {
|
54
58
|
if (resData.errors) throw resData;
|
59
|
+
|
55
60
|
return callback();
|
56
61
|
})
|
57
|
-
.catch(function
|
62
|
+
.catch(function(err) {
|
58
63
|
log.error("changeBio", err);
|
59
64
|
return callback(err);
|
60
65
|
});
|
@@ -3,31 +3,37 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function changeBlockedStatus(userID, block, callback) {
|
8
|
-
var resolveFunc = function
|
9
|
-
var rejectFunc = function
|
10
|
-
var returnPromise = new Promise(function
|
8
|
+
var resolveFunc = function() {};
|
9
|
+
var rejectFunc = function() {};
|
10
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
13
13
|
});
|
14
14
|
|
15
15
|
if (!callback) {
|
16
|
-
callback = function
|
16
|
+
callback = function(err) {
|
17
17
|
if (err) return rejectFunc(err);
|
18
18
|
resolveFunc();
|
19
19
|
};
|
20
20
|
}
|
21
21
|
|
22
22
|
defaultFuncs
|
23
|
-
.post(
|
23
|
+
.post(
|
24
|
+
`https://www.facebook.com/messaging/${
|
25
|
+
block ? "" : "un"
|
26
|
+
}block_messages/`,
|
27
|
+
ctx.jar,
|
28
|
+
{ fbid: userID }
|
29
|
+
)
|
24
30
|
.then(utils.saveCookies(ctx.jar))
|
25
31
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
26
|
-
.then(function
|
32
|
+
.then(function(resData) {
|
27
33
|
if (resData.error) throw resData;
|
28
34
|
return callback();
|
29
35
|
})
|
30
|
-
.catch(function
|
36
|
+
.catch(function(err) {
|
31
37
|
log.error("changeBlockedStatus", err);
|
32
38
|
return callback(err);
|
33
39
|
});
|