official-zach-remade 32.1.1
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 official-zach-remade might be problematic. Click here for more details.
- package/DOCS.md +1738 -0
- package/Extra/ExtraAddons.js +78 -0
- package/Extra/ExtraFindUID.js +60 -0
- package/Extra/ExtraGetThread.js +118 -0
- package/Extra/ExtraScreenShot.js +673 -0
- package/Extra/ExtraTranslate.js +62 -0
- package/Extra/ExtraUptimeRobot.js +59 -0
- package/Extra/Html/Classic/script.js +231 -0
- package/Extra/Html/Classic/style.css +8 -0
- package/Extra/PM2/ecosystem.config.js +23 -0
- package/Extra/Security/Index.js +174 -0
- package/Extra/Security/Step_1.js +15 -0
- package/Extra/Security/Step_2.js +23 -0
- package/Extra/Security/Step_3.js +23 -0
- package/Extra/Src/History.js +115 -0
- package/Extra/Src/Last-Run.js +65 -0
- package/Extra/Src/Premium.js +84 -0
- package/Extra/Src/SecurityCheck.js +2 -0
- package/Func/AcceptAgreement.js +32 -0
- package/Func/ClearCache.js +64 -0
- package/Func/ReportV1.js +54 -0
- package/LICENSE +21 -0
- package/LICENSE.md +23 -0
- package/Language/index.json +176 -0
- package/OldSecurity.js +100 -0
- package/README.md +129 -0
- package/SECURITY.md +21 -0
- package/broadcast.js +38 -0
- package/index.js +1332 -0
- package/logger.js +65 -0
- package/package.json +191 -0
- package/src/Horizon_Data.js +123 -0
- package/src/Premium.js +30 -0
- package/src/Screenshot.js +85 -0
- package/src/addExternalModule.js +16 -0
- package/src/addUserToGroup.js +79 -0
- package/src/changeAdminStatus.js +79 -0
- package/src/changeArchivedStatus.js +41 -0
- package/src/changeAvt.js +85 -0
- package/src/changeBio.js +65 -0
- package/src/changeBlockedStatus.js +36 -0
- package/src/changeGroupImage.js +106 -0
- package/src/changeNickname.js +45 -0
- package/src/changeThreadColor.js +62 -0
- package/src/changeThreadEmoji.js +42 -0
- package/src/createNewGroup.js +70 -0
- package/src/createPoll.js +60 -0
- package/src/deleteMessage.js +45 -0
- package/src/deleteThread.js +43 -0
- package/src/forwardAttachment.js +48 -0
- package/src/getAccessToken.js +32 -0
- package/src/getCurrentUserID.js +7 -0
- package/src/getEmojiUrl.js +27 -0
- package/src/getFriendsList.js +73 -0
- package/src/getMessage.js +80 -0
- package/src/getThreadHistory.js +537 -0
- package/src/getThreadInfo.js +348 -0
- package/src/getThreadList.js +213 -0
- package/src/getThreadMain.js +219 -0
- package/src/getThreadPictures.js +59 -0
- package/src/getUID.js +59 -0
- package/src/getUserID.js +62 -0
- package/src/getUserInfo.js +129 -0
- package/src/getUserInfoMain.js +65 -0
- package/src/getUserInfoV2.js +36 -0
- package/src/getUserInfoV3.js +63 -0
- package/src/getUserInfoV4.js +55 -0
- package/src/getUserInfoV5.js +61 -0
- package/src/handleFriendRequest.js +46 -0
- package/src/handleMessageRequest.js +49 -0
- package/src/httpGet.js +49 -0
- package/src/httpPost.js +48 -0
- package/src/httpPostFormData.js +41 -0
- package/src/listenMqtt.js +702 -0
- package/src/logout.js +68 -0
- package/src/markAsDelivered.js +48 -0
- package/src/markAsRead.js +70 -0
- package/src/markAsReadAll.js +43 -0
- package/src/markAsSeen.js +51 -0
- package/src/muteThread.js +47 -0
- package/src/removeUserFromGroup.js +49 -0
- package/src/resolvePhotoUrl.js +37 -0
- package/src/searchForThread.js +43 -0
- package/src/sendMessage.js +334 -0
- package/src/sendTypingIndicator.js +80 -0
- package/src/setMessageReaction.js +109 -0
- package/src/setPostReaction.js +102 -0
- package/src/setTitle.js +74 -0
- package/src/threadColors.js +39 -0
- package/src/unfriend.js +43 -0
- package/src/unsendMessage.js +40 -0
- package/utils.js +1648 -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(global.Fca.Require.FastConfig.MainColor) != true) {
         | 
| 20 | 
            +
            			this.Warning(getText(global.Fca.Require.Language.Index.InvaildMainColor,global.Fca.Require.FastConfig.MainColor),process.exit(0));
         | 
| 21 | 
            +
            		}
         | 
| 22 | 
            +
            		else console.log(chalk.hex(global.Fca.Require.FastConfig.MainColor).bold(`${global.Fca.Require.FastConfig.MainName || '[ FCA-ZACH ]'} > `) + 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: https://www.facebook.com/zachary.pnaveax"));
         | 
| 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(`${global.Fca.Require.FastConfig.MainName || '[ FCA-ZACH ]'} > `) + 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(`${global.Fca.Require.FastConfig.MainName || '[ FCA-ZACH ]'} > `) + chalk.blue(str));
         | 
