alicezetion 1.7.0 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -1
  2. package/.cache/replit/nix/env.json +1 -1
  3. package/Extra/Database/index.js +399 -0
  4. package/Extra/Database/methods.js +286 -0
  5. package/Extra/ExtraAddons.js +213 -0
  6. package/Extra/ExtraGetThread.js +1 -0
  7. package/Extra/ExtraUptimeRobot.js +59 -0
  8. package/Extra/PM2/ecosystem.config.js +23 -0
  9. package/Extra/Src/Last-Run.js +48 -0
  10. package/Language/index.json +151 -0
  11. package/StateCrypt.js +22 -0
  12. package/broadcast.js +42 -0
  13. package/index.js +755 -533
  14. package/logger.js +21 -0
  15. package/package.json +35 -21
  16. package/replit.nix +0 -3
  17. package/src/addExternalModule.js +23 -0
  18. package/{leiamnash → src}/addUserToGroup.js +11 -23
  19. package/{leiamnash → src}/changeAdminStatus.js +32 -16
  20. package/{leiamnash → src}/changeArchivedStatus.js +9 -17
  21. package/src/changeAvt.js +91 -0
  22. package/{leiamnash → src}/changeBio.js +16 -24
  23. package/{leiamnash → src}/changeBlockedStatus.js +13 -18
  24. package/{leiamnash → src}/changeGroupImage.js +14 -23
  25. package/{leiamnash → src}/changeNickname.js +9 -14
  26. package/{leiamnash → src}/changeThreadColor.js +6 -10
  27. package/{leiamnash → src}/changeThreadEmoji.js +6 -11
  28. package/{leiamnash → src}/chat.js +116 -127
  29. package/{leiamnash → src}/createNewGroup.js +19 -27
  30. package/{leiamnash → src}/createPoll.js +6 -12
  31. package/{leiamnash → src}/deleteMessage.js +8 -13
  32. package/{leiamnash → src}/deleteThread.js +7 -14
  33. package/{leiamnash → src}/forwardAttachment.js +9 -16
  34. package/src/getAccessToken.js +32 -0
  35. package/{leiamnash → src}/getCurrentUserID.js +0 -0
  36. package/{leiamnash → src}/getEmojiUrl.js +1 -2
  37. package/{leiamnash → src}/getFriendsList.js +11 -14
  38. package/src/getMessage.js +84 -0
  39. package/{leiamnash → src}/getThreadHistory.js +27 -38
  40. package/{leiamnash → src}/getThreadHistoryDeprecated.js +14 -25
  41. package/src/getThreadInfo.js +197 -0
  42. package/{leiamnash → src}/getThreadInfoDeprecated.js +12 -24
  43. package/{leiamnash → src}/getThreadList.js +122 -88
  44. package/{leiamnash → src}/getThreadListDeprecated.js +9 -20
  45. package/{leiamnash → src}/getThreadPictures.js +9 -17
  46. package/{leiamnash → src}/getUserID.js +8 -11
  47. package/{leiamnash → src}/getUserInfo.js +12 -16
  48. package/src/getUserInfoV2.js +35 -0
  49. package/src/handleFriendRequest.js +47 -0
  50. package/{leiamnash → src}/handleMessageRequest.js +12 -22
  51. package/{leiamnash → src}/httpGet.js +15 -13
  52. package/{leiamnash → src}/httpPost.js +14 -13
  53. package/src/httpPostFormData.js +46 -0
  54. package/src/listenMqtt.js +1280 -0
  55. package/{leiamnash → src}/logout.js +7 -9
  56. package/{leiamnash → src}/markAsDelivered.js +14 -18
  57. package/{leiamnash → src}/markAsRead.js +30 -28
  58. package/{leiamnash → src}/markAsSeen.js +18 -19
  59. package/{leiamnash → src}/muteThread.js +7 -8
  60. package/{leiamnash/setMessageReaction.js → src/react.js} +15 -18
  61. package/{leiamnash → src}/removeUserFromGroup.js +13 -20
  62. package/{leiamnash → src}/resolvePhotoUrl.js +7 -13
  63. package/{leiamnash → src}/searchForThread.js +8 -13
  64. package/{leiamnash/markAsReadAll.js → src/seen.js} +10 -13
  65. package/{leiamnash → src}/sendTypingIndicator.js +23 -31
  66. package/src/setPostReaction.js +104 -0
  67. package/{leiamnash → src}/setTitle.js +15 -21
  68. package/src/threadColors.js +39 -0
  69. package/{leiamnash → src}/unfriend.js +9 -13
  70. package/{leiamnash/unsendMessage.js → src/unsend.js} +7 -16
  71. package/utils.js +1112 -1236
  72. package/leiamnash/addExternalModule.js +0 -19
  73. package/leiamnash/changeApprovalMode.js +0 -80
  74. package/leiamnash/getThreadInfo.js +0 -212
  75. package/leiamnash/handleFriendRequest.js +0 -61
  76. package/leiamnash/listenMqtt.js +0 -1129
  77. package/leiamnash/setPostReaction.js +0 -76
  78. package/leiamnash/threadColors.js +0 -57
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,9 +1,10 @@
1
1
  {
2
2
  "name": "alicezetion",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "description": "",
5
5
  "scripts": {
6
- "lint": "./node_modules/.bin/eslint **.js",
6
+ "test": "mocha",
7
+ "lint": "eslint **.js",
7
8
  "prettier": "prettier utils.js src/* --write"
8
9
  },
9
10
  "repository": {
@@ -11,34 +12,49 @@
11
12
  "url": ""
12
13
  },
13
14
  "keywords": [
15
+ "alice",
14
16
  "leiamnash"
15
17
  ],
16
18
  "bugs": {
17
- "url": "https://leiamnash.vercel.app"
19
+ "url": ""
18
20
  },
19
- "author": "LeiamNash",
21
+ "author": "leiamnash",
20
22
  "license": "MIT",
21
23
  "dependencies": {
24
+ "@replit/database": "latest",
25
+ "aes-js": "latest",
26
+ "assert": "latest",
27
+ "better-sqlite3": "latest",
22
28
  "bluebird": "^2.11.0",
23
- "cheerio": "^1.0.0-rc.12",
24
- "https-proxy-agent": "^4.0.0",
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": "",
25
37
  "mqtt": "^4.3.7",
26
- "npmlog": "^1.2.0",
27
- "request": "^2.53.0",
28
- "websocket-stream": "^5.5.0"
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"
29
46
  },
30
47
  "engines": {
31
48
  "node": ">=10.x"
32
49
  },
33
50
  "devDependencies": {
34
- "eslint": "^7.5.0",
35
- "mocha": "^10.2.0",
36
- "prettier": "^1.11.1"
51
+ "eslint": "latest",
52
+ "mocha": "latest",
53
+ "prettier": "1.11.1"
37
54
  },
38
55
  "eslintConfig": {
39
56
  "env": {
40
57
  "es6": true,
41
- "es2017": true,
42
58
  "node": true
43
59
  },
44
60
  "extends": "eslint:recommended",
@@ -57,16 +73,14 @@
57
73
  "no-unused-vars": [
58
74
  1,
59
75
  {
60
- "argsIgnorePattern": "^_",
61
- "varsIgnorePattern": "^_"
62
- }
63
- ],
64
- "no-empty": [
65
- "error",
66
- {
67
- "allowEmptyCatch": true
76
+ "argsIgnorePattern": "^_"
68
77
  }
69
78
  ]
70
79
  }
80
+ },
81
+ "homepage": "",
82
+ "main": "index.js",
83
+ "directories": {
84
+ "test": "test"
71
85
  }
