alicezetion 1.7.6 → 1.7.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -1
  2. package/.cache/replit/nix/env.json +1 -1
  3. package/.travis.yml +6 -0
  4. package/index.js +120 -655
  5. package/package.json +25 -37
  6. package/replit.nix +4 -3
  7. package/src/addExternalModule.js +5 -13
  8. package/src/addUserToGroup.js +12 -36
  9. package/src/changeAdminStatus.js +37 -85
  10. package/src/changeArchivedStatus.js +9 -15
  11. package/src/changeBio.js +8 -13
  12. package/src/changeBlockedStatus.js +8 -14
  13. package/src/changeGroupImage.js +13 -28
  14. package/src/changeNickname.js +11 -22
  15. package/src/changeThreadColor.js +10 -16
  16. package/src/changeThreadEmoji.js +9 -18
  17. package/src/chat.js +280 -401
  18. package/src/createNewGroup.js +10 -18
  19. package/src/createPoll.js +11 -17
  20. package/src/deleteMessage.js +10 -17
  21. package/src/deleteThread.js +10 -17
  22. package/src/forwardAttachment.js +9 -15
  23. package/src/forwardMessage.js +0 -0
  24. package/src/getCurrentUserID.js +1 -1
  25. package/src/getEmojiUrl.js +2 -3
  26. package/src/getFriendsList.js +10 -18
  27. package/src/getThreadHistory.js +59 -156
  28. package/src/getThreadHistoryDeprecated.js +15 -26
  29. package/src/getThreadInfo.js +42 -68
  30. package/src/getThreadInfoDeprecated.js +13 -25
  31. package/src/getThreadList.js +53 -112
  32. package/src/getThreadListDeprecated.js +12 -30
  33. package/src/getThreadPictures.js +13 -25
  34. package/src/getUserID.js +7 -9
  35. package/src/getUserInfo.js +10 -12
  36. package/src/handleFriendRequest.js +35 -36
  37. package/src/handleMessageRequest.js +10 -18
  38. package/src/httpGet.js +13 -20
  39. package/src/httpPost.js +13 -19
  40. package/src/listen.js +553 -0
  41. package/src/listenMqtt-Test.js +687 -0
  42. package/src/listenMqtt.js +621 -1224
  43. package/src/logout.js +13 -18
  44. package/src/markAsDelivered.js +10 -17
  45. package/src/markAsRead.js +24 -36
  46. package/src/{seen.js → markAsReadAll.js} +10 -17
  47. package/src/markAsSeen.js +12 -22
  48. package/src/muteThread.js +9 -15
  49. package/src/removeUserFromGroup.js +11 -38
  50. package/src/resolvePhotoUrl.js +6 -9
  51. package/src/searchForThread.js +8 -14
  52. package/src/sendMessage.js +315 -0
  53. package/src/sendTypingIndicator.js +19 -44
  54. package/src/{react.js → setMessageReaction.js} +9 -20
  55. package/src/setPostReaction.js +22 -63
  56. package/src/setTitle.js +12 -22
  57. package/src/threadColors.js +19 -17
  58. package/src/unfriend.js +9 -15
  59. package/src/{unsend.js → unsendMessage.js} +8 -9
  60. package/test/data/shareAttach.js +146 -0
  61. package/test/data/something.mov +0 -0
  62. package/test/data/test.png +0 -0
  63. package/test/data/test.txt +7 -0
  64. package/test/example-config.json +18 -0
  65. package/test/test-page.js +140 -0
  66. package/test/test.js +385 -0
  67. package/utils.js +27 -120
  68. package/Extra/Database/index.js +0 -399
  69. package/Extra/Database/methods.js +0 -286
  70. package/Extra/ExtraAddons.js +0 -213
  71. package/Extra/ExtraGetThread.js +0 -1
  72. package/Extra/ExtraUptimeRobot.js +0 -59
  73. package/Extra/PM2/ecosystem.config.js +0 -23
  74. package/Extra/Src/Last-Run.js +0 -48
  75. package/Language/index.json +0 -151
  76. package/StateCrypt.js +0 -22
  77. package/broadcast.js +0 -42
  78. package/logger.js +0 -21
  79. package/src/changeAvt.js +0 -91
  80. package/src/getAccessToken.js +0 -32
  81. package/src/getMessage.js +0 -84
  82. package/src/getUserInfoV2.js +0 -35
  83. package/src/httpPostFormData.js +0 -46