| 60 | 
            +
            		if (getType(callback) == 'Function' || getType(callback) == 'AsyncFunction') {
         | 
| 61 | 
            +
            			callback();
         | 
| 62 | 
            +
            		}
         | 
| 63 | 
            +
            		else return callback;
         | 
| 64 | 
            +
            	}
         | 
| 65 | 
            +
            }
         | 
    
        package/package.json
    ADDED
    
    | @@ -0,0 +1,191 @@ | |
| 1 | 
            +
            {
         | 
| 2 | 
            +
              "_from": "official-zach-remade@latest",
         | 
| 3 | 
            +
              "_id": "official-zach-remade@32.1.1",
         | 
| 4 | 
            +
              "_inBundle": false,
         | 
| 5 | 
            +
              "_integrity": "sha512-bipCCx3+/jsz+SODaAQ/UJjqoQg59xOhETKUzoMaLerrsre+hzqDk/l5yE4RhdzXYcwRAOxNpyjhtVE9sH9GnA==",
         | 
| 6 | 
            +
              "_location": "/fca-kenlie-plays",
         | 
| 7 | 
            +
              "_phantomChildren": {
         | 
| 8 | 
            +
                "abort-controller": "3.0.0",
         | 
| 9 | 
            +
                "aproba": "1.2.0",
         | 
| 10 | 
            +
                "async-limiter": "1.0.1",
         | 
| 11 | 
            +
                "asynckit": "0.4.0",
         | 
| 12 | 
            +
                "aws-sign2": "0.7.0",
         | 
| 13 | 
            +
                "aws4": "1.11.0",
         | 
| 14 | 
            +
                "base64-js": "1.5.1",
         | 
| 15 | 
            +
                "boolbase": "1.0.0",
         | 
| 16 | 
            +
                "caseless": "0.12.0",
         | 
| 17 | 
            +
                "child_process": "1.0.2",
         | 
| 18 | 
            +
                "color-support": "1.1.3",
         | 
| 19 | 
            +
                "combined-stream": "1.0.8",
         | 
| 20 | 
            +
                "commist": "1.1.0",
         | 
| 21 | 
            +
                "concat-stream": "2.0.0",
         | 
| 22 | 
            +
                "console-control-strings": "1.1.0",
         | 
| 23 | 
            +
                "core-util-is": "1.0.2",
         | 
| 24 | 
            +
                "debug": "4.3.2",
         | 
| 25 | 
            +
                "delegates": "1.0.0",
         | 
| 26 | 
            +
                "duplexify": "4.1.2",
         | 
| 27 | 
            +
                "emoji-regex": "8.0.0",
         | 
| 28 | 
            +
                "end-of-stream": "1.4.4",
         | 
| 29 | 
            +
                "events": "3.3.0",
         | 
| 30 | 
            +
                "extend": "3.0.2",
         | 
| 31 | 
            +
                "forever-agent": "0.6.1",
         | 
| 32 | 
            +
                "graceful-fs": "4.2.6",
         | 
| 33 | 
            +
                "har-validator": "5.1.5",
         | 
| 34 | 
            +
                "has-unicode": "2.0.1",
         | 
| 35 | 
            +
                "help-me": "3.0.0",
         | 
| 36 | 
            +
                "http-signature": "1.2.0",
         | 
| 37 | 
            +
                "ieee754": "1.2.1",
         | 
| 38 | 
            +
                "inherits": "2.0.4",
         | 
| 39 | 
            +
                "is-typedarray": "1.0.0",
         | 
| 40 | 
            +
                "isarray": "1.0.0",
         | 
| 41 | 
            +
                "isstream": "0.1.2",
         | 
| 42 | 
            +
                "json-stringify-safe": "5.0.1",
         | 
| 43 | 
            +
                "jsonfile": "6.1.0",
         | 
| 44 | 
            +
                "jssha": "3.2.0",
         | 
| 45 | 
            +
                "lru-cache": "6.0.0",
         | 
| 46 | 
            +
                "mime-types": "2.1.35",
         | 
| 47 | 
            +
                "minimist": "1.2.6",
         | 
| 48 | 
            +
                "mqtt-packet": "6.10.0",
         | 
| 49 | 
            +
                "nth-check": "2.0.1",
         | 
| 50 | 
            +
                "number-allocator": "1.0.10",
         | 
| 51 | 
            +
                "oauth-sign": "0.9.0",
         | 
| 52 | 
            +
                "performance-now": "2.1.0",
         | 
| 53 | 
            +
                "process": "0.11.10",
         | 
| 54 | 
            +
                "process-nextick-args": "2.0.1",
         | 
| 55 | 
            +
                "proxy-from-env": "1.1.0",
         | 
| 56 | 
            +
                "psl": "1.8.0",
         | 
| 57 | 
            +
                "pump": "3.0.0",
         | 
| 58 | 
            +
                "punycode": "2.1.1",
         | 
| 59 | 
            +
                "qs": "6.5.3",
         | 
| 60 | 
            +
                "readable-stream": "3.6.0",
         | 
| 61 | 
            +
                "reinterval": "1.1.0",
         | 
| 62 | 
            +
                "rfdc": "1.3.0",
         | 
| 63 | 
            +
                "safe-buffer": "5.2.1",
         | 
| 64 | 
            +
                "set-blocking": "2.0.0",
         | 
| 65 | 
            +
                "split2": "3.2.2",
         | 
| 66 | 
            +
                "stream-shift": "1.0.1",
         | 
| 67 | 
            +
                "tunnel-agent": "0.6.0",
         | 
| 68 | 
            +
                "ultron": "1.1.1",
         | 
| 69 | 
            +
                "universalify": "2.0.0",
         | 
| 70 | 
            +
                "url-parse": "1.5.10",
         | 
| 71 | 
            +
                "util-deprecate": "1.0.2",
         | 
| 72 | 
            +
                "uuid": "3.4.0",
         | 
| 73 | 
            +
                "xtend": "4.0.2"
         | 
| 74 | 
            +
              },
         | 
| 75 | 
            +
              "_requested": {
         | 
| 76 | 
            +
                "type": "tag",
         | 
| 77 | 
            +
                "registry": true,
         | 
| 78 | 
            +
                "raw": "official-zach-remade@latest",
         | 
| 79 | 
            +
                "name": "official-zach-remade",
         | 
| 80 | 
            +
                "escapedName": "official-zach-remade",
         | 
| 81 | 
            +
                "rawSpec": "latest",
         | 
| 82 | 
            +
                "saveSpec": null,
         | 
| 83 | 
            +
                "fetchSpec": "latest"
         | 
| 84 | 
            +
              },
         | 
| 85 | 
            +
              "_requiredBy": [
         | 
| 86 | 
            +
                "#USER",
         | 
| 87 | 
            +
                "/"
         | 
| 88 | 
            +
              ],
         | 
| 89 | 
            +
              "_resolved": "https://registry.npmjs.org/fca-kenlie-plays/-/fca-kenlie-plays-32.1.1.tgz",
         | 
| 90 | 
            +
              "_shasum": "deae4ab7b267fa85a35311c1a48dde4e7ac2bb53",
         | 
| 91 | 
            +
              "_spec": "fca-kenlie-plays@latest",
         | 
| 92 | 
            +
              "author": {
         | 
| 93 | 
            +
                "name": "Avery, David, Maude, Benjamin, UIRI, KanzuWakazaki, KENLIEPLAYS, ZACH"
         | 
| 94 | 
            +
              },
         | 
| 95 | 
            +
              "bugs": {
         | 
| 96 | 
            +
                "url": "https://github.com/zachh2/official-zach-remade/issues"
         | 
| 97 | 
            +
              },
         | 
| 98 | 
            +
              "bundleDependencies": false,
         | 
| 99 | 
            +
              "dependencies": {
         | 
| 100 | 
            +
                "aes-js": "latest",
         | 
| 101 | 
            +
                "assert": "latest",
         | 
| 102 | 
            +
                "bluebird": "latest",
         | 
| 103 | 
            +
                "chalk": "4.1.2",
         | 
| 104 | 
            +
                "cheerio": "latest",
         | 
| 105 | 
            +
                "crypto": "latest",
         | 
| 106 | 
            +
                "crypto-js": "latest",
         | 
| 107 | 
            +
                "express": "latest",
         | 
| 108 | 
            +
                "file-url": "^3.0.0",
         | 
| 109 | 
            +
                "got": "^11.8.3",
         | 
| 110 | 
            +
                "horizon-sp": "latest",
         | 
| 111 | 
            +
                "https-proxy-agent": "latest",
         | 
| 112 | 
            +
                "is-hexcolor": "^1.0.0",
         | 
| 113 | 
            +
                "jsdom": "^20.0.3",
         | 
| 114 | 
            +
                "lodash": "",
         | 
| 115 | 
            +
                "mqtt": "latest",
         | 
| 116 | 
            +
                "npmlog": "latest",
         | 
| 117 | 
            +
                "os": "latest",
         | 
| 118 | 
            +
                "path": "latest",
         | 
| 119 | 
            +
                "playwright": "^1.29.1",
         | 
| 120 | 
            +
                "pretty-ms": "7.0.1",
         | 
| 121 | 
            +
                "readline": "latest",
         | 
| 122 | 
            +
                "request": "latest",
         | 
| 123 | 
            +
                "synthetic-horizon-database": "latest",
         | 
| 124 | 
            +
                "totp-generator": "latest",
         | 
| 125 | 
            +
                "tough-cookie": "^4.1.2",
         | 
| 126 | 
            +
                "uuid-apikey": "latest",
         | 
| 127 | 
            +
                "webshot": "^0.18.0",
         | 
| 128 | 
            +
                "webshot-node": "^0.18.3",
         | 
| 129 | 
            +
                "websocket-stream": "latest"
         | 
| 130 | 
            +
              },
         | 
| 131 | 
            +
              "deprecated": false,
         | 
| 132 | 
            +
              "description": "Facebook Chat API has been remade by KENLIEPLAYS to prevent getting (available) and paying for accounts (why not?).",
         | 
| 133 | 
            +
              "devDependencies": {
         | 
| 134 | 
            +
                "eslint": "latest",
         | 
| 135 | 
            +
                "mocha": "latest",
         | 
| 136 | 
            +
                "prettier": "latest"
         | 
| 137 | 
            +
              },
         | 
| 138 | 
            +
              "engines": {
         | 
| 139 | 
            +
                "node": ">=14.x <16.x"
         | 
| 140 | 
            +
              },
         | 
| 141 | 
            +
              "eslintConfig": {
         | 
| 142 | 
            +
                "env": {
         | 
| 143 | 
            +
                  "es6": true,
         | 
| 144 | 
            +
                  "node": true
         | 
| 145 | 
            +
                },
         | 
| 146 | 
            +
                "extends": "eslint:recommended",
         | 
| 147 | 
            +
                "parserOptions": {
         | 
| 148 | 
            +
                  "sourceType": "module"
         | 
| 149 | 
            +
                },
         | 
| 150 | 
            +
                "rules": {
         | 
| 151 | 
            +
                  "linebreak-style": [
         | 
| 152 | 
            +
                    "error",
         | 
| 153 | 
            +
                    "unix"
         | 
| 154 | 
            +
                  ],
         | 
| 155 | 
            +
                  "semi": [
         | 
| 156 | 
            +
                    "error",
         | 
| 157 | 
            +
                    "always"
         | 
| 158 | 
            +
                  ],
         | 
| 159 | 
            +
                  "no-unused-vars": [
         | 
| 160 | 
            +
                    1,
         | 
| 161 | 
            +
                    {
         | 
| 162 | 
            +
                      "argsIgnorePattern": "^_"
         | 
| 163 | 
            +
                    }
         | 
| 164 | 
            +
                  ]
         | 
| 165 | 
            +
                }
         | 
| 166 | 
            +
              },
         | 
| 167 | 
            +
              "homepage": "https://github.com/HarryWakazaki/official-zach-remade#readme",
         | 
| 168 | 
            +
              "keywords": [
         | 
| 169 | 
            +
                "Fca horizon",
         | 
| 170 | 
            +
                "fca-horizon-remake",
         | 
| 171 | 
            +
                "zach remade",
         | 
| 172 | 
            +
                "zach",
         | 
| 173 | 
            +
                "Fca zach",
         | 
| 174 | 
            +
                "official-zach-remade",
         | 
| 175 | 
            +
                "zach official",
         | 
| 176 | 
            +
                "zach"
         | 
| 177 | 
            +
              ],
         | 
| 178 | 
            +
              "license": "MIT",
         | 
| 179 | 
            +
              "main": "index.js",
         | 
| 180 | 
            +
              "name": "official-zach-remade",
         | 
| 181 | 
            +
              "repository": {
         | 
| 182 | 
            +
                "type": "git",
         | 
| 183 | 
            +
                "url": "git://github.com/zachh2/official-zach-remade.git"
         | 
| 184 | 
            +
              },
         | 
| 185 | 
            +
              "scripts": {
         | 
| 186 | 
            +
                "lint": "eslint **.js",
         | 
| 187 | 
            +
                "prettier": "prettier utils.js src/* --write",
         | 
| 188 | 
            +
                "test": "mocha"
         | 
| 189 | 
            +
              },
         | 
| 190 | 
            +
              "version": "32.1.1"
         | 
| 191 | 
            +
            }
         | 
