fca-candy-darkster 0.0.1-security → 25.0.3

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.

Potentially problematic release.


This version of fca-candy-darkster might be problematic. Click here for more details.

Files changed (92) hide show
  1. package/API/anup.json +12 -0
  2. package/API/candy.json +12 -0
  3. package/CHANGELOG.md +2 -0
  4. package/Controllers/Remote.js +3 -0
  5. package/CountTime.json +1 -0
  6. package/DOCS.md +1738 -0
  7. package/Extra/ExtraAddons.js +78 -0
  8. package/Extra/ExtraFindUID.js +60 -0
  9. package/Extra/ExtraGetThread.js +118 -0
  10. package/Extra/ExtraTranslate.js +60 -0
  11. package/Extra/ExtraUptimeRobot.js +59 -0
  12. package/Extra/Html/Classic/script.js +231 -0
  13. package/Extra/Html/Classic/style.css +8 -0
  14. package/Extra/PM2/ecosystem.config.js +23 -0
  15. package/Extra/Security/Index.js +174 -0
  16. package/Extra/Security/Step_1.js +15 -0
  17. package/Extra/Security/Step_2.js +23 -0
  18. package/Extra/Security/Step_3.js +23 -0
  19. package/Extra/Src/History.js +115 -0
  20. package/Extra/Src/Last-Run.js +65 -0
  21. package/Extra/Src/Premium.js +98 -0
  22. package/Extra/Src/SecurityCheck.js +2 -0
  23. package/Func/AcceptAgreement.js +32 -0
  24. package/Func/ClearCache.js +63 -0
  25. package/Func/ReportV1.js +54 -0
  26. package/LICENSE.md +23 -0
  27. package/Language/index.json +217 -0
  28. package/OldSecurity.js +100 -0
  29. package/README.md +118 -3
  30. package/Settings/Database.js +21 -0
  31. package/Settings/Location.js +59 -0
  32. package/broadcast.js +40 -0
  33. package/index.js +1349 -0
  34. package/logger.js +65 -0
  35. package/package.json +208 -3
  36. package/src/Premium.js +30 -0
  37. package/src/addExternalModule.js +16 -0
  38. package/src/addUserToGroup.js +78 -0
  39. package/src/changeAdminStatus.js +79 -0
  40. package/src/changeArchivedStatus.js +41 -0
  41. package/src/changeAvt.js +85 -0
  42. package/src/changeBio.js +65 -0
  43. package/src/changeBlockedStatus.js +36 -0
  44. package/src/changeGroupImage.js +106 -0
  45. package/src/changeNickname.js +45 -0
  46. package/src/changeThreadColor.js +62 -0
  47. package/src/changeThreadEmoji.js +42 -0
  48. package/src/createNewGroup.js +70 -0
  49. package/src/createPoll.js +60 -0
  50. package/src/deleteMessage.js +45 -0
  51. package/src/deleteThread.js +43 -0
  52. package/src/forwardAttachment.js +48 -0
  53. package/src/getAccessToken.js +32 -0
  54. package/src/getCurrentUserID.js +7 -0
  55. package/src/getEmojiUrl.js +27 -0
  56. package/src/getFriendsList.js +73 -0
  57. package/src/getMessage.js +80 -0
  58. package/src/getThreadHistory.js +537 -0
  59. package/src/getThreadInfo.js +232 -0
  60. package/src/getThreadList.js +213 -0
  61. package/src/getThreadPictures.js +59 -0
  62. package/src/getUID.js +53 -0
  63. package/src/getUserID.js +62 -0
  64. package/src/getUserInfo.js +65 -0
  65. package/src/getUserInfoV2.js +35 -0
  66. package/src/getUserInfoV3.js +63 -0
  67. package/src/getUserInfoV4.js +55 -0
  68. package/src/getUserInfoV5.js +61 -0
  69. package/src/handleFriendRequest.js +46 -0
  70. package/src/handleMessageRequest.js +49 -0
  71. package/src/httpGet.js +49 -0
  72. package/src/httpPost.js +48 -0
  73. package/src/httpPostFormData.js +41 -0
  74. package/src/listenMqtt.js +725 -0
  75. package/src/logout.js +68 -0
  76. package/src/markAsDelivered.js +48 -0
  77. package/src/markAsRead.js +70 -0
  78. package/src/markAsReadAll.js +43 -0
  79. package/src/markAsSeen.js +51 -0
  80. package/src/muteThread.js +47 -0
  81. package/src/removeUserFromGroup.js +49 -0
  82. package/src/resolvePhotoUrl.js +37 -0
  83. package/src/searchForThread.js +43 -0
  84. package/src/sendMessage.js +334 -0
  85. package/src/sendTypingIndicator.js +80 -0
  86. package/src/setMessageReaction.js +109 -0
  87. package/src/setPostReaction.js +102 -0
  88. package/src/setTitle.js +74 -0
  89. package/src/threadColors.js +39 -0
  90. package/src/unfriend.js +43 -0
  91. package/src/unsendMessage.js +40 -0
  92. package/utils.js +1708 -0