package/package.json CHANGED
@@ -1,60 +1,46 @@
1
1
  {
2
2
  "name": "alicezetion",
3
- "version": "1.7.6",
3
+ "version": "1.7.7",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "mocha",
7
- "lint": "eslint **.js",
7
+ "lint": "./node_modules/.bin/eslint **.js",
8
8
  "prettier": "prettier utils.js src/* --write"
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": ""
12
+ "url": "https://leiamnash.vercel.app"
13
13
  },
14
14
  "keywords": [
15
- "alice",
16
- "leiamnash"
15
+ "leiamnash",
16
+ "alice"
17
17
  ],
18
18
  "bugs": {
19
19
  "url": ""
20
20
  },
21
- "author": "leiamnash",
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",
28
24
  "bluebird": "^2.11.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": "",
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"
25
+ "cheerio": "^0.22.0",
26
+ "https-proxy-agent": "^4.0.0",
27
+ "mqtt": "^3.0.0",
28
+ "npmlog": "^1.2.0",
29
+ "request": "^2.53.0",
30
+ "websocket-stream": "^5.5.0"
46
31
  },
47
32
  "engines": {
48
33
  "node": ">=10.x"
49
34
  },
50
35
  "devDependencies": {
51
- "eslint": "latest",
52
- "mocha": "latest",
53
- "prettier": "1.11.1"
36
+ "eslint": "^7.5.0",
37
+ "mocha": "^7.0.1",
38
+ "prettier": "^1.11.1"
54
39
  },
55
40
  "eslintConfig": {
56
41
  "env": {
57
42
  "es6": true,
43
+ "es2017": true,
58
44
  "node": true
59
45
  },
60
46
  "extends": "eslint:recommended",
@@ -73,14 +59,16 @@
73
59
  "no-unused-vars": [
74
60
  1,
75
61
  {
76
- "argsIgnorePattern": "^_"
62
+ "argsIgnorePattern": "^_",
63
+ "varsIgnorePattern": "^_"
64
+ }
65
+ ],
66
+ "no-empty": [
67
+ "error",
68
+ {
69
+ "allowEmptyCatch": true
77
70
  }
78
71
  ]
79
72
  }
80
- },
81
- "homepage": "",
82
- "main": "index.js",
83
- "directories": {
84
- "test": "test"
85
73
  }
86
- }
74
+ }
package/replit.nix CHANGED
@@ -1,5 +1,6 @@
1
1
  { pkgs }: {
2
- deps = [
3
- pkgs.nodejs-16_x
4
- ];
2
+ deps = [
3
+ pkgs.nodejs-16_x
4
+ pkgs.cowsay
5
+ ];
5
6
  }
@@ -2,22 +2,14 @@
2
2
 
3
3
  const utils = require("../utils");
4
4
 