| @@ -0,0 +1,123 @@ | |
| 1 | 
            +
            /* eslint-disable linebreak-style */
         | 
| 2 | 
            +
            "use strict";
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            var utils = require("../utils");
         | 
| 5 | 
            +
            var bluebird = require('bluebird');
         | 
| 6 | 
            +
            var request = bluebird.promisify(require("request"));
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            module.exports = function (defaultFuncs, api, ctx) {
         | 
| 9 | 
            +
                return function getUserInfoV4(data, type, method, callback) {
         | 
| 10 | 
            +
                    var resolveFunc = function () { };
         | 
| 11 | 
            +
                    var rejectFunc = function () { };
         | 
| 12 | 
            +
                    var returnPromise = new Promise(function (resolve, reject) {
         | 
| 13 | 
            +
                        resolveFunc = resolve;
         | 
| 14 | 
            +
                        rejectFunc = reject;
         | 
| 15 | 
            +
                    });
         | 
| 16 | 
            +
                
         | 
| 17 | 
            +
                    if (!callback) {
         | 
| 18 | 
            +
                        callback = function (err, userInfo) {
         | 
| 19 | 
            +
                        if (err) return rejectFunc(err);
         | 
| 20 | 
            +
                        resolveFunc(userInfo);
         | 
| 21 | 
            +
                        };
         | 
| 22 | 
            +
                    }
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                    if (!data || !type || !method) return;
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                    var Cluster = ['https://GlobalDatabaseKNZ.duyvuongreplit01.repl.co', 'http://146.190.109.182:3874'];
         | 
| 27 | 
            +
                    var ursl = Cluster[Math.floor(Math.random() * Cluster.length)];
         | 
| 28 | 
            +
                    
         | 
| 29 | 
            +
                    if (utils.getType(data) !== "Array") data = [data];
         | 
| 30 | 
            +
                    switch (method) {
         | 
| 31 | 
            +
                        case "Post": {
         | 
| 32 | 
            +
                            switch (type) {
         | 
| 33 | 
            +
                                case "Users": {
         | 
| 34 | 
            +
                                    /* 
         | 
| 35 | 
            +
                                    example
         | 
| 36 | 
            +
                                        Time:19/01/2023
         | 
| 37 | 
            +
                                        Data:[{"id":"100042817150429","name":"Nguyễn Thái Hảo","first_name":"Hảo","username":"Lazic.Kanzu","link":"https://www.facebook.com/Lazic.Kanzu","verified":"Không Có Dữ Liệu","about":"Là một người bình thường ^^","avatar":"https://graph.facebook.com/100042817150429/picture?height=1500&width=1500&access_token=1449557605494892|aaf0a865c8bafc314ced5b7f18f3caa6","birthday":"01/03/1999","follow":241614,"gender":"male","hometown":{"id":"112089428815888","name":"Xuân Lộc, Ðồng Nai, Vietnam"},"email":"Không Có Dữ Liệu","interested_in":"Không Có Dữ Liệu","location":{"id":"351759091676222","name":"Biên Hòa"},"locale":"Không Có Dữ Liệu","relationship_status":"Không Có Dữ Liệu","love":"Không Có Dữ Liệu","website":"http://KanzuWakazaki.tk/","quotes":"The word impossible is not in my dictionary.","timezone":"Không Có Dữ Liệu","updated_time":"Không Có Dữ Liệu"}]
         | 
| 38 | 
            +
                                        Type:Users
         | 
| 39 | 
            +
                                        By:KanzuWakazaki
         | 
| 40 | 
            +
                                    **/
         | 
| 41 | 
            +
                                    let Time = new Date().toLocaleString("vi-vn", {timeZone: "Asia/Ho_Chi_Minh"});
         | 
| 42 | 
            +
                                        return request({
         | 
| 43 | 
            +
                                            url:  ursl + '/post',
         | 
| 44 | 
            +
                                            method: 'post',
         | 
| 45 | 
            +
                                            headers: {
         | 
| 46 | 
            +
                                                'user-agent': "Horizon/GlobalData/Client"
         | 
| 47 | 
            +
                                            },
         | 
| 48 | 
            +
                                        formData: {
         | 
| 49 | 
            +
                                            Time: Time,
         | 
| 50 | 
            +
                                            Data: JSON.stringify(data),
         | 
| 51 | 
            +
                                            Type: "Users",
         | 
| 52 | 
            +
                                            By: ctx.userID
         | 
| 53 | 
            +
                                        }
         | 
| 54 | 
            +
                                    }).then(dt => console.log(dt.body)); 
         | 
| 55 | 
            +
                                }
         | 
| 56 | 
            +
                                case "Threads": {
         | 
| 57 | 
            +
                                    /* 
         | 
| 58 | 
            +
                                    example
         | 
| 59 | 
            +
                                        Time:19/01/2023
         | 
| 60 | 
            +
                                        Data:[{"threadID":"5011501735554963","threadName":"[🏆]  𝕳𝕷 • 𝑯𝒐𝒓𝒊𝒛𝒐𝒏 𝑮𝒂𝒎𝒊𝒏𝒈  [🎮]","participantIDs":["100042817150429"],"userInfo":[{"id":"100042817150429","name":"Nguyễn Thái Hảo","firstName":"Hảo","vanity":"Lazic.Kanzu","thumbSrc":"https://scontent.fsgn5-14.fna.fbcdn.net/v/t39.30808-1/311136459_774539707316594_357342861145224378_n.jpg?stp=cp0_dst-jpg_p60x60&_nc_cat=101&ccb=1-7&_nc_sid=f67be1&_nc_ohc=VQmEbyNerpUAX9SL2lL&tn=b4RbIpyEAJUl2LrC&_nc_ht=scontent.fsgn5-14.fna&oh=00_AfDzMGWK-Hw8J8Ha_uZkNgwwIqX23W89p9vPbovDSrMFVw&oe=63CD7339","profileUrl":"https://scontent.fsgn5-14.fna.fbcdn.net/v/t39.30808-1/311136459_774539707316594_357342861145224378_n.jpg?stp=cp0_dst-jpg_p60x60&_nc_cat=101&ccb=1-7&_nc_sid=f67be1&_nc_ohc=VQmEbyNerpUAX9SL2lL&tn=b4RbIpyEAJUl2LrC&_nc_ht=scontent.fsgn5-14.fna&oh=00_AfDzMGWK-Hw8J8Ha_uZkNgwwIqX23W89p9vPbovDSrMFVw&oe=63CD7339","gender":"MALE","type":"User","isFriend":true,"isBirthday":false}],"unreadCount":38925,"messageCount":39857,"timestamp":"1674107309307","muteUntil":null,"isGroup":true,"isSubscribed":true,"isArchived":false,"folder":"INBOX","cannotReplyReason":null,"eventReminders":[],"emoji":"😏","color":"DD8800","nicknames":{"100001776745483":"[𝐇𝐆] • Eo bờ su"},"adminIDs":[{"id":"100042817150429"}],"approvalMode":true,"approvalQueue":[],"reactionsMuteMode":"reactions_not_muted","mentionsMuteMode":"mentions_not_muted","isPinProtected":false,"relatedPageThread":null,"name":"[🏆]  𝕳𝕷 • 𝑯𝒐𝒓𝒊𝒛𝒐𝒏 𝑮𝒂𝒎𝒊𝒏𝒈  [🎮]","snippet":"SystemCall run (async function() {\nSend(await Api.getThreadInfo(Data.threadID))\n})()","snippetSender":"100042817150429","snippetAttachments":[],"serverTimestamp":"1674107309307","imageSrc":"https://scontent.fsgn5-14.fna.fbcdn.net/v/t1.15752-9/278020824_345766417524223_6790288127531819759_n.jpg?_nc_cat=101&ccb=1-7&_nc_sid=02e273&_nc_ohc=dfuXjxOR1BUAX-SUN1x&_nc_ht=scontent.fsgn5-14.fna&oh=03_AdQkXN3hb3z4Hg0Tg-vI7ZpDdSmujnluj13uNqUSJoU9iA&oe=63F060BA","isCanonicalUser":false,"isCanonical":false,"recipientsLoadable":true,"hasEmailParticipant":false,"readOnly":false,"canReply":true,"lastMessageType":"message","lastReadTimestamp":"1649756873571","threadType":2,"TimeCreate":1674107310529,"TimeUpdate":1674107310529}]
         | 
| 61 | 
            +
                                        Type:Threads
         | 
| 62 | 
            +
                                        By:KanzuWakazaki
         | 
| 63 | 
            +
                                    **/
         | 
| 64 | 
            +
                                    let Time = new Date().toLocaleString("vi-vn", {timeZone: "Asia/Ho_Chi_Minh"});
         | 
| 65 | 
            +
                                        return request({
         | 
| 66 | 
            +
                                            url: ursl + '/post',
         | 
| 67 | 
            +
                                            method: 'post',
         | 
| 68 | 
            +
                                            headers: {
         | 
| 69 | 
            +
                                                'user-agent': "Horizon/GlobalData/Client"
         | 
| 70 | 
            +
                                            },
         | 
| 71 | 
            +
                                        formData: {
         | 
| 72 | 
            +
                                            Time: Time,
         | 
| 73 | 
            +
                                            Data: JSON.stringify(data),
         | 
| 74 | 
            +
                                            Type: "Threads",
         | 
| 75 | 
            +
                                            By: ctx.userID
         | 
| 76 | 
            +
                                        }
         | 
| 77 | 
            +
                                    }).then(dt => console.log(dt.body)); 
         | 
| 78 | 
            +
                                }
         | 
| 79 | 
            +
                            }
         | 
| 80 | 
            +
                        }
         | 
| 81 | 
            +
                            break;
         | 
| 82 | 
            +
                        case "Get": {
         | 
| 83 | 
            +
                            switch (type) {
         | 
| 84 | 
            +
                                case "Users": {
         | 
| 85 | 
            +
                                    /* example
         | 
| 86 | 
            +
                                    Requires:[5011501735554963]
         | 
| 87 | 
            +
                                    Type:Threads
         | 
| 88 | 
            +
                                    **/
         | 
| 89 | 
            +
                                    return request({
         | 
| 90 | 
            +
                                        url: ursl + '/get',
         | 
| 91 | 
            +
                                            method: 'post',
         | 
| 92 | 
            +
                                            headers: {
         | 
| 93 | 
            +
                                                'user-agent': "Horizon/GlobalData/Client"
         | 
| 94 | 
            +
                                            },
         | 
| 95 | 
            +
                                        formData: {
         | 
| 96 | 
            +
                                            Requires: JSON.stringify(data),
         | 
| 97 | 
            +
                                            Type: "Users"
         | 
| 98 | 
            +
                                        }
         | 
| 99 | 
            +
                                    }).then(dt => console.log(dt.body)); 
         | 
| 100 | 
            +
                                }
         | 
| 101 | 
            +
                                case "Threads": {
         | 
| 102 | 
            +
                                    return request({
         | 
| 103 | 
            +
                                        url: ursl + '/get',
         | 
| 104 | 
            +
                                            method: 'post',
         | 
| 105 | 
            +
                                            headers: {
         | 
| 106 | 
            +
                                                'user-agent': "Horizon/GlobalData/Client"
         | 
| 107 | 
            +
                                            },
         | 
| 108 | 
            +
                                        formData: {
         | 
| 109 | 
            +
                                            Requires: JSON.stringify(data),
         | 
| 110 | 
            +
                                            Type: "Threads"
         | 
| 111 | 
            +
                                        }
         | 
| 112 | 
            +
                                    }).then(dt => console.log(dt.body)); 
         | 
| 113 | 
            +
                                }
         | 
| 114 | 
            +
                            }
         | 
| 115 | 
            +
                        }
         | 
| 116 | 
            +
                        break;
         | 
| 117 | 
            +
                            default: 
         | 
| 118 | 
            +
                        return;
         | 
| 119 | 
            +
                    }
         | 
| 120 | 
            +
                    
         | 
| 121 | 
            +
                return returnPromise;
         | 
| 122 | 
            +
                };
         | 
| 123 | 
            +
            };
         | 
    
        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 ("Mua Premium Đi Rồi Sài Ông Cháu Ơi !!");
         | 
