diff --git a/index.js b/index.js index c80bbbb..a3189b1 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,6 @@ Hash: SHA256 */ - /* Moomoo-AI-Bot-Sender Copyright (C) 2018 Mega Mewthree @@ -21,21 +20,18 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ - // Created on April 22nd, 2018 - const io = require("socket.io-client"); const request = require("request"); const http = require("http"); const url = require("url"); const fs = require("fs"); -const { spawn } = require("child_process"); - +const spawn = require("child_process").spawn; let parser = null; try { require.resolve("socket.io-msgpack-parser"); parser = require("socket.io-msgpack-parser"); -}catch(e) { +} catch (e) { console.error("Socket.io Msgpack Parser was not installed. Exiting and installing..."); spawn("npm", ["install"], { stdio: "ignore", @@ -44,7 +40,6 @@ try { }); process.exit(); } - if (!fs.existsSync(`${__dirname}/lastUpdated.txt`) || Date.now() - parseInt(fs.readFileSync(`${__dirname}/lastUpdated.txt`, "utf8")) > 43200000) { spawn("node", [`${__dirname}/autoupdate.js`], { stdio: "ignore", @@ -52,20 +47,15 @@ if (!fs.existsSync(`${__dirname}/lastUpdated.txt`) || Date.now() - parseInt(fs.r detached: true }); } - let computer = null; - try { require.resolve("robotjs"); computer = require("robotjs"); -}catch(e) { +} catch (e) { console.error("Robot.js was not installed correctly. Follow mouse function is disabled."); } - const screen = computer && computer.getScreenSize(); - const args = parseFlags(process.argv.slice(2).join(" "), ["--num", "--link", "--tribe", "--name", "--randNames", "--randSkins", "--chat", "--ai", "--probeTribe", "--probeName", "--probeRegex", "--autoHeal", "--hat", "--autoAttack"]); - const httpServer = http.createServer((req, res) => { const args = url.parse(req.url, true).query; if (args.ownerID) { @@ -87,16 +77,18 @@ httpServer.on("listening", () => { console.log(`Http server ready at ${Date.now()}`); }); httpServer.listen(15729); - let ownerID = null; let followID = null; - let attackFollowedPlayer = false; let stay = false; - -const goto = { x: null, y: null }; - -let mousePos = { x: 0, y: 0 }; +const goto = { + x: null, + y: null +}; +let mousePos = { + x: 0, + y: 0 +}; let followMouse = false; let getMouseInputInterval = null; if (computer) { @@ -121,15 +113,21 @@ function get(url) { function parseFlags(string, flags_array) { if (!Array.isArray(flags_array)) { - return { error: "Array of flags not found." }; + return { + error: "Array of flags not found." + }; } const return_object = {}; - const flag_locations = [[-1, "null", []]]; + const flag_locations = [ + [-1, "null", []] + ]; const string_array = string.split(" "); for (let index = 0; index < string_array.length; index++) { if (flags_array.indexOf(string_array[index]) > -1) { - flag_locations.push([index, string_array[index], []]); - }else{ + flag_locations.push([index, string_array[index], + [] + ]); + } else { flag_locations[flag_locations.length - 1][2].push(string_array[index]); } } @@ -145,7 +143,7 @@ function getIP(link) { link = link.match(/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/g); if (link.length > 0) { return link[link.length - 1]; - }else{ + } else { return false; } } @@ -160,21 +158,18 @@ function processInput(line) { function getHatID(name) { const possiblyInt = parseInt(name); - if (!isNaN(possiblyInt)) { - return possiblyInt; - }else{ + if (isNaN(possiblyInt)) { if (!name || !name.toString) return null; let safeName = name.toString().toLowerCase(); safeName = safeName.replace(/[$-/:-?{-~!"^_`\[\]]/g, ""); // remove symbols safeName = safeName.replace(/\s/g, ""); // remove whitespace safeName = data.hatAliases[safeName]; - if (!isNaN(safeName)) return safeName; - return null; + return isNaN(safeName) ? null : safeName; + } else { + return possiblyInt; } } - const data = require("./data.json"); - const names = [ "Wally", "Tanika", @@ -227,903 +222,899 @@ const names = [ "Jeraldine", "Hunter", ]; - -const allServers = [ - { - "ip":"45.76.136.65", - "maxPlayers":80, - "experimental":false, +const allServers = [{ + "ip": "45.76.136.65", + "maxPlayers": 80, + "experimental": false, }, { - "ip":"45.76.133.132", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.133.132", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.138.87", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.138.87", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"108.61.172.61", - "maxPlayers":40, - "experimental":false, + "ip": "108.61.172.61", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"108.61.172.171", - "maxPlayers":40, - "experimental":false, + "ip": "108.61.172.171", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.142.135", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.142.135", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.88.200", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.88.200", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.59.212", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.59.212", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.133.107", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.133.107", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.56.35", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.56.35", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.226.52", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.226.52", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.132.116", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.132.116", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.132.153", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.132.153", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.183.22", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.183.22", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"104.238.174.199", - "maxPlayers":40, - "experimental":false, + "ip": "104.238.174.199", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.100.199", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.100.199", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"104.238.185.114", - "maxPlayers":40, - "experimental":false, + "ip": "104.238.185.114", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"104.238.174.163", - "maxPlayers":40, - "experimental":false, + "ip": "104.238.174.163", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"104.238.172.118", - "maxPlayers":40, - "experimental":false, + "ip": "104.238.172.118", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.139.158", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.139.158", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"108.61.173.191", - "maxPlayers":40, - "experimental":false, + "ip": "108.61.173.191", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.140.136", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.140.136", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"104.238.185.37", - "maxPlayers":40, - "experimental":false, + "ip": "104.238.185.37", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.128.8", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.128.8", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"108.61.173.128", - "maxPlayers":40, - "experimental":false, + "ip": "108.61.173.128", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.141.118", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.141.118", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.96.219", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.96.219", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.140.11", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.140.11", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.56.124", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.56.124", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"108.61.175.195", - "maxPlayers":40, - "experimental":false, + "ip": "108.61.175.195", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.140.159", - "maxPlayers":80, - "experimental":true, + "ip": "45.77.140.159", + "maxPlayers": 80, + "experimental": true, }, { - "ip":"45.76.82.46", - "maxPlayers":40, - "experimental":true, + "ip": "45.76.82.46", + "maxPlayers": 40, + "experimental": true, }, { - "ip":"45.32.155.246", - "maxPlayers":40, - "experimental":true, + "ip": "45.32.155.246", + "maxPlayers": 40, + "experimental": true, }, { - "ip":"45.76.89.139", - "maxPlayers":40, - "experimental":true, + "ip": "45.76.89.139", + "maxPlayers": 40, + "experimental": true, }, { - "ip":"45.76.91.231", - "maxPlayers":40, - "experimental":true, + "ip": "45.76.91.231", + "maxPlayers": 40, + "experimental": true, }, { - "ip":"45.63.119.195", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.119.195", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.53.1", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.53.1", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.116.80", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.116.80", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.119.207", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.119.207", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.119.52", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.119.52", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.153.139", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.153.139", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.143.240", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.143.240", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.156.154", - "maxPlayers":80, - "experimental":false, + "ip": "45.32.156.154", + "maxPlayers": 80, + "experimental": false, }, { - "ip":"45.76.84.243", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.84.243", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.141.202", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.141.202", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.65.89", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.65.89", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.87.213", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.87.213", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.87.26", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.87.26", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"104.238.159.33", - "maxPlayers":40, - "experimental":false, + "ip": "104.238.159.33", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.159.20", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.159.20", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.53.215", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.53.215", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"108.61.190.220", - "maxPlayers":40, - "experimental":false, + "ip": "108.61.190.220", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.92.133", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.92.133", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.85.241", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.85.241", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"104.207.130.132", - "maxPlayers":40, - "experimental":false, + "ip": "104.207.130.132", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"104.207.131.132", - "maxPlayers":40, - "experimental":false, + "ip": "104.207.131.132", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.119.244", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.119.244", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.84.207", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.84.207", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.85.159", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.85.159", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.94.198", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.94.198", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.67.137", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.67.137", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.92.138", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.92.138", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.86.95", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.86.95", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.90.54", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.90.54", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"104.207.151.1", - "maxPlayers":80, - "experimental":true, + "ip": "104.207.151.1", + "maxPlayers": 80, + "experimental": true, }, { - "ip":"45.63.83.190", - "maxPlayers":40, - "experimental":true, + "ip": "45.63.83.190", + "maxPlayers": 40, + "experimental": true, }, { - "ip":"45.77.187.224", - "maxPlayers":40, - "experimental":true, + "ip": "45.77.187.224", + "maxPlayers": 40, + "experimental": true, }, { - "ip":"104.156.231.170", - "maxPlayers":40, - "experimental":true, + "ip": "104.156.231.170", + "maxPlayers": 40, + "experimental": true, }, { - "ip":"45.77.185.222", - "maxPlayers":40, - "experimental":true, + "ip": "45.77.185.222", + "maxPlayers": 40, + "experimental": true, }, { - "ip":"45.32.131.170", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.131.170", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"104.156.231.84", - "maxPlayers":40, - "experimental":false, + "ip": "104.156.231.84", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.84.67", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.84.67", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.139.137", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.139.137", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.87.14", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.87.14", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.3.146", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.3.146", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.0.180", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.0.180", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"104.238.183.121", - "maxPlayers":40, - "experimental":false, + "ip": "104.238.183.121", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.130.32", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.130.32", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.141.144", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.141.144", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.2.244", + "ip": "45.77.2.244", }, { - "ip":"45.63.90.253", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.90.253", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.184.80", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.184.80", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"104.238.181.215", - "maxPlayers":40, - "experimental":false, + "ip": "104.238.181.215", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.141.124", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.141.124", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.88.172", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.88.172", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.2.123", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.2.123", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.86.66", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.86.66", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.89.186", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.89.186", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.95.94", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.95.94", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.0.61", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.0.61", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.4.113", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.4.113", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"104.238.182.118", - "maxPlayers":40, - "experimental":false, + "ip": "104.238.182.118", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.84.223", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.84.223", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.7.228", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.7.228", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.84.65", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.84.65", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.184.245", - "maxPlayers":80, - "experimental":false, + "ip": "45.77.184.245", + "maxPlayers": 80, + "experimental": false, }, { - "ip":"45.63.83.173", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.83.173", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.93.208", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.93.208", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.87.182", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.87.182", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"207.246.66.206", - "maxPlayers":80, - "experimental":true, + "ip": "207.246.66.206", + "maxPlayers": 80, + "experimental": true, }, { - "ip":"45.77.163.153", - "maxPlayers":40, - "experimental":true, + "ip": "45.77.163.153", + "maxPlayers": 40, + "experimental": true, }, { - "ip":"45.77.164.226", - "maxPlayers":40, - "experimental":true, + "ip": "45.77.164.226", + "maxPlayers": 40, + "experimental": true, }, { - "ip":"207.246.67.140", - "maxPlayers":40, - "experimental":true, + "ip": "207.246.67.140", + "maxPlayers": 40, + "experimental": true, }, { - "ip":"45.32.163.130", - "maxPlayers":40, - "experimental":true, + "ip": "45.32.163.130", + "maxPlayers": 40, + "experimental": true, }, { - "ip":"45.77.163.173", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.163.173", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.174.88", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.174.88", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"104.156.247.133", - "maxPlayers":40, - "experimental":false, + "ip": "104.156.247.133", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.192.182", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.192.182", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.109.213", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.109.213", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.168.83", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.168.83", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.169.37", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.169.37", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"104.207.147.14", - "maxPlayers":40, - "experimental":false, + "ip": "104.207.147.14", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.118.112", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.118.112", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.168.187", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.168.187", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"104.156.244.247", - "maxPlayers":40, - "experimental":false, + "ip": "104.156.244.247", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.193.252", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.193.252", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.165.21", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.165.21", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.192.49", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.192.49", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.104.17", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.104.17", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.175.103", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.175.103", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.111.179", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.111.179", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.192.175", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.192.175", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.169.197", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.169.197", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.192.149", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.192.149", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.164.181", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.164.181", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.192.112", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.192.112", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.192.132", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.192.132", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.174.168", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.174.168", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.167.61", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.167.61", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.162.62", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.162.62", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.192.177", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.192.177", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"104.238.136.101", - "maxPlayers":40, - "experimental":false, + "ip": "104.238.136.101", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.160.82", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.160.82", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.192.136", - "maxPlayers":80, - "experimental":false, + "ip": "45.77.192.136", + "maxPlayers": 80, + "experimental": false, }, { - "ip":"45.77.37.126", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.37.126", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.32.72", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.32.72", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.108.134", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.108.134", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.150.102", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.150.102", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.37.202", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.37.202", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.182.186", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.182.186", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.40.183", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.40.183", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.163.225", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.163.225", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.32.131", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.32.131", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.103.118", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.103.118", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.33.206", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.33.206", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.104.160", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.104.160", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.116.159", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.116.159", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.105.212", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.105.212", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.113.18", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.113.18", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.109.24", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.109.24", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.180.83", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.180.83", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.119.216", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.119.216", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.77.38.189", - "maxPlayers":40, - "experimental":false, + "ip": "45.77.38.189", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.160.21", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.160.21", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.117.201", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.117.201", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"107.191.56.127", - "maxPlayers":40, - "experimental":false, + "ip": "107.191.56.127", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.117.68", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.117.68", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"108.61.185.149", - "maxPlayers":40, - "experimental":false, + "ip": "108.61.185.149", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.242.88", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.242.88", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.32.245.179", - "maxPlayers":40, - "experimental":false, + "ip": "45.32.245.179", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.120.98", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.120.98", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.113.134", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.113.134", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.123.248", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.123.248", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.25.76", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.25.76", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.63.28.39", - "maxPlayers":40, - "experimental":false, + "ip": "45.63.28.39", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.112.235", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.112.235", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"103.43.75.103", - "maxPlayers":40, - "experimental":false, + "ip": "103.43.75.103", + "maxPlayers": 40, + "experimental": false, }, { - "ip":"45.76.123.234", - "maxPlayers":40, - "experimental":false, + "ip": "45.76.123.234", + "maxPlayers": 40, + "experimental": false, }, // Dev servers { - "ip":"45.32.130.215", - "maxPlayers":40, - "experimental":true, + "ip": "45.32.130.215", + "maxPlayers": 40, + "experimental": true, }, { - "ip":"45.63.90.79", - "maxPlayers":40, - "experimental":true, + "ip": "45.63.90.79", + "maxPlayers": 40, + "experimental": true, }, { - "ip":"45.77.2.192", - "maxPlayers":40, - "experimental":true, + "ip": "45.77.2.192", + "maxPlayers": 40, + "experimental": true, }, { - "ip":"45.77.0.43", - "maxPlayers":40, - "experimental":false, // Uncertain + "ip": "45.77.0.43", + "maxPlayers": 40, + "experimental": false, // Uncertain }, { - "ip":"45.32.128.142", - "maxPlayers":40, - "experimental":false, // Uncertain + "ip": "45.32.128.142", + "maxPlayers": 40, + "experimental": false, // Uncertain }, { - "ip":"45.63.93.27", - "maxPlayers":40, - "experimental":false, // Uncertain + "ip": "45.63.93.27", + "maxPlayers": 40, + "experimental": false, // Uncertain }, { - "ip":"45.77.2.25", - "maxPlayers":40, - "experimental":false, // Uncertain + "ip": "45.77.2.25", + "maxPlayers": 40, + "experimental": false, // Uncertain }, { - "ip":"45.63.82.111", - "maxPlayers":40, - "experimental":false, // Uncertain + "ip": "45.63.82.111", + "maxPlayers": 40, + "experimental": false, // Uncertain }, { - "ip":"45.77.7.137", - "maxPlayers":40, - "experimental":false, // Uncertain + "ip": "45.77.7.137", + "maxPlayers": 40, + "experimental": false, // Uncertain }, { - "ip":"45.63.88.19", - "maxPlayers":40, - "experimental":false, // Uncertain + "ip": "45.63.88.19", + "maxPlayers": 40, + "experimental": false, // Uncertain }, ]; - const bots = []; const tribes = {}; const players = {}; - class Bot { constructor(n, ip, name, tribe, chatMsg, ai, probe, autoHeal, randSkins, hatID, autoAttack) { this.number = n; @@ -1190,8 +1181,8 @@ class Bot { }); // Leaderboard sk.on("5", data => { - if (probeName){ - if ((probeName instanceof RegExp && data.filter(d => typeof d === "string" && d.match(probeName)).length > 0) || (typeof probeName === "string" && data.indexOf(probeName) > -1)){ + if (probeName) { + if ((probeName instanceof RegExp && data.filter(d => typeof d === "string" && d.match(probeName)).length > 0) || (typeof probeName === "string" && data.indexOf(probeName) > -1)) { console.log(`${this.ip}`); sk.disconnect(); } @@ -1200,8 +1191,8 @@ class Bot { // ID (tribes[name, owner]) sk.on("id", (data) => { data.teams.forEach(t => { - if (probeTribe){ - if ((probeTribe instanceof RegExp && t.sid.match(probeTribe)) || (typeof probeTribe === "string" && t.sid === probeTribe)){ + if (probeTribe) { + if ((probeTribe instanceof RegExp && t.sid.match(probeTribe)) || (typeof probeTribe === "string" && t.sid === probeTribe)) { console.log(`${this.ip}`); sk.disconnect(); } @@ -1209,7 +1200,7 @@ class Bot { }); }); return true; - }else{ + } else { sk.once("disconnect", () => { bots.splice(bots.indexOf(this), 1); console.log(`${this.number} disconnected`); @@ -1260,19 +1251,19 @@ class Bot { this.pos.y = data[2 + i * 13]; this.angle = data[3 + i * 13]; } - if (!players[data[0 + i * 13]]) { + if (players[data[0 + i * 13]]) { + const p = players[data[0 + i * 13]]; + p.x = data[1 + i * 13]; + p.y = data[2 + i * 13], + p.angle = data[3 + i * 13], + p.lastUpdated = Date.now(); + } else { players[data[0 + i * 13]] = { x: data[1 + i * 13], y: data[2 + i * 13], angle: data[3 + i * 13], lastUpdated: Date.now(), }; - }else{ - const p = players[data[0 + i * 13]]; - p.x = data[1 + i * 13]; - p.y = data[2 + i * 13], - p.angle = data[3 + i * 13], - p.lastUpdated = Date.now(); } } this.update(); @@ -1316,15 +1307,20 @@ class Bot { }); // Tribe add request ({sid, owner}) sk.on("ac", (data) => { - tribes[name] = { owner: data.owner, players: [] }; + tribes[name] = { + owner: data.owner, + players: [] + }; }); // Tribe join request (id, name) sk.on("an", (id, name) => { sk.emit("11", id, 1); if (players[id]) { players[id].inMainTribe = true; - }else{ - players[id] = { inMainTribe: true }; + } else { + players[id] = { + inMainTribe: true + }; } }); // Chat (id, name) @@ -1333,93 +1329,110 @@ class Bot { if (!msg.startsWith("!")) return; const args = msg.slice(1).trim().split(/ +/g); const command = args.shift().toLowerCase(); - if (command === "fme") { - goto.x = goto.y = null; - stay = false; - followID = ownerID; - attackFollowedPlayer = false; - followMouse = false; - }else if (command === "id") { - const a = []; - for (const k in players) { - if (players[k].name === args.join(" ")) a.push(k); - } - if (a.length > 0) { - this.chatMsg = a.join(", ").slice(0, 30); - }else{ - this.chatMsg = "Player not in memory."; - } - clearInterval(this.chatInterval); - this.chatInterval = null; - setTimeout(this.chat.bind(this), 1000); - }else if (command === "fid") { - goto.x = goto.y = null; - stay = false; - followID = parseInt(args[0]); - attackFollowedPlayer = false; - followMouse = false; - }else if (command === "atkid") { - goto.x = goto.y = null; - stay = false; - followID = parseInt(args[0]); - attackFollowedPlayer = true; - followMouse = false; - }else if (command === "s") { - goto.x = goto.y = null; - stay = true; - followID = null; - attackFollowedPlayer = false; - followMouse = false; - }else if (command === "r") { - goto.x = goto.y = null; - stay = false; - followID = null; - attackFollowedPlayer = false; - followMouse = false; - }else if (command === "fm" && computer) { - goto.x = goto.y = null; - stay = false; - followID = null; - attackFollowedPlayer = false; - followMouse = true; - }else if (command === "hat" && args[0]) { - const hatToEquip = args[0]; - let len = bots.length; - let bot, triedHat; - while (len--) { - bot = bots[len]; - triedHat = bot.tryHatOn(hatToEquip); - if (triedHat) { - bot.chatMsg = "Switched hat."; - }else if (triedHat === false) { - bot.chatMsg = `Need ${data.hatPrices[getHatID(hatToEquip)] - bot.materials.points} more gold.`; - }else{ - bot.chatMsg = "Invalid hat!"; + switch (command) { + case "fme": + goto.x = goto.y = null; + stay = false; + followID = ownerID; + attackFollowedPlayer = false; + followMouse = false; + break; + case "id": + const a = []; + for (const k in players) { + if (players[k].name === args.join(" ")) a.push(k); } - clearInterval(bot.chatInterval); - bot.chatInterval = null; - setTimeout(bot.chat.bind(bot), 1000); - } - }else if (command === "atk") { - this.autoAttack = !this.autoAttack; - this.socket && this.socket.emit("7", this.autoAttack); - }else if (command === "sp") { - this.socket.emit("5", 5, null); - this.socket.emit("4", 1, null); - this.socket.emit("4", 0, null); - this.socket.emit("5", 1, null); - }else if (command === "w") { - this.socket.emit("5", 2, null); - this.socket.emit("4", 1, null); - this.socket.emit("4", 0, null); - this.socket.emit("5", 1, null); + this.chatMsg = a.length > 0 ? a.join(", ").slice(0, 30) : "Player not in memory."; + clearInterval(this.chatInterval); + this.chatInterval = null; + setTimeout(this.chat.bind(this), 1000); + break; + case "fid": + goto.x = goto.y = null; + stay = false; + followID = parseInt(args[0]); + attackFollowedPlayer = false; + followMouse = false; + break; + case "atkid": + goto.x = goto.y = null; + stay = false; + followID = parseInt(args[0]); + attackFollowedPlayer = true; + followMouse = false; + break; + case "s": + goto.x = goto.y = null; + stay = true; + followID = null; + attackFollowedPlayer = false; + followMouse = false; + break; + case "r": + goto.x = goto.y = null; + stay = false; + followID = null; + attackFollowedPlayer = false; + followMouse = false; + break; + case "fm": + if (computer) { + goto.x = goto.y = null; + stay = false; + followID = null; + attackFollowedPlayer = false; + followMouse = true; + } else { + this.chatMsg = "Cannot use follow mouse."; + } + break; + case "hat": + if (args[0]) { + const hatToEquip = args[0]; + let len = bots.length; + let bot, triedHat; + while (len--) { + bot = bots[len]; + triedHat = bot.tryHatOn(hatToEquip); + if (triedHat) { + bot.chatMsg = "Switched hat."; + } else if (triedHat === false) { + bot.chatMsg = `Need ${data.hatPrices[getHatID(hatToEquip)] - bot.materials.points} more gold.`; + } else { + bot.chatMsg = "Invalid hat!"; + } + clearInterval(bot.chatInterval); + bot.chatInterval = null; + setTimeout(bot.chat.bind(bot), 1000); + } + } + break; + case "atk": + this.autoAttack = !this.autoAttack; + this.socket && this.socket.emit("7", this.autoAttack); + break; + case "sp": + this.socket.emit("5", 5, null); + this.socket.emit("4", 1, null); + this.socket.emit("4", 0, null); + this.socket.emit("5", 1, null); + break; + case "w": + this.socket.emit("5", 2, null); + this.socket.emit("4", 1, null); + this.socket.emit("4", 0, null); + this.socket.emit("5", 1, null); + break; } }); // ID (tribes[name, owner]) sk.on("id", (data) => { if (this === bots[0]) { data.teams.forEach(t => { - tribes[t.sid] = { owner: t.owner, players: [] }; + tribes[t.sid] = { + owner: t.owner, + players: [] + }; }); } }); @@ -1428,14 +1441,20 @@ class Bot { if (tribes[this.tribe]) { tribes[this.tribe].players = []; for (let i = 0, len = data.length; i < len; i += 2) { - tribes[this.tribe].players.push({ id: data[i], name: data[i + 1] }); + tribes[this.tribe].players.push({ + id: data[i], + name: data[i + 1] + }); } } }); // Tribe Start (name, owner) sk.on("st", (name, owner) => { if (this === bots[0]) { - tribes[name] = { owner: owner, players: [] }; + tribes[name] = { + owner: owner, + players: [] + }; } }); // Minimap Ping (x, y) @@ -1477,7 +1496,7 @@ class Bot { this.socket.emit("13", 1, id); this.socket.emit("13", 0, id); return true; - }else{ + } else { this.socket.emit("13", 0, id); return false; } @@ -1492,11 +1511,10 @@ class Bot { } } update() { - if (!this.socket) return; - if (!this.ai) return; + if (!this.socket || !this.ai) return; if (stay) { this.socket.emit(3, null); - }else if (followMouse) { + } else if (followMouse) { const p = players[ownerID]; if (p && p.x) { const targetX = p.x + (mousePos.x - screen.width / 2); @@ -1504,12 +1522,12 @@ class Bot { if (Math.pow(this.pos.x - targetX, 2) + Math.pow(this.pos.y - targetY, 2) < 20000) { this.socket.emit(2, p.angle); this.socket.emit(3, null); - }else{ + } else { this.socket.emit(2, Math.atan2(targetY - this.pos.y, targetX - this.pos.x)); this.socket.emit(3, Math.atan2(targetY - this.pos.y, targetX - this.pos.x)); } } - }else if (followID && players[followID]) { + } else if (followID && players[followID]) { const p = players[followID]; if (p && p.x) { const now = Date.now(); @@ -1518,42 +1536,41 @@ class Bot { const randAngle = Math.random() * Math.PI * 2; this.socket.emit(2, randAngle); this.socket.emit(3, randAngle); - }else if (!attackFollowedPlayer) { + } else if (!attackFollowedPlayer) { if (Math.pow(this.pos.x - p.x, 2) + Math.pow(this.pos.y - p.y, 2) < 20000) { this.socket.emit(2, p.angle); this.socket.emit(3, null); - }else{ + } else { this.socket.emit(2, Math.atan2(p.y - this.pos.y, p.x - this.pos.x)); this.socket.emit(3, Math.atan2(p.y - this.pos.y, p.x - this.pos.x)); } - }else{ + } else { this.socket.emit(2, Math.atan2(p.y - this.pos.y, p.x - this.pos.x)); this.socket.emit(3, Math.atan2(p.y - this.pos.y, p.x - this.pos.x)); } } - }else if (goto.x && goto.y) { + } else if (goto.x && goto.y) { if (Math.pow(this.pos.x - goto.x, 2) + Math.pow(this.pos.y - goto.y, 2) < 40000) { this.socket.emit(2, 0); this.socket.emit(3, null); - }else{ + } else { this.socket.emit(2, Math.atan2(goto.y - this.pos.y, goto.x - this.pos.x)); this.socket.emit(3, Math.atan2(goto.y - this.pos.y, goto.x - this.pos.x)); } return; - }else{ + } else { this.socket.emit(3, null); } } } function escapeRegExp(s) { - if (s.startsWith("/") && s.endsWith("/")){ + if (s.startsWith("/") && s.endsWith("/")) { s = s.split(""); s = s.slice(1, s.length - 1).join(""); } - return s.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"); + return s.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"); } - const numBots = (args.num && parseInt(args.num.value)) || 0; const link = (args.link && getIP(args.link.value)) || null; let name = (args.randNames && args.randNames.value.toLowerCase() != "false" && args.randNames.value != 0) ? true : ((args.name && args.name.value) || "unknown"); @@ -1571,36 +1588,32 @@ const autoAttack = !args.autoAttack || (args.autoAttack.value.toLowerCase() != " typeof name === "string" && (name = name.slice(0, 16)); tribe && (tribe = tribe.slice(0, 6)); chat && (chat = chat.slice(0, 30)); - if (probe) { - if (probeRegex){ + if (probeRegex) { console.log(`Initiating probe for${(args.probeTribe && args.probeTribe.value) ? ` tribe ${args.probeTribe.value}` : ""}${(args.probeName && args.probeName.value) ? ` player ${args.probeName.value}` : ""} using regex.`); - }else{ + } else { console.log(`Initiating probe for${probeTribe ? ` tribe ${probeTribe}` : ""}${probeName ? ` player ${probeName}` : ""}.`); } - (function connectBots(i) { - if (i <= 0) return; - const promises = []; - for (let j = i; (j > i - 8) && (j > 0); j--) { + connectBots(allServers.length, true); +} else { + connectBots(numBots); +} + +function connectBots(i, probe = false) { + if (i <= 0) return; + const promises = []; + for (let j = i; + (j > i - 8) && (j > 0); j--) { + if (probe) { promises.push(new Bot(j, allServers[j - 1].ip, "PROBE", tribe, chat, ai, probe, autoHeal, randSkins, hatID, autoAttack).connect()); - } - Promise.all(promises).then(() => { - connectBots(i - 8); - }).catch(console.error); - })(allServers.length); -}else{ - (function connectBots(i) { - if (i <= 0) return; - const promises = []; - for (let j = i; (j > i - 8) && (j > 0); j--) { + } else { promises.push(new Bot(j, link, name === true ? names[(Math.random() * names.length) | 0] : name, tribe, chat, ai, probe, autoHeal, randSkins, hatID, autoAttack).connect()); } - Promise.all(promises).then(() => { - connectBots(i - 8); - }).catch(console.error); - })(numBots); + } + Promise.all(promises).then(() => { + connectBots(i - 8); + }).catch(console.error); } - process.stdin.setEncoding("utf8"); process.stdin.on("data", data => { data.split(/[\r\n]+/).forEach(l => { @@ -1608,7 +1621,6 @@ process.stdin.on("data", data => { }); }); process.stdin.resume(); - /* -----BEGIN PGP SIGNATURE-----