alicezetion 1.7.7 → 1.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -1
  2. package/index.js +570 -493
  3. package/leiamnash/chat.js +452 -0
  4. package/leiamnash/listenMqtt.js +843 -0
  5. package/leiamnash/react.js +109 -0
  6. package/leiamnash/refreshFb_dtsg.js +81 -0
  7. package/leiamnash/seen.js +40 -0
  8. package/package.json +8 -15
  9. package/utils.js +1338 -1047
  10. package/src/chat.js +0 -315
  11. package/src/listen.js +0 -553
  12. package/src/listenMqtt-Test.js +0 -687
  13. package/src/listenMqtt.js +0 -677
  14. package/test/data/shareAttach.js +0 -146
  15. package/test/data/something.mov +0 -0
  16. package/test/data/test.png +0 -0
  17. package/test/data/test.txt +0 -7
  18. package/test/example-config.json +0 -18
  19. package/test/test-page.js +0 -140
  20. package/test/test.js +0 -385
  21. /package/{src → leiamnash}/addExternalModule.js +0 -0
  22. /package/{src → leiamnash}/addUserToGroup.js +0 -0
  23. /package/{src → leiamnash}/changeAdminStatus.js +0 -0
  24. /package/{src → leiamnash}/changeArchivedStatus.js +0 -0
  25. /package/{src → leiamnash}/changeBio.js +0 -0
  26. /package/{src → leiamnash}/changeBlockedStatus.js +0 -0
  27. /package/{src → leiamnash}/changeGroupImage.js +0 -0
  28. /package/{src → leiamnash}/changeNickname.js +0 -0
  29. /package/{src → leiamnash}/changeThreadColor.js +0 -0
  30. /package/{src → leiamnash}/changeThreadEmoji.js +0 -0
  31. /package/{src → leiamnash}/createNewGroup.js +0 -0
  32. /package/{src → leiamnash}/createPoll.js +0 -0
  33. /package/{src → leiamnash}/deleteMessage.js +0 -0
  34. /package/{src → leiamnash}/deleteThread.js +0 -0
  35. /package/{src → leiamnash}/forwardAttachment.js +0 -0
  36. /package/{src → leiamnash}/forwardMessage.js +0 -0
  37. /package/{src → leiamnash}/getCurrentUserID.js +0 -0
  38. /package/{src → leiamnash}/getEmojiUrl.js +0 -0
  39. /package/{src → leiamnash}/getFriendsList.js +0 -0
  40. /package/{src → leiamnash}/getThreadHistory.js +0 -0
  41. /package/{src → leiamnash}/getThreadHistoryDeprecated.js +0 -0
  42. /package/{src → leiamnash}/getThreadInfo.js +0 -0
  43. /package/{src → leiamnash}/getThreadInfoDeprecated.js +0 -0
  44. /package/{src → leiamnash}/getThreadList.js +0 -0
  45. /package/{src → leiamnash}/getThreadListDeprecated.js +0 -0
  46. /package/{src → leiamnash}/getThreadPictures.js +0 -0
  47. /package/{src → leiamnash}/getUserID.js +0 -0
  48. /package/{src → leiamnash}/getUserInfo.js +0 -0
  49. /package/{src → leiamnash}/handleFriendRequest.js +0 -0
  50. /package/{src → leiamnash}/handleMessageRequest.js +0 -0
  51. /package/{src → leiamnash}/httpGet.js +0 -0
  52. /package/{src → leiamnash}/httpPost.js +0 -0
  53. /package/{src → leiamnash}/logout.js +0 -0
  54. /package/{src → leiamnash}/markAsDelivered.js +0 -0
  55. /package/{src → leiamnash}/markAsRead.js +0 -0
  56. /package/{src → leiamnash}/markAsReadAll.js +0 -0
  57. /package/{src → leiamnash}/markAsSeen.js +0 -0
  58. /package/{src → leiamnash}/muteThread.js +0 -0
  59. /package/{src → leiamnash}/removeUserFromGroup.js +0 -0
  60. /package/{src → leiamnash}/resolvePhotoUrl.js +0 -0
  61. /package/{src → leiamnash}/searchForThread.js +0 -0
  62. /package/{src → leiamnash}/sendMessage.js +0 -0
  63. /package/{src → leiamnash}/sendTypingIndicator.js +0 -0
  64. /package/{src → leiamnash}/setMessageReaction.js +0 -0
  65. /package/{src → leiamnash}/setPostReaction.js +0 -0
  66. /package/{src → leiamnash}/setTitle.js +0 -0
  67. /package/{src → leiamnash}/threadColors.js +0 -0
  68. /package/{src → leiamnash}/unfriend.js +0 -0
  69. /package/{src → leiamnash}/unsendMessage.js +0 -0
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ return function setMessageReaction(reaction, messageID, callback, forceCustomReaction) {
8
+ var resolveFunc = function () { };
9
+ var rejectFunc = function () { };
10
+ var returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
+
15
+ if (!callback) {
16
+ callback = function (err, data) {
17
+ if (err) return rejectFunc(err);
18
+ resolveFunc(data);
19
+ };
20
+ }
21
+
22
+ switch (reaction) {
23
+ case "\uD83D\uDE0D": //:heart_eyes:
24
+ case "\uD83D\uDE06": //:laughing:
25
+ case "\uD83D\uDE2E": //:open_mouth:
26
+ case "\uD83D\uDE22": //:cry:
27
+ case "\uD83D\uDE20": //:angry:
28
+ case "\uD83D\uDC4D": //:thumbsup:
29
+ case "\uD83D\uDC4E": //:thumbsdown:
30
+ case "\u2764": //:heart:
31
+ case "\uD83D\uDC97": //:glowingheart:
32
+ case "":
33
+ //valid
34
+ break;
35
+ case ":heart_eyes:":
36
+ case ":love:":
37
+ reaction = "\uD83D\uDE0D";
38
+ break;
39
+ case ":laughing:":
40
+ case ":haha:":
41
+ reaction = "\uD83D\uDE06";
42
+ break;
43
+ case ":open_mouth:":
44
+ case ":wow:":
45
+ reaction = "\uD83D\uDE2E";
46
+ break;
47
+ case ":cry:":
48
+ case ":sad:":
49
+ reaction = "\uD83D\uDE22";
50
+ break;
51
+ case ":angry:":
52
+ reaction = "\uD83D\uDE20";
53
+ break;
54
+ case ":thumbsup:":
55
+ case ":like:":
56
+ reaction = "\uD83D\uDC4D";
57
+ break;
58
+ case ":thumbsdown:":
59
+ case ":dislike:":
60
+ reaction = "\uD83D\uDC4E";
61
+ break;
62
+ case ":heart:":
63
+ reaction = "\u2764";
64
+ break;
65
+ case ":glowingheart:":
66
+ reaction = "\uD83D\uDC97";
67
+ break;
68
+ default:
69
+ if (forceCustomReaction) break;
70
+ return callback({ error: "Reaction is not a valid emoji." });
71
+ }
72
+
73
+ var variables = {
74
+ data: {
75
+ client_mutation_id: ctx.clientMutationId++,
76
+ actor_id: ctx.userID,
77
+ action: reaction == "" ? "REMOVE_REACTION" : "ADD_REACTION",
78
+ message_id: messageID,
79
+ reaction: reaction
80
+ }
81
+ };
82
+
83
+ var qs = {
84
+ doc_id: "1491398900900362",
85
+ variables: JSON.stringify(variables),
86
+ dpr: 1
87
+ };
88
+
89
+ defaultFuncs
90
+ .postFormData(
91
+ "https://www.facebook.com/webgraphql/mutation/",
92
+ ctx.jar,
93
+ {},
94
+ qs
95
+ )
96
+ .then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
97
+ .then(function (resData) {
98
+ if (!resData) throw { error: "setReaction returned empty object." };
99
+ if (resData.error) throw resData;
100
+ callback(null);
101
+ })
102
+ .catch(function (err) {
103
+ log.error("setReaction", err);
104
+ return callback(err);
105
+ });
106
+
107
+ return returnPromise;
108
+ };
109
+ };
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ const log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ /**
8
+ * Refreshes the fb_dtsg and jazoest values.
9
+ * @param {Function} callback
10
+ * @returns {Promise}
11
+ * @description if you don't update the value of fb_dtsg and jazoest for a long time an error "Please try closing and re-opening your browser window" will appear
12
+ * @description you should refresh it every 48h or less
13
+ */
14
+ return function refreshFb_dtsg(obj, callback) {
15
+ let resolveFunc = function () { };
16
+ let rejectFunc = function () { };
17
+ const returnPromise = new Promise(function (resolve, reject) {
18
+ resolveFunc = resolve;
19
+ rejectFunc = reject;
20
+ });
21
+
22
+ if (utils.getType(obj) === "Function" || utils.getType(obj) === "AsyncFunction") {
23
+ callback = obj;
24
+ obj = {};
25
+ }
26
+
27
+ if (!obj) {
28
+ obj = {};
29
+ }
30
+
31
+ if (utils.getType(obj) !== "Object") {
32
+ throw new utils.CustomError("the first parameter must be an object or a callback function");
33
+ }
34
+
35
+ if (!callback) {
36
+ callback = function (err, friendList) {
37
+ if (err) {
38
+ return rejectFunc(err);
39
+ }
40
+ resolveFunc(friendList);
41
+ };
42
+ }
43
+
44
+ if (Object.keys(obj).length == 0) {
45
+ utils
46
+ .get('https://m.facebook.com/', ctx.jar, null, ctx.globalOptions, { noRef: true })
47
+ .then(function (resData) {
48
+ const html = resData.body;
49
+ const fb_dtsg = utils.getFrom(html, 'name="fb_dtsg" value="', '"');
50
+ const jazoest = utils.getFrom(html, 'name="jazoest" value="', '"');
51
+ if (!fb_dtsg) {
52
+ throw new utils.CustomError("Could not find fb_dtsg in HTML after requesting https://www.facebook.com/");
53
+ }
54
+ ctx.fb_dtsg = fb_dtsg;
55
+ ctx.jazoest = jazoest;
56
+ callback(null, {
57
+ data: {
58
+ fb_dtsg: fb_dtsg,
59
+ jazoest: jazoest
60
+ },
61
+ message: "refreshed fb_dtsg and jazoest"
62
+ });
63
+ })
64
+ .catch(function (err) {
65
+ log.error("refreshFb_dtsg", err);
66
+ return callback(err);
67
+ });
68
+ }
69
+ else {
70
+ Object.keys(obj).forEach(function (key) {
71
+ ctx[key] = obj[key];
72
+ });
73
+ callback(null, {
74
+ data: obj,
75
+ message: "refreshed " + Object.keys(obj).join(", ")
76
+ });
77
+ }
78
+
79
+ return returnPromise;
80
+ };
81
+ };
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ return function markAsReadAll(callback) {
8
+ var resolveFunc = function () { };
9
+ var rejectFunc = function () { };
10
+ var returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
+
15
+ if (!callback) {
16
+ callback = function (err, data) {
17
+ if (err) return rejectFunc(err);
18
+ resolveFunc(data);
19
+ };
20
+ }
21
+
22
+ var form = {
23
+ folder: 'inbox'
24
+ };
25
+
26
+ defaultFuncs
27
+ .post("https://www.facebook.com/ajax/mercury/mark_folder_as_read.php", ctx.jar, form)
28
+ .then(utils.saveCookies(ctx.jar))
29
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
30
+ .then(function (resData) {
31
+ if (resData.error) throw resData;
32
+ return callback();
33
+ })
34
+ .catch(function (err) {
35
+ log.error("markAsReadAll", err);
36
+ return callback(err);
37
+ });
38
+ return returnPromise;
39
+ };
40
+ };
package/package.json CHANGED
@@ -1,11 +1,9 @@
1
1
  {
2
2
  "name": "alicezetion",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
4
4
  "description": "",
5
5
  "scripts": {
6
- "test": "mocha",
7
- "lint": "./node_modules/.bin/eslint **.js",
8
- "prettier": "prettier utils.js src/* --write"
6
+ "start": "node index.js"
9
7
  },
10
8
  "repository": {
11
9
  "type": "git",
@@ -22,21 +20,16 @@
22
20
  "license": "MIT",
23
21
  "dependencies": {
24
22
  "bluebird": "^2.11.0",
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"
23
+ "cheerio": "^1.0.0-rc.12",
24
+ "https-proxy-agent": "^5.0.1",
25
+ "mqtt": "^4.3.7",
26
+ "npmlog": "^7.0.1",
27
+ "request": "^2.88.2",
28
+ "websocket-stream": "^5.5.2"
31
29
  },
32
30
  "engines": {
33
31
  "node": ">=10.x"
34
32
  },
35
- "devDependencies": {
36
- "eslint": "^7.5.0",
37
- "mocha": "^7.0.1",
38
- "prettier": "^1.11.1"
39
- },
40
33
  "eslintConfig": {
41
34
  "env": {
42
35
  "es6": true,