5
- module.exports = function(defaultFuncs, api, ctx) {
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
- 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
- );
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])}!`);
17
11
  }
18
- } else
19
- throw new Error(
20
- `moduleObj must be an object, not ${utils.getType(moduleObj)}!`
21
- );
12
+ }
13
+ else throw new Error(`moduleObj must be an object, not ${utils.getType(moduleObj)}!`);
22
14
  };
23
15
  };
@@ -3,39 +3,25 @@
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 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
  });
14
14
 
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." };
15
+ if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
21
16
 
22
17
  if (!callback) {
23
- callback = function(err) {
18
+ callback = function (err) {
24
19
  if (err) return rejectFunc(err);
25
20
  resolveFunc();
26
21
  };
27
22
  }
28
23
 
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
- };
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) + "." };
39
25
 
40
26
  if (utils.getType(userID) !== "Array") userID = [userID];
41
27
 
@@ -68,31 +54,21 @@ module.exports = function(defaultFuncs, api, ctx) {
68
54
  };
69
55
 
70
56
  for (var i = 0; i < userID.length; i++) {
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];
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];
83
59
  }
84
60
 
85
61
  defaultFuncs
86
62
  .post("https://www.facebook.com/messaging/send/", ctx.jar, form)
87
63
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
88
- .then(function(resData) {
64
+ .then(function (resData) {
89
65
  if (!resData) throw { error: "Add to group failed." };
90
66
  if (resData.error) throw resData;
91
67
 
92
68
  return callback();
93
69
  })
94
- .catch(function(err) {
95
- log.error("addUserToGroup", err);
70
+ .catch(function (err) {
71
+ log.error("addUserToGroup", "» Cannot add user to the voice chat. Please try again after");
96
72
  return callback(err);
97
73
  });
98
74
 
@@ -1,95 +1,47 @@
1
1
  "use strict";
2
2
 
3
3
  const utils = require("../utils");
4
- const log = require("npmlog");
5
4
 
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" };
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'
10
21
  }
11
22
 
12
- if (utils.getType(adminIDs) === "String") {
13
- adminIDs = [adminIDs];
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
+ }
14
33
  }
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" };
22
- }
23
-
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);
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
91
41
  });
42
+ }
92
43
 
93
- return returnPromise;
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()));
94
46
  };
95
- };
47
+ };
@@ -3,17 +3,17 @@
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 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
- callback = function(err) {
16
+ callback = function (err) {
17
17
  if (err) return rejectFunc(err);
18
18
  resolveFunc();
19
19
  };
@@ -21,23 +21,17 @@ module.exports = function(defaultFuncs, api, ctx) {
21
21
 
22
22
  var form = {};
23
23
 
24
- if (utils.getType(threadOrThreads) === "Array")
25
- for (var i = 0; i < threadOrThreads.length; i++)
26
- form["ids[" + threadOrThreads[i] + "]"] = archive;
24
+ if (utils.getType(threadOrThreads) === "Array") for (var i = 0; i < threadOrThreads.length; i++) form["ids[" + threadOrThreads[i] + "]"] = archive;
27
25
  else form["ids[" + threadOrThreads + "]"] = archive;
28
26
 
29
27
  defaultFuncs
30
- .post(
31
- "https://www.facebook.com/ajax/mercury/change_archived_status.php",
32
- ctx.jar,
33
- form
34
- )
28
+ .post("https://www.facebook.com/ajax/mercury/change_archived_status.php", ctx.jar, form)
35
29
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
36
- .then(function(resData) {
30
+ .then(function (resData) {
37
31
  if (resData.error) throw resData;
38
32
  return callback();
39
33
  })
40
- .catch(function(err) {
34
+ .catch(function (err) {
41
35
  log.error("changeArchivedStatus", err);
42
36
  return callback(err);
43
37
  });
package/src/changeBio.js CHANGED
@@ -3,23 +3,19 @@
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 (
17
- utils.getType(publish) == "Function" ||
18
- utils.getType(publish) == "AsyncFunction"
19
- )
20
- callback = publish;
16
+ if (utils.getType(publish) == "Function" || utils.getType(publish) == "AsyncFunction") callback = publish;
21
17
  else {
22
- callback = function(err) {
18
+ callback = function (err) {
23
19
  if (err) return rejectFunc(err);
24
20
  resolveFunc();
25
21
  };
@@ -54,12 +50,11 @@ module.exports = function(defaultFuncs, api, ctx) {
54
50
  defaultFuncs
55
51
  .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
56
52
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
57
- .then(function(resData) {
53
+ .then(function (resData) {
58
54
  if (resData.errors) throw resData;
59
-
60
55
  return callback();
61
56
  })
62
- .catch(function(err) {
57
+ .catch(function (err) {
63
58
  log.error("changeBio", err);
64
59
  return callback(err);
65
60
  });
@@ -3,37 +3,31 @@
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) {
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(
24
- `https://www.facebook.com/messaging/${
25
- block ? "" : "un"
26
- }block_messages/`,
27
- ctx.jar,
28
- { fbid: userID }
29
- )
23
+ .post(`https://www.facebook.com/messaging/${block ? "" : "un"}block_messages/`, ctx.jar, { fbid: userID })
30
24
  .then(utils.saveCookies(ctx.jar))