package/logger.js ADDED
@@ -0,0 +1,65 @@
1
+ /* eslint-disable linebreak-style */
2
+
3
+ const chalk = require('chalk');
4
+ var isHexcolor = require('is-hexcolor');
5
+ var getText = function(/** @type {string[]} */ ...Data) {
6
+ var Main = (Data.splice(0,1)).toString();
7
+ for (let i = 0; i < Data.length; i++) Main = Main.replace(RegExp(`%${i + 1}`, 'g'), Data[i]);
8
+ return Main;
9
+ };
10
+ /**
11
+ * @param {any} obj
12
+ */
13
+ function getType(obj) {
14
+ return Object.prototype.toString.call(obj).slice(8, -1);
15
+ }
16
+
17
+ module.exports = {
18
+ Normal: function(/** @type {string} */ Str, /** @type {() => any} */ Data ,/** @type {() => void} */ Callback) {
19
+ if (isHexcolor(globalThis.Fca.Require.FastConfig.MainColor) != true) {
20
+ this.Warning(getText(globalThis.Fca.Require.Language.Index.InvaildMainColor,globalThis.Fca.Require.FastConfig.MainColor),process.exit(0));
21
+ }
22
+ else console.log(chalk.hex(globalThis.Fca.Require.FastConfig.MainColor).bold(`${globalThis.Fca.Require.FastConfig.MainName || '[ FCA-CANDY ]'} > `) + Str);
23
+ if (getType(Data) == 'Function' || getType(Data) == 'AsyncFunction') {
24
+ return Data()
25
+ }
26
+ if (Data) {
27
+ return Data;
28
+ }
29
+ if (getType(Callback) == 'Function' || getType(Callback) == 'AsyncFunction') {
30
+ Callback();
31
+ }
32
+ else return Callback;
33
+ },
34
+ Warning: function(/** @type {unknown} */ str, /** @type {() => void} */ callback) {
35
+ console.log(chalk.magenta.bold('[ FCA-WARNING ] > ') + chalk.yellow(str));
36
+ if (getType(callback) == 'Function' || getType(callback) == 'AsyncFunction') {
37
+ callback();
38
+ }
39
+ else return callback;
40
+ },
41
+ Error: function(/** @type {unknown} */ str, /** @type {() => void} */ callback) {
42
+ if (!str) {
43
+ console.log(chalk.magenta.bold('[ FCA-ERROR ] > ') + chalk.red("Already Faulty, Please Contact: Facebook.com/Candy.x.marvi.inside"));
44
+ }
45
+ console.log(chalk.magenta.bold('[ FCA-ERROR ] > ') + chalk.red(str));
46
+ if (getType(callback) == 'Function' || getType(callback) == 'AsyncFunction') {
47
+ callback();
48
+ }
49
+ else return callback;
50
+ },
51
+ Success: function(/** @type {unknown} */ str, /** @type {() => void} */ callback) {
52
+ console.log(chalk.hex('#9900FF').bold(`${globalThis.Fca.Require.FastConfig.MainName || '[ FCA-CANDY ]'} > `) + chalk.green(str));
53
+ if (getType(callback) == 'Function' || getType(callback) == 'AsyncFunction') {
54
+ callback();
55
+ }
56
+ else return callback;
57
+ },
58
+ Info: function(/** @type {unknown} */ str, /** @type {() => void} */ callback) {
59
+ console.log(chalk.hex('#9900FF').bold(`${globalThis.Fca.Require.FastConfig.MainName || '[ FCA-CANDY ]'} > `) + chalk.blue(str));
60
+ if (getType(callback) == 'Function' || getType(callback) == 'AsyncFunction') {
61
+ callback();
62
+ }
63
+ else return callback;
64
+ }
65
+ }
package/package.json CHANGED
@@ -1,6 +1,211 @@
1
1
  {
2
+ "_from": "fca-candy-darkster@latest",
3
+ "_id": "fca-candy-darkster@25.0.3",
4
+ "_inBundle": false,
5
+ "_integrity": "sha512-tuP6Vw7yM5rDtJujQIALfDrwWjhh3cXv154AQ6jV087sTW7HQ30B3cSzEvRlzlPzWo1vIoUYKr/09AtgeE9r0Q==",
6
+ "_location": "/fca-candy-darkster",
7
+ "_phantomChildren": {
8
+ "@pm2/agent": "2.0.3",
9
+ "@pm2/io": "5.0.0",
10
+ "@pm2/js-api": "0.6.7",
11
+ "@pm2/pm2-version-check": "1.0.4",
12
+ "accepts": "1.3.8",
13
+ "ansi-styles": "4.3.0",
14
+ "are-we-there-yet": "4.0.0",
15
+ "array-flatten": "1.1.1",
16
+ "async": "3.2.4",
17
+ "asynckit": "0.4.0",
18
+ "aws-sign2": "0.7.0",
19
+ "aws4": "1.11.0",
20
+ "blessed": "0.1.81",
21
+ "bytes": "3.1.2",
22
+ "caseless": "0.12.0",
23
+ "cheerio-select": "2.1.0",
24
+ "chokidar": "3.5.3",
25
+ "cli-tableau": "2.0.1",
26
+ "combined-stream": "1.0.8",
27
+ "commander": "2.15.1",
28
+ "console-control-strings": "1.1.0",
29
+ "content-disposition": "0.5.4",
30
+ "content-type": "1.0.4",
31
+ "cookie": "0.5.0",
32
+ "cookie-signature": "1.0.6",
33
+ "croner": "4.1.97",
34
+ "dayjs": "1.11.9",
35
+ "depd": "2.0.0",
36
+ "destroy": "1.2.0",
37
+ "encodeurl": "1.0.2",
38
+ "enquirer": "2.3.6",
39
+ "escape-html": "1.0.3",
40
+ "etag": "1.8.1",
41
+ "eventemitter2": "5.0.1",
42
+ "extend": "3.0.2",
43
+ "fclone": "1.0.11",
44
+ "finalhandler": "1.2.0",
45
+ "forever-agent": "0.6.1",
46
+ "fresh": "0.5.2",
47
+ "gauge": "5.0.0",
48
+ "har-validator": "5.1.5",
49
+ "http-errors": "2.0.0",
50
+ "http-signature": "1.2.0",
51
+ "iconv-lite": "0.4.24",
52
+ "is-typedarray": "1.0.0",
53
+ "isstream": "0.1.2",
54
+ "json-stringify-safe": "5.0.1",
55
+ "jssha": "3.2.0",
56
+ "merge-descriptors": "1.0.1",
57
+ "methods": "1.1.2",
58
+ "mime-types": "2.1.35",
59
+ "mkdirp": "1.0.4",
60
+ "needle": "2.4.0",
61
+ "oauth-sign": "0.9.0",
62
+ "on-finished": "2.4.1",
63
+ "parse5": "7.0.0",
64
+ "parse5-htmlparser2-tree-adapter": "7.0.0",
65
+ "parseurl": "1.3.3",
66
+ "path-to-regexp": "0.1.7",
67
+ "performance-now": "2.1.0",
68
+ "pidusage": "3.0.0",
69
+ "pm2-axon": "4.0.1",
70
+ "pm2-axon-rpc": "0.7.1",
71
+ "pm2-deploy": "1.0.2",
72
+ "pm2-multimeter": "0.1.2",
73
+ "pm2-sysmonit": "1.2.8",
74
+ "process": "0.11.10",
75
+ "promptly": "2.2.0",
76
+ "proxy-addr": "2.0.7",
77
+ "proxy-from-env": "1.1.0",
78
+ "range-parser": "1.2.1",
79
+ "raw-body": "2.5.1",
80
+ "safe-buffer": "5.2.1",
81
+ "semver": "7.3.7",
82
+ "send": "0.18.0",
83
+ "serve-static": "1.15.0",
84
+ "set-blocking": "2.0.0",
85
+ "setprototypeof": "1.2.0",
86
+ "side-channel": "1.0.4",
87
+ "source-map-support": "0.5.21",
88
+ "sprintf-js": "1.1.2",
89
+ "statuses": "2.0.1",
90
+ "supports-color": "7.2.0",
91
+ "tough-cookie": "2.5.0",
92
+ "tunnel-agent": "0.6.0",
93
+ "type-is": "1.6.18",
94
+ "unpipe": "1.0.0",
95
+ "utils-merge": "1.0.1",
96
+ "uuid": "3.4.0",
97
+ "vary": "1.1.2",
98
+ "vizion": "2.2.1",
99
+ "yamljs": "0.3.0"
100
+ },
101
+ "_requested": {
102
+ "type": "tag",
103
+ "registry": true,
104
+ "raw": "fca-candy-darkster@latest",
105
+ "name": "fca-candy-darkster",
106
+ "escapedName": "fca-candy-darkster",
107
+ "rawSpec": "latest",
108
+ "saveSpec": null,
109
+ "fetchSpec": "latest"
110
+ },
111
+ "_requiredBy": [
112
+ "#USER",
113
+ "/"
114
+ ],
115
+ "_resolved": "https://registry.npmjs.org/fca-candy-darkster/-/fca-candy-darkster-25.0.3.tgz",
116
+ "_shasum": "7f03b77f8c7da9f1765085089de42cf1f251d01c",
117
+ "_spec": "fca-candy-darkster@latest",
118
+ "_where": "/home/runner/Chantell",
119
+ "author": {
120
+ "name": "Candy Darkster"
121
+ },
122
+ "bugs": {
123
+ "url": "https://github.com/c9rl9/c9rla/issues"
124
+ },
125
+ "bundleDependencies": false,
126
+ "dependencies": {
127
+ "aes-js": "latest",
128
+ "aliya-anup-database": "latest",
129
+ "aliya-remake": "latest",
130
+ "assert": "latest",
131
+ "axios": "^1.1.3",
132
+ "bluebird": "latest",
133
+ "chalk": "4.1.2",
134
+ "cheerio": "latest",
135
+ "crypto": "latest",
136
+ "crypto-js": "latest",
137
+ "express": "latest",
138
+ "figlet": "^1.5.2",
139
+ "form-data": "^4.0.0",
140
+ "fs-extra": "^10.1.0",
141
+ "got": "^11.8.3",
142
+ "https-proxy-agent": "latest",
143
+ "is-hexcolor": "^1.0.0",
144
+ "lodash": "",
145
+ "mqtt": "latest",
146
+ "node-superfetch": "",
147
+ "npmlog": "latest",
148
+ "os": "latest",
149
+ "path": "latest",
150
+ "pm2": "latest",
151
+ "pretty-ms": "7.0.1",
152
+ "readline": "latest",
153
+ "request": "latest",
154
+ "totp-generator": "latest",
155
+ "uuid-apikey": "latest",
156
+ "websocket-stream": "latest"
157
+ },
158
+ "deprecated": false,
159
+ "description": "Facebook Chat Api For Messenger Bot",
160
+ "devDependencies": {
161
+ "eslint": "latest",
162
+ "mocha": "latest",
163
+ "prettier": "latest"
164
+ },
165
+ "engines": {
166
+ "node": ">=14.x <16.x"
167
+ },
168
+ "eslintConfig": {
169
+ "env": {
170
+ "es6": true,
171
+ "node": true
172
+ },
173
+ "extends": "eslint:recommended",
174
+ "parserOptions": {
175
+ "sourceType": "module"
176
+ },
177
+ "rules": {
178
+ "linebreak-style": [
179
+ "error",
180
+ "unix"
181
+ ],
182
+ "semi": [
183
+ "error",
184
+ "always"
185
+ ],
186
+ "no-unused-vars": [
187
+ 1,
188
+ {
189
+ "argsIgnorePattern": "^_"
190
+ }
191
+ ]
192
+ }
193
+ },
194
+ "homepage": "https://github.com/c4ndyd0n/JS0N#readme",
195
+ "keywords": [
196
+ "Neha"
197
+ ],
198
+ "license": "MIT",
199
+ "main": "index.js",
2
200
  "name": "fca-candy-darkster",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
201
+ "repository": {
202
+ "type": "git",
203
+ "url": "git://github.com/c4ndyd0n/JS0N.git"
204
+ },
205
+ "scripts": {
206
+ "lint": "eslint **.js",
207
+ "prettier": "prettier utils.js src/* --write",
208
+ "test": "mocha"
209
+ },
210
+ "version": "25.0.3"
6
211
  }
