alicezetion 1.0.9 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -1
  2. package/.cache/replit/nix/env.json +1 -1
  3. package/index.js +558 -490
  4. package/leiamnash/addExternalModule.js +19 -0
  5. package/{src → leiamnash}/addUserToGroup.js +52 -16
  6. package/leiamnash/changeAdminStatus.js +79 -0
  7. package/leiamnash/changeArchivedStatus.js +55 -0
  8. package/{src → leiamnash}/changeBio.js +19 -6
  9. package/{src → leiamnash}/changeBlockedStatus.js +14 -3
  10. package/{src → leiamnash}/changeGroupImage.js +40 -16
  11. package/leiamnash/changeNickname.js +59 -0
  12. package/{src → leiamnash}/changeThreadColor.js +20 -10
  13. package/leiamnash/changeThreadEmoji.js +55 -0
  14. package/leiamnash/chat.js +459 -0
  15. package/{src → leiamnash}/createNewGroup.js +28 -12
  16. package/{src → leiamnash}/createPoll.js +25 -13
  17. package/leiamnash/deleteMessage.js +56 -0
  18. package/leiamnash/deleteThread.js +56 -0
  19. package/leiamnash/forwardAttachment.js +60 -0
  20. package/{src → leiamnash}/getCurrentUserID.js +1 -1
  21. package/{src → leiamnash}/getEmojiUrl.js +4 -2
  22. package/{src → leiamnash}/getFriendsList.js +21 -10
  23. package/{src → leiamnash}/getThreadHistory.js +166 -58
  24. package/{src → leiamnash}/getThreadHistoryDeprecated.js +42 -20
  25. package/{src → leiamnash}/getThreadInfo.js +60 -25
  26. package/leiamnash/getThreadInfoDeprecated.js +80 -0
  27. package/{src → leiamnash}/getThreadList.js +66 -41
  28. package/leiamnash/getThreadListDeprecated.js +75 -0
  29. package/leiamnash/getThreadPictures.js +79 -0
  30. package/{src → leiamnash}/getUserID.js +14 -9
  31. package/{src → leiamnash}/getUserInfo.js +18 -12
  32. package/leiamnash/handleFriendRequest.js +61 -0
  33. package/leiamnash/handleMessageRequest.js +65 -0
  34. package/{src → leiamnash}/httpGet.js +17 -12
  35. package/{src → leiamnash}/httpPost.js +17 -12
  36. package/leiamnash/listenMqtt.js +687 -0
  37. package/{src → leiamnash}/logout.js +20 -13
  38. package/{src → leiamnash}/markAsDelivered.js +22 -11
  39. package/{src → leiamnash}/markAsRead.js +21 -11
  40. package/{src → leiamnash}/markAsReadAll.js +20 -10
  41. package/{src → leiamnash}/markAsSeen.js +18 -7
  42. package/{src → leiamnash}/muteThread.js +18 -11
  43. package/leiamnash/removeUserFromGroup.js +79 -0
  44. package/{src → leiamnash}/resolvePhotoUrl.js +17 -8
  45. package/{src → leiamnash}/searchForThread.js +21 -10
  46. package/{src → leiamnash}/sendTypingIndicator.js +47 -14
  47. package/{src → leiamnash}/setMessageReaction.js +26 -12
  48. package/{src → leiamnash}/setPostReaction.js +26 -13
  49. package/{src → leiamnash}/setTitle.js +29 -13
  50. package/leiamnash/threadColors.js +57 -0
  51. package/{src → leiamnash}/unfriend.js +19 -9
  52. package/{src → leiamnash}/unsendMessage.js +19 -9
  53. package/package.json +9 -14
  54. package/replit.nix +0 -1
  55. package/utils.js +1193 -1023
  56. package/src/addExternalModule.js +0 -15
  57. package/src/changeAdminStatus.js +0 -47
  58. package/src/changeArchivedStatus.js +0 -41
  59. package/src/changeNickname.js +0 -43
  60. package/src/changeThreadEmoji.js +0 -41
  61. package/src/chat.js +0 -315
  62. package/src/deleteMessage.js +0 -44
  63. package/src/deleteThread.js +0 -42
  64. package/src/forwardAttachment.js +0 -47
  65. package/src/forwardMessage.js +0 -0
  66. package/src/getThreadInfoDeprecated.js +0 -56
  67. package/src/getThreadListDeprecated.js +0 -46
  68. package/src/getThreadPictures.js +0 -59
  69. package/src/handleFriendRequest.js +0 -46
  70. package/src/handleMessageRequest.js +0 -47
  71. package/src/listen.js +0 -553
  72. package/src/listenMqtt-Test.js +0 -687
  73. package/src/listenMqtt.js +0 -677
  74. package/src/removeUserFromGroup.js +0 -45
  75. package/src/threadColors.js +0 -41