72
86
  }
package/replit.nix CHANGED
@@ -1,8 +1,5 @@
1
1
  { pkgs }: {
2
2
  deps = [
3
3
  pkgs.nodejs-16_x
4
- pkgs.bashInteractive
5
- pkgs.nodePackages.bash-language-server
6
- pkgs.man
7
4
  ];
8
5
  }
@@ -0,0 +1,23 @@
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")
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
+ );
17
+ }
18
+ } else
19
+ throw new Error(
20
+ `moduleObj must be an object, not ${utils.getType(moduleObj)}!`
21
+ );
22
+ };
23
+ };
@@ -5,9 +5,9 @@ var log = require("npmlog");
5
5
 
6
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 (resolve, reject) {
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
  });
@@ -16,15 +16,12 @@ module.exports = function(defaultFuncs, api, ctx) {
16
16
  !callback &&
17
17
  (utils.getType(threadID) === "Function" ||
18
18
  utils.getType(threadID) === "AsyncFunction")
19
- ) {
19
+ )
20
20
  throw { error: "please pass a threadID as a second argument." };
21
- }
22
21
 
23
22
  if (!callback) {
24
23
  callback = function(err) {
25
- if (err) {
26
- return rejectFunc(err);
27
- }
24
+ if (err) return rejectFunc(err);
28
25
  resolveFunc();
29
26
  };
30
27
  }