package/src/Premium.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ var { join } = require('path')
4
+ var fs = require('fs')
5
+
6
+
7
+ module.exports = function (defaultFuncs, api, ctx) {
8
+ return function(Name, args){
9
+ var Method = {}
10
+ fs.readdirSync(join(__dirname, "../Func")).filter((/** @type {string} */File) => File.endsWith(".js") && !File.includes('Dev_')).map((/** @type {string} */File) => Method[File.split('.').slice(0, -1).join('.')] = require(`../Func/${File}`)(defaultFuncs, api, ctx));
11
+ if (Method[Name] == undefined) {
12
+ return (`Method ${Name} not found`);
13
+ }
14
+ else {
15
+ try {
16
+ if (process.env.HalzionVersion == 1973 && global.Fca.Data.PremText.includes("Premium")) {
17
+ return Method[Name](args).then((/** @type {string} */Data) => {
18
+ return Data;
19
+ })
20
+ }
21
+ else {
22
+ return ("Buy Premium Go Go Grandpa and Grandpai !!");
23
+ }
24
+ }
25
+ catch (e) {
26
+ console.log(e);
27
+ }
28
+ }
29
+ }
30
+ };
@@ -0,0 +1,16 @@
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") 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])}!`);
11
+
12
+ }
13
+ }
14
+ else throw new Error(`moduleObj must be an object, not ${utils.getType(moduleObj)}!`);
15
+ };
16
+ };
@@ -0,0 +1,78 @@
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 addUserToGroup(userID, threadID, 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 && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
16
+
17
+ if (!callback) {
18
+ callback = function (err) {
19
+ if (err) return rejectFunc(err);
20
+ resolveFunc();
21
+ };
22
+ }
23
+
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) + "." };
25
+
26
+ if (utils.getType(userID) !== "Array") userID = [userID];
27
+
28
+ var messageAndOTID = utils.generateOfflineThreadingID();
29
+ var form = {
30
+ client: "mercury",
31
+ action_type: "ma-type:log-message",
32
+ author: "fbid:" + ctx.userID,
33
+ thread_id: "",
34
+ timestamp: Date.now(),
35
+ timestamp_absolute: "Today",
36
+ timestamp_relative: utils.generateTimestampRelative(),
37
+ timestamp_time_passed: "0",
38
+ is_unread: false,
39
+ is_cleared: false,
40
+ is_forward: false,
41
+ is_filtered_content: false,
42
+ is_filtered_content_bh: false,
43
+ is_filtered_content_account: false,
44
+ is_spoof_warning: false,
45
+ source: "source:chat:web",
46
+ "source_tags[0]": "source:chat",
47
+ log_message_type: "log:subscribe",
48
+ status: "0",
49
+ offline_threading_id: messageAndOTID,
50
+ message_id: messageAndOTID,
51
+ threading_id: utils.generateThreadingID(ctx.clientID),
52
+ manual_retry_cnt: "0",
53
+ thread_fbid: threadID
54
+ };
55
+
56
+ for (var i = 0; i < userID.length; 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];
59
+ }
60
+
61
+ defaultFuncs
62
+ .post("https://www.facebook.com/messaging/send/", ctx.jar, form)
63
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
64
+ .then(function (resData) {
65
+ if (!resData) throw { error: "Add to group failed." };
66
+ if (resData.error) throw resData;
67
+
68
+
69
+ return callback();
70
+ })
71
+ .catch(function (err) {
72
+ log.error("addUserToGroup", err);
73
+ return callback(err);
74
+ });
75
+
76
+ return returnPromise;
77
+ };
78
+ };
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ const log = require("npmlog");
5
+
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"};
10
+ }
11
+
12
+ if (utils.getType(adminIDs) === "String") {
13
+ adminIDs = [adminIDs];
14
+ }
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 (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
41
+ throw {error: "changeAdminStatus: callback is not a function"};
42
+ }
43
+
44
+ let form = {
45
+ "thread_fbid": threadID,
46
+ };
47
+
48
+ let i = 0;
49
+ for (let u of adminIDs) {
50
+ form[`admin_ids[${i++}]`] = u;
51
+ }
52
+ form["add"] = adminStatus;
53
+
54
+ defaultFuncs
55
+ .post("https://www.facebook.com/messaging/save_admins/?dpr=1", ctx.jar, form)
56
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
57
+ .then(function(resData) {
58
+ if (resData.error) {
59
+ switch (resData.error) {
60
+ case 1976004:
61
+ throw { error: "Cannot alter admin status: you are not an admin.", rawResponse: resData };
62
+ case 1357031:
63
+ throw { error: "Cannot alter admin status: this thread is not a group chat.", rawResponse: resData };
64
+ default:
65
+ throw { error: "Cannot alter admin status: unknown error.", rawResponse: resData };
66
+ }
67
+ }
68
+
69
+ callback();
70
+ })
71
+ .catch(function(err) {
72
+ log.error("changeAdminStatus", err);
73
+ return callback(err);
74
+ });
75
+
76
+ return returnPromise;
77
+ };
78
+ };
79
+
@@ -0,0 +1,41 @@
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 changeArchivedStatus(threadOrThreads, archive, 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) {
17
+ if (err) return rejectFunc(err);
18
+ resolveFunc();
19
+ };
20
+ }
21
+
22
+ var form = {};
23
+
24
+ if (utils.getType(threadOrThreads) === "Array") for (var i = 0; i < threadOrThreads.length; i++) form["ids[" + threadOrThreads[i] + "]"] = archive;
25
+ else form["ids[" + threadOrThreads + "]"] = archive;
26
+
27
+ defaultFuncs
28
+ .post("https://www.facebook.com/ajax/mercury/change_archived_status.php", ctx.jar, form)
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("changeArchivedStatus", err);
36
+ return callback(err);
37
+ });
38
+
39
+ return returnPromise;
40
+ };
41
+ };
@@ -0,0 +1,85 @@
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(`https://www.facebook.com/profile/picture/upload/?profile_id=${BotID}&photo_source=57&av=${BotID}`, form);
15
+ return JSON.parse(Data.split("for (;;);")[1]);
16
+ }
17
+
18
+ module.exports = function(defaultFuncs, api, ctx) {
19
+ /* Changing the profile picture of the bot. */
20
+ return function changeAvt(link, caption, callback) {
21
+ var resolveFunc = function() {};
22
+ var rejectFunc = function() {};
23
+ var returnPromise = new Promise(function(resolve, reject) {
24
+ resolveFunc = resolve;
25
+ rejectFunc = reject;
26
+ });
27
+
28
+ if (!callback) {
29
+ callback = function(err, data) {
30
+ if (err) return rejectFunc(err);
31
+ resolveFunc(data);
32
+ };
33
+ }
34
+ try {
35
+ var Fetch = require('axios')
36
+ Fetch.get(link, { responseType: "stream" }).then(data => {
37
+ postImage(api, ctx.userID, { file: data.data }).then(data => {
38
+ if (data.error) throw new Error({ error: data.error, des: data.error.errorDescription });
39
+ var form = {
40
+ av: ctx.userID,
41
+ fb_api_req_friendly_name: "ProfileCometProfilePictureSetMutation",
42
+ fb_api_caller_class: "RelayModern",
43
+ doc_id: "5066134240065849",
44
+ variables: JSON.stringify({
45
+ input: {
46
+ caption: (caption || ""),
47
+ existing_photo_id: data.payload.fbid,
48
+ expiration_time: null,
49
+ profile_id: ctx.userID,
50
+ profile_pic_method: "EXISTING",
51
+ profile_pic_source: "TIMELINE",
52
+ scaled_crop_rect: {
53
+ height: 1,
54
+ width: 1,
55
+ x: 0,
56
+ y: 0
57
+ },
58
+ skip_cropping: true,
59
+ actor_id: ctx.userID,
60
+ client_mutation_id: Math.round(Math.random() * 19).toString()
61
+ },
62
+ isPage: false,
63
+ isProfile: true,
64
+ scale: 3,
65
+ })
66
+ };
67
+ defaultFuncs
68
+ .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
69
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
70
+ .then(function(resData) {
71
+ if (resData.error) throw resData;
72
+ else return callback(null,true)
73
+ })
74
+ .catch(function(err) {
75
+ return callback(err);
76
+ });
77
+ })
78
+ })
79
+ }
80
+ catch (e) {
81
+ throw e;
82
+ }
83
+ return returnPromise;
84
+ };
85
+ };
@@ -0,0 +1,65 @@
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 changeBio(bio, publish, 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
+ if (utils.getType(publish) == "Function" || utils.getType(publish) == "AsyncFunction") callback = publish;
17
+ else {
18
+ callback = function (err) {
19
+ if (err) return rejectFunc(err);
20
+ resolveFunc();
21
+ };
22
+ }
23
+ }
24
+
25
+ if (utils.getType(publish) != "Boolean") publish = false;
26
+ if (utils.getType(bio) != "String") {
27
+ bio = "";
28
+ publish = false;
29
+ }
30
+
31
+ var form = {
32
+ fb_api_caller_class: "RelayModern",
33
+ fb_api_req_friendly_name: "ProfileCometSetBioMutation",
34
+ // This doc_is is valid as of May 23, 2020
35
+ doc_id: "2725043627607610",
36
+ variables: JSON.stringify({
37
+ input: {
38
+ bio: bio,
39
+ publish_bio_feed_story: publish,
40
+ actor_id: ctx.userID,
41
+ client_mutation_id: Math.round(Math.random() * 1024).toString()
42
+ },
43
+ hasProfileTileViewID: false,
44
+ profileTileViewID: null,
45
+ scale: 1
46
+ }),
47
+ av: ctx.userID
48
+ };
49
+
50
+ defaultFuncs
51
+ .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
52
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
53
+ .then(function (resData) {
54
+ if (resData.errors) throw resData;
55
+
56
+ return callback();
57
+ })
58
+ .catch(function (err) {
59
+ log.error("changeBio", err);
60
+ return callback(err);
61
+ });
62
+
63
+ return returnPromise;
64
+ };
65
+ };