@@ -3,19 +3,21 @@
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 setMessageReaction(reaction, messageID, callback, forceCustomReaction) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
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, data) {
17
- if (err) return rejectFunc(err);
18
- resolveFunc(data);
16
+ callback = function (err, friendList) {
17
+ if (err) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc(friendList);
19
21
  };
20
22
  }
21
23
 
@@ -66,7 +68,9 @@ module.exports = function (defaultFuncs, api, ctx) {
66
68
  reaction = "\uD83D\uDC97";
67
69
  break;
68
70
  default:
69
- if (forceCustomReaction) break;
71
+ if (forceCustomReaction) {
72
+ break;
73
+ }
70
74
  return callback({ error: "Reaction is not a valid emoji." });
71
75
  }
72
76
 
@@ -87,17 +91,27 @@ module.exports = function (defaultFuncs, api, ctx) {
87
91
  };
88
92
 
89
93
  defaultFuncs
90
- .postFormData("https://www.facebook.com/webgraphql/mutation/", ctx.jar, {}, qs)
94
+ .postFormData(
95
+ "https://www.facebook.com/webgraphql/mutation/",
96
+ ctx.jar,
97
+ {},
98
+ qs
99
+ )
91
100
  .then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
92
- .then(function (resData) {
93
- if (!resData) throw { error: "setReaction returned empty object." };
94
- if (resData.error) throw resData;
101
+ .then(function(resData) {
102
+ if (!resData) {
103
+ throw { error: "setReaction returned empty object." };
104
+ }
105
+ if (resData.error) {
106
+ throw resData;
107
+ }
95
108
  callback(null);
96
109
  })
97
- .catch(function (err) {
110
+ .catch(function(err) {
98
111
  log.error("setReaction", err);
99
112
  return callback(err);
100
113
  });
114
+
101
115
  return returnPromise;
102
116
  };
103
117
  };
@@ -3,19 +3,21 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return function setPostReaction(postID, type, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
+ return function unsendMessage(postID, type, callback) {
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
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, data) {
17
- if (err) return rejectFunc(err);
18
- resolveFunc(data);
16
+ callback = function (err, friendList) {
17
+ if (err) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc(friendList);
19
21
  };
20
22
  }
21
23
 
@@ -29,7 +31,9 @@ module.exports = function (defaultFuncs, api, ctx) {
29
31
  };
30
32
  if (typeof type != "number") {
31
33
  type = map[type.toLocaleLowerCase()];
32
- if (!type) type = 1;
34
+ if (!type) {
35
+ type = 1;
36
+ }
33
37
  }
34
38
  var form = {
35
39
  av: ctx.userID,
@@ -41,23 +45,32 @@ module.exports = function (defaultFuncs, api, ctx) {
41
45
  input: {
42
46
  client_mutation_id: "7",
43
47
  actor_id: ctx.userID,
44
- feedback_reaction: type
48
+ feedback_reaction: type,
49
+
45
50
  },
46
51
  useDefaultActor: true
47
52
  })
48
53
  };
49
54
 
50
55
  defaultFuncs
51
- .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
56
+ .post(
57
+ "https://www.facebook.com/api/graphql/",
58
+ ctx.jar,
59
+ form
60
+ )
52
61
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
53
- .then(function (resData) {
54
- if (resData.error) throw resData;
62
+ .then(function(resData) {
63
+ if (resData.error) {
64
+ throw resData;
65
+ }
66
+
55
67
  return callback();
56
68
  })
57
- .catch(function (err) {
69
+ .catch(function(err) {
58
70
  log.error("setPostReaction", err);
59
71
  return callback(err);
60
72
  });
73
+
61
74
  return returnPromise;
62
75
  };
63
76
  };
@@ -3,23 +3,29 @@
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 setTitle(newTitle, threadID, callback) {
8
- if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction"))
8
+ if (
9
+ !callback &&
10
+ (utils.getType(threadID) === "Function" ||
11
+ utils.getType(threadID) === "AsyncFunction")
12
+ ) {
9
13
  throw { error: "please pass a threadID as a second argument." };
14
+ }
10
15
 
11
-
12
- var resolveFunc = function () { };
13
- var rejectFunc = function () { };
16
+ var resolveFunc = function(){};
17
+ var rejectFunc = function(){};
14
18
  var returnPromise = new Promise(function (resolve, reject) {
15
19
  resolveFunc = resolve;
16
20
  rejectFunc = reject;
17
21
  });
18
22
 
19
23
  if (!callback) {
20
- callback = function (err, data) {
21
- if (err) return rejectFunc(err);
22
- resolveFunc(data);
24
+ callback = function (err, friendList) {
25
+ if (err) {
26
+ return rejectFunc(err);
27
+ }
28
+ resolveFunc(friendList);
23
29
  };
24
30
  }
25
31
 
@@ -55,16 +61,26 @@ module.exports = function (defaultFuncs, api, ctx) {
55
61
  defaultFuncs
56
62
  .post("https://www.facebook.com/messaging/set_thread_name/", ctx.jar, form)
57
63
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
58
- .then(function (resData) {
59
- if (resData.error && resData.error === 1545012) throw { error: "Cannot change chat title: Not member of chat." };
60
- if (resData.error && resData.error === 1545003) throw { error: "Cannot set title of single-user chat." };
61
- if (resData.error) throw resData;
64
+ .then(function(resData) {
65
+ if (resData.error && resData.error === 1545012) {
66
+ throw { error: "Cannot change chat title: Not member of chat." };
67
+ }
68
+
69
+ if (resData.error && resData.error === 1545003) {
70
+ throw { error: "Cannot set title of single-user chat." };
71
+ }
72
+
73
+ if (resData.error) {
74
+ throw resData;
75
+ }
76
+
62
77
  return callback();
63
78
  })
64
- .catch(function (err) {
79
+ .catch(function(err) {
65
80
  log.error("setTitle", err);
66
81
  return callback(err);
67
82
  });
83
+
68
84
  return returnPromise;
69
85
  };
70
86
  };
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ module.exports = function(_defaultFuncs, _api, _ctx) {
4
+ // Currently the only colors that can be passed to api.changeThreadColor(); may change if Facebook adds more
5
+ return {
6
+ //Old hex colors.
7
+ ////MessengerBlue: null,
8
+ ////Viking: "#44bec7",
9
+ ////GoldenPoppy: "#ffc300",
10
+ ////RadicalRed: "#fa3c4c",
11
+ ////Shocking: "#d696bb",
12
+ ////PictonBlue: "#6699cc",
13
+ ////FreeSpeechGreen: "#13cf13",
14
+ ////Pumpkin: "#ff7e29",
15
+ ////LightCoral: "#e68585",
16
+ ////MediumSlateBlue: "#7646ff",
17
+ ////DeepSkyBlue: "#20cef5",
18
+ ////Fern: "#67b868",
19
+ ////Cameo: "#d4a88c",
20
+ ////BrilliantRose: "#ff5ca1",
21
+ ////BilobaFlower: "#a695c7"
22
+
23
+ //#region This part is for backward compatibly
24
+ //trying to match the color one-by-one. kill me plz
25
+ MessengerBlue: "196241301102133", //DefaultBlue
26
+ Viking: "1928399724138152", //TealBlue
27
+ GoldenPoppy: "174636906462322", //Yellow
28
+ RadicalRed: "2129984390566328", //Red
29
+ Shocking: "2058653964378557", //LavenderPurple
30
+ FreeSpeechGreen: "2136751179887052", //Green
31
+ Pumpkin: "175615189761153", //Orange
32
+ LightCoral: "980963458735625", //CoralPink
33
+ MediumSlateBlue: "234137870477637", //BrightPurple
34
+ DeepSkyBlue: "2442142322678320", //AquaBlue
35
+ BrilliantRose: "169463077092846", //HotPink
36
+ //i've tried my best, everything else can't be mapped. (or is it?) -UIRI 2020
37
+ //#endregion
38
+
39
+ DefaultBlue: "196241301102133",
40
+ HotPink: "169463077092846",
41
+ AquaBlue: "2442142322678320",
42
+ BrightPurple: "234137870477637",
43
+ CoralPink: "980963458735625",
44
+ Orange: "175615189761153",
45
+ Green: "2136751179887052",
46
+ LavenderPurple: "2058653964378557",
47
+ Red: "2129984390566328",
48
+ Yellow: "174636906462322",
49
+ TealBlue: "1928399724138152",
50
+ Aqua: "417639218648241",
51
+ Mango: "930060997172551",
52
+ Berry: "164535220883264",
53
+ Citrus: "370940413392601",
54
+ Candy: "205488546921017",
55
+ //StarWars: "809305022860427" Removed.
56
+ };
57
+ };
@@ -3,10 +3,10 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return function unfriend(userID, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
+ return function unsendMessage(userID, callback) {
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
10
  var returnPromise = new Promise(function (resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
@@ -14,7 +14,9 @@ module.exports = function (defaultFuncs, api, ctx) {
14
14
 
15
15
  if (!callback) {
16
16
  callback = function (err, friendList) {
17
- if (err) return rejectFunc(err);
17
+ if (err) {
18
+ return rejectFunc(err);
19
+ }
18
20
  resolveFunc(friendList);
19
21
  };
20
22
  }
@@ -27,16 +29,24 @@ module.exports = function (defaultFuncs, api, ctx) {
27
29
  };
28
30
 
29
31
  defaultFuncs
30
- .post("https://www.facebook.com/ajax/profile/removefriendconfirm.php", ctx.jar, form)
32
+ .post(
33
+ "https://www.facebook.com/ajax/profile/removefriendconfirm.php",
34
+ ctx.jar,
35
+ form
36
+ )
31
37
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
32
- .then(function (resData) {
33
- if (resData.error) throw resData;
38
+ .then(function(resData) {
39
+ if (resData.error) {
40
+ throw resData;
41
+ }
42
+
34
43
  return callback();
35
44
  })
36
- .catch(function (err) {
45
+ .catch(function(err) {
37
46
  log.error("unfriend", err);
38
47
  return callback(err);
39
48
  });
49
+
40
50
  return returnPromise;
41
51
  };
42
52
  };
@@ -3,10 +3,10 @@
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 unsendMessage(messageID, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
10
  var returnPromise = new Promise(function (resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
@@ -14,7 +14,9 @@ module.exports = function (defaultFuncs, api, ctx) {
14
14
 
15
15
  if (!callback) {
16
16
  callback = function (err, friendList) {
17
- if (err) return rejectFunc(err);
17
+ if (err) {
18
+ return rejectFunc(err);
19
+ }
18
20
  resolveFunc(friendList);
19
21
  };
20
22
  }
@@ -24,16 +26,24 @@ module.exports = function (defaultFuncs, api, ctx) {
24
26
  };
25
27
 
26
28
  defaultFuncs
27
- .post("https://www.facebook.com/messaging/unsend_message/", ctx.jar, form)
29
+ .post(
30
+ "https://www.facebook.com/messaging/unsend_message/",
31
+ ctx.jar,
32
+ form
33
+ )
28
34
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
29
- .then(function (resData) {
30
- if (resData.error) throw resData;
35
+ .then(function(resData) {
36
+ if (resData.error) {
37
+ throw resData;
38
+ }
39
+
31
40
  return callback();
32
41
  })
33
- .catch(function (err) {
34
- log.error("unsendMessage", "» ParseAndCheckLogin got status code: 404. Bailing out of trying to parse response.");
42
+ .catch(function(err) {
43
+ log.error("unsendMessage", err);
35
44
  return callback(err);
36
45
  });
46
+
37
47
  return returnPromise;
38
48
  };
39
49
  };
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "alicezetion",
3
- "version": "1.0.9",
4
- "description": "Artificial labile intelligence cybernated existence",
3
+ "version": "1.1.1",
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": ""
@@ -33,9 +33,9 @@
33
33
  "node": ">=10.x"
34
34
  },
35
35
  "devDependencies": {
36
- "eslint": "latest",
37
- "mocha": "latest",
38
- "prettier": "latest"
36
+ "eslint": "^7.5.0",
37
+ "mocha": "^7.0.1",
38
+ "prettier": "^1.11.1"
39
39
  },
40
40
  "eslintConfig": {
41
41
  "env": {
@@ -70,10 +70,5 @@
70
70
  }
71
71
  ]
72
72
  }
73
- },
74
- "homepage": "https://replit.com/@LeiamNashRebirth/alice",
75
- "main": "index.js",
76
- "directories": {
77
- "test": "test"
78
73
  }
79
74
  }
package/replit.nix CHANGED
@@ -1,6 +1,5 @@
1
1
  { pkgs }: {
2
2
  deps = [
3
3
  pkgs.nodejs-16_x
4
- pkgs.unzip
5
4
  ];
6
5
  }