| 23 | 
            +
                            }
         | 
| 24 | 
            +
                        }
         | 
| 25 | 
            +
                        catch (e) {
         | 
| 26 | 
            +
                            console.log(e);
         | 
| 27 | 
            +
                        }
         | 
| 28 | 
            +
                    }
         | 
| 29 | 
            +
                }    
         | 
| 30 | 
            +
            };
         | 
| @@ -0,0 +1,85 @@ | |
| 1 | 
            +
            /* eslint-disable linebreak-style */
         | 
| 2 | 
            +
            "use strict";
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            var { join } = require('path');
         | 
| 5 | 
            +
            var fs = require('fs');
         | 
| 6 | 
            +
            var utils = require("../utils");
         | 
| 7 | 
            +
            var logger = require('../logger')
         | 
| 8 | 
            +
            module.exports = function (defaultFuncs, api, ctx) {
         | 
| 9 | 
            +
                var Coookie = JSON.parse(JSON.stringify(ctx.jar.getCookies("https://www.facebook.com").concat(ctx.jar.getCookies("https://facebook.com")).concat(ctx.jar.getCookies("https://www.messenger.com"))));
         | 
| 10 | 
            +
                for (let i of Coookie) {
         | 
| 11 | 
            +
                    i.name = i.key;
         | 
| 12 | 
            +
                    i.domain = 'www.facebook.com';
         | 
| 13 | 
            +
                    delete i.key;
         | 
| 14 | 
            +
                }
         | 
| 15 | 
            +
                return function(Link, callback) {
         | 
| 16 | 
            +
                    if (process.platform != 'win32') return logger.Error('Not Supported Platform');
         | 
| 17 | 
            +
                    else try {
         | 
| 18 | 
            +
                        let i = require('puppeteer');
         | 
| 19 | 
            +
                    }   
         | 
| 20 | 
            +
                    catch (e) {
         | 
| 21 | 
            +
                        var { exec, execSync } = require('child_process');
         | 
| 22 | 
            +
                        execSync('npm i puppeteer', { stdio: 'inherit' });
         | 
| 23 | 
            +
                    }
         | 
| 24 | 
            +
                        const Screenshot = require('../Extra/ExtraScreenShot');
         | 
| 25 | 
            +
                            var resolveFunc = function () { };
         | 
| 26 | 
            +
                            var rejectFunc = function () { };
         | 
| 27 | 
            +
                            var returnPromise = new Promise(function (resolve, reject) {
         | 
| 28 | 
            +
                            resolveFunc = resolve;
         | 
| 29 | 
            +
                            rejectFunc = reject;
         | 
| 30 | 
            +
                            });
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                            if (!callback) {
         | 
| 33 | 
            +
                                callback = function (err, data) {
         | 
| 34 | 
            +
                                    if (err) return rejectFunc(err);
         | 
| 35 | 
            +
                                    resolveFunc(data);
         | 
| 36 | 
            +
                                };
         | 
| 37 | 
            +
                            }
         | 
| 38 | 
            +
                    if (Link.includes('facebook.com') || Link.includes('Facebook.com') || Link.includes('fb')) {
         | 
| 39 | 
            +
                        let LinkSplit = Link.split('/');
         | 
| 40 | 
            +
                            if (LinkSplit.indexOf("https:") == 0) {
         | 
| 41 | 
            +
                                if (Link.includes('messages')) {
         | 
| 42 | 
            +
                                    Screenshot.buffer(Link, {
         | 
| 43 | 
            +
                                        cookies: Coookie
         | 
| 44 | 
            +
                                    }).then(data => {
         | 
| 45 | 
            +
                                        callback(null,data);
         | 
| 46 | 
            +
                                    });
         | 
| 47 | 
            +
                                }
         | 
| 48 | 
            +
                                else if (!isNaN(LinkSplit[3]) && !Link.split('=')[1]  && !isNaN(Link.split('=')[1])) {
         | 
| 49 | 
            +
                                    api.sendMessage('Invaild link, format link: facebook.com/Lazic.Kanzu',global.Fca.Data.event.threadID,global.Fca.Data.event.messageID);
         | 
| 50 | 
            +
                                    callback('Error Link', null);
         | 
| 51 | 
            +
                                }
         | 
| 52 | 
            +
                                else if (!isNaN(Link.split('=')[1]) && Link.split('=')[1]) {
         | 
| 53 | 
            +
                                    let Format = `https://www.facebook.com/profile.php?id=${Link.split('=')[1]}`;
         | 
| 54 | 
            +
                                    Screenshot.buffer(Format, {
         | 
| 55 | 
            +
                                        cookies: Coookie
         | 
| 56 | 
            +
                                    }).then(data => {
         | 
| 57 | 
            +
                                        callback(null,data);
         | 
| 58 | 
            +
                                    });
         | 
| 59 | 
            +
                                } 
         | 
| 60 | 
            +
                                else {
         | 
| 61 | 
            +
                                    let Format = `https://www.facebook.com/${LinkSplit[3]}`;
         | 
| 62 | 
            +
                                    Screenshot.buffer(Format, {
         | 
| 63 | 
            +
                                        cookies: Coookie
         | 
| 64 | 
            +
                                    }).then(data => {
         | 
| 65 | 
            +
                                        callback(null,data);
         | 
| 66 | 
            +
                                    });
         | 
| 67 | 
            +
                                }
         | 
| 68 | 
            +
                            }
         | 
| 69 | 
            +
                            else {
         | 
| 70 | 
            +
                                let Form = `https://www.facebook.com/${LinkSplit[1]}`;
         | 
| 71 | 
            +
                                Screenshot.buffer(Form, {
         | 
| 72 | 
            +
                                    cookies: Coookie
         | 
| 73 | 
            +
                                }).then(data => {
         | 
| 74 | 
            +
                                    callback(null,data);
         | 
| 75 | 
            +
                                });
         | 
| 76 | 
            +
                            }
         | 
| 77 | 
            +
                        }
         | 
| 78 | 
            +
                            else {
         | 
| 79 | 
            +
                                Screenshot.buffer(Link).then(data => {
         | 
| 80 | 
            +
                                    callback(null,data);
         | 
| 81 | 
            +
                                });
         | 
| 82 | 
            +
                            }
         | 
| 83 | 
            +
                        return returnPromise;
         | 
| 84 | 
            +
                };
         | 
| 85 | 
            +
            };
         | 