31
25
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
32
- .then(function(resData) {
26
+ .then(function (resData) {
33
27
  if (resData.error) throw resData;
34
28
  return callback();
35
29
  })
36
- .catch(function(err) {
30
+ .catch(function (err) {
37
31
  log.error("changeBlockedStatus", err);
38
32
  return callback(err);
39
33
  });
@@ -4,7 +4,7 @@ var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
  var bluebird = require("bluebird");
6
6
 
7
- module.exports = function(defaultFuncs, api, ctx) {
7
+ module.exports = function (defaultFuncs, api, ctx) {
8
8
  function handleUpload(image, callback) {
9
9
  var uploads = [];
10
10
 
@@ -15,16 +15,10 @@ module.exports = function(defaultFuncs, api, ctx) {
15
15
 
16
16
  uploads.push(
17
17
  defaultFuncs
18
- .postFormData(
19
- "https://upload.facebook.com/ajax/mercury/upload.php",
20
- ctx.jar,
21
- form,
22
- {}
23
- )
18
+ .postFormData("https://upload.facebook.com/ajax/mercury/upload.php", ctx.jar, form, {})
24
19
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
25
- .then(function(resData) {
20
+ .then(function (resData) {
26
21
  if (resData.error) throw resData;
27
-
28
22
  return resData.payload.metadata[0];
29
23
  })
30
24
  );
@@ -33,29 +27,24 @@ module.exports = function(defaultFuncs, api, ctx) {
33
27
  bluebird
34
28
  .all(uploads)
35
29
  .then(resData => callback(null, resData))
36
- .catch(function(err) {
30
+ .catch(function (err) {
37
31
  log.error("handleUpload", err);
38
32
  return callback(err);
39
33
  });
40
34
  }
41
35
 
42
36
  return function changeGroupImage(image, threadID, callback) {
43
- if (
44
- !callback &&
45
- (utils.getType(threadID) === "Function" ||
46
- utils.getType(threadID) === "AsyncFunction")
47
- )
48
- throw { error: "please pass a threadID as a second argument." };
37
+ if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
49
38
 
50
- var resolveFunc = function() {};
51
- var rejectFunc = function() {};
52
- var returnPromise = new Promise(function(resolve, reject) {
39
+ var resolveFunc = function () { };
40
+ var rejectFunc = function () { };
41
+ var returnPromise = new Promise(function (resolve, reject) {
53
42
  resolveFunc = resolve;
54
43
  rejectFunc = reject;
55
44
  });
56
45
 
57
46
  if (!callback) {
58
- callback = function(err) {
47
+ callback = function (err) {
59
48
  if (err) return rejectFunc(err);
60
49
  resolveFunc();
61
50
  };
@@ -91,25 +80,21 @@ module.exports = function(defaultFuncs, api, ctx) {
91
80
  timestamp_time_passed: "0"
92
81
  };
93
82
 
94
- handleUpload(image, function(err, payload) {
83
+ handleUpload(image, function (err, payload) {
95
84
  if (err) return callback(err);
96
85
 
97
86
  form["thread_image_id"] = payload[0]["image_id"];
98
87
  form["thread_id"] = threadID;
99
88
 
100
89
  defaultFuncs
101
- .post(
102
- "https://www.facebook.com/messaging/set_thread_image/",
103
- ctx.jar,
104
- form
105
- )
90
+ .post("https://www.facebook.com/messaging/set_thread_image/", ctx.jar, form)
106
91
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
107
- .then(function(resData) {
92
+ .then(function (resData) {
108
93
  // check for errors here
109
94
  if (resData.error) throw resData;
110
95
  return callback();
111
96
  })
112
- .catch(function(err) {
97
+ .catch(function (err) {
113
98
  log.error("changeGroupImage", err);
114
99
  return callback(err);
115
100
  });
@@ -3,16 +3,16 @@
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 changeNickname(nickname, threadID, participantID, 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
  if (!callback) {
15
- callback = function(err) {
15
+ callback = function (err) {
16
16
  if (err) return rejectFunc(err);
17
17
  resolveFunc();
18
18
  };
@@ -25,27 +25,16 @@ module.exports = function(defaultFuncs, api, ctx) {
25
25
  };
26
26
 
27
27
  defaultFuncs
28
- .post(
29
- "https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1",
30
- ctx.jar,
31
- form
32
- )
28
+ .post("https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1", ctx.jar, form)
33
29
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
34
- .then(function(resData) {
35
- if (resData.error === 1545014)
36
- throw { error: "Trying to change nickname of user isn't in thread" };
37
- if (resData.error === 1357031)
38
- throw {
39
- error:
40
- "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."
41
- };
42
-
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." };
43
33
  if (resData.error) throw resData;
44
-
45
34
  return callback();
46
35
  })
47
- .catch(function(err) {
48
- log.error("changeNickname", err);
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.");
49
38
  return callback(err);
50
39
  });
51
40