@@ -32,18 +29,15 @@ module.exports = function(defaultFuncs, api, ctx) {
32
29
  if (
33
30
  utils.getType(threadID) !== "Number" &&
34
31
  utils.getType(threadID) !== "String"
35
- ) {
32
+ )
36
33
  throw {
37
34
  error:
38
35
  "ThreadID should be of type Number or String and not " +
39
36
  utils.getType(threadID) +
40
37
  "."
41
38
  };
42
- }
43
39
 
44
- if (utils.getType(userID) !== "Array") {
45
- userID = [userID];
46
- }
40
+ if (utils.getType(userID) !== "Array") userID = [userID];
47
41
 
48
42
  var messageAndOTID = utils.generateOfflineThreadingID();
49
43
  var form = {
@@ -77,15 +71,13 @@ module.exports = function(defaultFuncs, api, ctx) {
77
71
  if (
78
72
  utils.getType(userID[i]) !== "Number" &&
79
73
  utils.getType(userID[i]) !== "String"
80
- ) {
74
+ )
81
75
  throw {
82
76
  error:
83
77
  "Elements of userID should be of type Number or String and not " +
84
78
  utils.getType(userID[i]) +
85
79
  "."
86
80
  };
87
- }
88
-
89
81
  form["log_message_data[added_participants][" + i + "]"] =
90
82
  "fbid:" + userID[i];
91
83
  }
@@ -94,12 +86,8 @@ module.exports = function(defaultFuncs, api, ctx) {
94
86
  .post("https://www.facebook.com/messaging/send/", ctx.jar, form)
95
87
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
96
88
  .then(function(resData) {
97
- if (!resData) {
98
- throw { error: "Add to group failed." };
99
- }
100
- if (resData.error) {
101
- throw resData;
102
- }
89
+ if (!resData) throw { error: "Add to group failed." };
90
+ if (resData.error) throw resData;
103
91
 
104
92
  return callback();
105
93
  })
@@ -107,7 +95,7 @@ module.exports = function(defaultFuncs, api, ctx) {
107
95
  log.error("addUserToGroup", err);
108
96
  return callback(err);
109
97
  });
110
-
98
+
111
99
  return returnPromise;
112
100
  };
113
101
  };