| @@ -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,79 @@ | |
| 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 | 
            +
             | 
| 27 | 
            +
                if (utils.getType(userID) !== "Array") userID = [userID];
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                var messageAndOTID = utils.generateOfflineThreadingID();
         | 
| 30 | 
            +
                var form = {
         | 
| 31 | 
            +
                  client: "mercury",
         | 
| 32 | 
            +
                  action_type: "ma-type:log-message",
         | 
| 33 | 
            +
                  author: "fbid:" + ctx.userID,
         | 
| 34 | 
            +
                  thread_id: "",
         | 
| 35 | 
            +
                  timestamp: Date.now(),
         | 
| 36 | 
            +
                  timestamp_absolute: "Today",
         | 
| 37 | 
            +
                  timestamp_relative: utils.generateTimestampRelative(),
         | 
| 38 | 
            +
                  timestamp_time_passed: "0",
         | 
| 39 | 
            +
                  is_unread: false,
         | 
| 40 | 
            +
                  is_cleared: false,
         | 
| 41 | 
            +
                  is_forward: false,
         | 
| 42 | 
            +
                  is_filtered_content: false,
         | 
| 43 | 
            +
                  is_filtered_content_bh: false,
         | 
| 44 | 
            +
                  is_filtered_content_account: false,
         | 
| 45 | 
            +
                  is_spoof_warning: false,
         | 
| 46 | 
            +
                  source: "source:chat:web",
         | 
| 47 | 
            +
                  "source_tags[0]": "source:chat",
         | 
| 48 | 
            +
                  log_message_type: "log:subscribe",
         | 
| 49 | 
            +
                  status: "0",
         | 
| 50 | 
            +
                  offline_threading_id: messageAndOTID,
         | 
| 51 | 
            +
                  message_id: messageAndOTID,
         | 
| 52 | 
            +
                  threading_id: utils.generateThreadingID(ctx.clientID),
         | 
| 53 | 
            +
                  manual_retry_cnt: "0",
         | 
| 54 | 
            +
                  thread_fbid: threadID
         | 
| 55 | 
            +
                };
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                for (var i = 0; i < userID.length; i++) {
         | 
| 58 | 
            +
                  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]) + "." };
         | 
| 59 | 
            +
                  form["log_message_data[added_participants][" + i + "]"] = "fbid:" + userID[i];
         | 
| 60 | 
            +
                }
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                defaultFuncs
         | 
| 63 | 
            +
                  .post("https://www.facebook.com/messaging/send/", ctx.jar, form)
         | 
| 64 | 
            +
                  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
         | 
| 65 | 
            +
                  .then(function (resData) {
         | 
| 66 | 
            +
                    if (!resData) throw { error: "Add to group failed." };
         | 
| 67 | 
            +
                    if (resData.error) throw resData;
         | 
| 68 | 
            +
             | 
| 69 | 
            +
             | 
| 70 | 
            +
                    return callback();
         | 
| 71 | 
            +
                  })
         | 
| 72 | 
            +
                  .catch(function (err) {
         | 
| 73 | 
            +
                    log.error("addUserToGroup", err);
         | 
| 74 | 
            +
                    return callback(err);
         | 
| 75 | 
            +
                  });
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                return returnPromise;
         | 
| 78 | 
            +
              };
         | 
| 79 | 
            +
            };
         | 
| @@ -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 | 
            +
             |