@@ -6,7 +6,7 @@ const log = require("npmlog");
6
6
  module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function changeAdminStatus(threadID, adminIDs, adminStatus, callback) {
8
8
  if (utils.getType(threadID) !== "String") {
9
- throw {error: "changeAdminStatus: threadID must be a string"};
9
+ throw { error: "changeAdminStatus: threadID must be a string" };
10
10
  }
11
11
 
12
12
  if (utils.getType(adminIDs) === "String") {
@@ -14,22 +14,22 @@ module.exports = function(defaultFuncs, api, ctx) {
14
14
  }
15
15
 
16
16
  if (utils.getType(adminIDs) !== "Array") {
17
- throw {error: "changeAdminStatus: adminIDs must be an array or string"};
17
+ throw { error: "changeAdminStatus: adminIDs must be an array or string" };
18
18
  }
19
19
 
20
20
  if (utils.getType(adminStatus) !== "Boolean") {
21
- throw {error: "changeAdminStatus: adminStatus must be a string"};
21
+ throw { error: "changeAdminStatus: adminStatus must be a string" };
22
22
  }
23
23
 
24
- var resolveFunc = function(){};
25
- var rejectFunc = function(){};
26
- var returnPromise = new Promise(function (resolve, reject) {
24
+ var resolveFunc = function() {};
25
+ var rejectFunc = function() {};
26
+ var returnPromise = new Promise(function(resolve, reject) {
27
27
  resolveFunc = resolve;
28
28
  rejectFunc = reject;
29
29
  });
30
30
 
31
31
  if (!callback) {
32
- callback = function (err) {
32
+ callback = function(err) {
33
33
  if (err) {
34
34
  return rejectFunc(err);
35
35
  }
@@ -37,12 +37,15 @@ module.exports = function(defaultFuncs, api, ctx) {
37
37
  };
38
38
  }
39
39
 
40
- if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
41
- throw {error: "changeAdminStatus: callback is not a function"};
40
+ if (
41
+ utils.getType(callback) !== "Function" &&
42
+ utils.getType(callback) !== "AsyncFunction"
43
+ ) {
44
+ throw { error: "changeAdminStatus: callback is not a function" };
42
45
  }
43
46
 
44
47
  let form = {
45
- "thread_fbid": threadID,
48
+ thread_fbid: threadID
46
49
  };
47
50
 
48
51
  let i = 0;
@@ -52,17 +55,31 @@ module.exports = function(defaultFuncs, api, ctx) {
52
55
  form["add"] = adminStatus;
53
56
 
54
57
  defaultFuncs
55
- .post("https://www.facebook.com/messaging/save_admins/?dpr=1", ctx.jar, form)
58
+ .post(
59
+ "https://www.facebook.com/messaging/save_admins/?dpr=1",
60
+ ctx.jar,
61
+ form
62
+ )
56
63
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
57
64
  .then(function(resData) {
58
65
  if (resData.error) {
59
66
  switch (resData.error) {
60
67
  case 1976004:
61
- throw { error: "Cannot alter admin status: you are not an admin.", rawResponse: resData };
68
+ throw {
69
+ error: "Cannot alter admin status: you are not an admin.",
70
+ rawResponse: resData
71
+ };
62
72
  case 1357031:
63
- throw { error: "Cannot alter admin status: this thread is not a group chat.", rawResponse: resData };
73
+ throw {
74
+ error:
75
+ "Cannot alter admin status: this thread is not a group chat.",
76
+ rawResponse: resData
77
+ };
64
78
  default:
65
- throw { error: "Cannot alter admin status: unknown error.", rawResponse: resData };
79
+ throw {
80
+ error: "Cannot alter admin status: unknown error.",
81
+ rawResponse: resData
82
+ };
66
83
  }
67
84
  }
68
85
 
@@ -72,8 +89,7 @@ module.exports = function(defaultFuncs, api, ctx) {
72
89
  log.error("changeAdminStatus", err);
73
90
  return callback(err);
74
91
  });
75
-
92
+
76
93
  return returnPromise;
77
94
  };
78
95
  };
79
-
@@ -5,31 +5,26 @@ var log = require("npmlog");
5
5
 
6
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 (resolve, reject) {
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
16
  callback = function(err) {
17
- if (err) {
18
- return rejectFunc(err);
19
- }
17
+ if (err) return rejectFunc(err);
20
18
  resolveFunc();
21
19
  };
22
20
  }
23
21
 
24
22
  var form = {};
25
23
 
26
- if (utils.getType(threadOrThreads) === "Array") {
27
- for (var i = 0; i < threadOrThreads.length; i++) {
24
+ if (utils.getType(threadOrThreads) === "Array")
25
+ for (var i = 0; i < threadOrThreads.length; i++)
28
26
  form["ids[" + threadOrThreads[i] + "]"] = archive;
29
- }
30
- } else {
31
- form["ids[" + threadOrThreads + "]"] = archive;
32
- }
27
+ else form["ids[" + threadOrThreads + "]"] = archive;
33
28
 
34
29
  defaultFuncs
35
30
  .post(
@@ -39,17 +34,14 @@ module.exports = function(defaultFuncs, api, ctx) {
39
34
  )
40
35
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
41
36
  .then(function(resData) {
42
- if (resData.error) {
43
- throw resData;
44
- }
45
-
37
+ if (resData.error) throw resData;
46
38
  return callback();
47
39
  })
48
40
  .catch(function(err) {
49
41
  log.error("changeArchivedStatus", err);
50
42
  return callback(err);
51
43
  });
52
-
44
+
53
45
  return returnPromise;
54
46
  };
55
47
  };
@@ -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
+ };
@@ -3,32 +3,30 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
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 (resolve, reject) {
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 (utils.getType(publish) == "Function" || utils.getType(publish) == "AsyncFunction") {
16
+ if (
17
+ utils.getType(publish) == "Function" ||
18
+ utils.getType(publish) == "AsyncFunction"
19
+ )
17
20
  callback = publish;
18
- } else {
19
- callback = function (err) {
20
- if (err) {
21
- return rejectFunc(err);
22
- }
21
+ else {
22
+ callback = function(err) {
23
+ if (err) return rejectFunc(err);
23
24
  resolveFunc();
24
25
  };
25
26
  }
26
27
  }
27
28
 
28
- if (utils.getType(publish) != "Boolean") {
29
- publish = false;
30
- }
31
-
29
+ if (utils.getType(publish) != "Boolean") publish = false;
32
30
  if (utils.getType(bio) != "String") {
33
31
  bio = "";
34
32
  publish = false;
@@ -54,20 +52,14 @@ module.exports = function (defaultFuncs, api, ctx) {
54
52
  };
55
53
 
56
54
  defaultFuncs
57
- .post(
58
- "https://www.facebook.com/api/graphql/",
59
- ctx.jar,
60
- form
61
- )
55
+ .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
62
56
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
63
- .then(function (resData) {
64
- if (resData.errors) {
65
- throw resData;
66
- }
57
+ .then(function(resData) {
58
+ if (resData.errors) throw resData;
67
59
 
68
60
  return callback();
69
61
  })
70
- .catch(function (err) {
62
+ .catch(function(err) {
71
63
  log.error("changeBio", err);
72
64
  return callback(err);
73
65
  });
@@ -3,42 +3,37 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
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 (resolve, reject) {
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 (err) {
17
- if (err) {
18
- return rejectFunc(err);
19
- }
16
+ callback = function(err) {
17
+ if (err) return rejectFunc(err);
20
18
  resolveFunc();
21
19
  };
22
20
  }
23
21
 
24
22
  defaultFuncs
25
23
  .post(
26
- `https://www.facebook.com/messaging/${block ? "" : "un"}block_messages/`,
24
+ `https://www.facebook.com/messaging/${
25
+ block ? "" : "un"
26
+ }block_messages/`,
27
27
  ctx.jar,
28
- {
29
- fbid: userID
30
- }
28
+ { fbid: userID }
31
29
  )
32
30
  .then(utils.saveCookies(ctx.jar))
33
31
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
34
- .then(function (resData) {
35
- if (resData.error) {
36
- throw resData;
37
- }
38
-
32
+ .then(function(resData) {
33
+ if (resData.error) throw resData;
39
34
  return callback();
40
35
  })
41
- .catch(function (err) {
36
+ .catch(function(err) {
42
37
  log.error("changeBlockedStatus", err);
43
38
  return callback(err);
44
39
  });