Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- process.on('uncaughtException', function(err){
- var e = '' + err;
- if(e != 'Error: Socket Closed' && e != 'Error: Connection Timed Out' && e != 'Error: socket hang up' && e != 'Error: read ECONNRESET' && e.substr(0,24) != 'Error: Negotiation Error'){
- console.log('' + err);
- }
- });
- const proxyAgent = require('proxy-agent');
- var http = require('http');
- var SocksProxyAgent = require('socks-proxy-agent');
- const request = require('request');
- const WebSocket = require('ws');
- const fs = require('fs');
- const defaultHeaders = {};
- console.log('NeyBots Made by FreeTzYT Dev By Slxsher');
- defaultHeaders["Accept-Encoding"] = "gzip, deflate";
- defaultHeaders["Accept-Language"] = "en-CA,en-GB;q=0.9,en-US;q=0.8,en;q=0.7";
- defaultHeaders["Cache-Control"] = "no-cache";
- defaultHeaders["Connection"] = "Upgrade";
- defaultHeaders["Cookie"] = "__cfduid=d557d93bdc916c9975b9a56a883e425021533342031; _ga=GA1.2.115770575.1533950899";
- defaultHeaders["Pragma"] = "no-cache";
- defaultHeaders["Sec-WebSocket-Extensions"] = "permessage-deflate; client_max_window_bits";
- defaultHeaders["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3789.0 Safari/537.36 Edg/76.0.159.0";
- let allProxyAgents = [];
- let connectedUsers = 0;
- let proxyAgents = [];
- let config = {};
- let id = Math.floor(Math.random() * 1000);
- var clientX = 0,
- clientY = 0,
- aiMode =false;
- function getProxy() {
- if (proxyAgents.length == 0) proxyAgents = allProxyAgents;
- return proxyAgents.shift();
- }
- if (fs.existsSync('./config.json')) {
- fs.readFile('./config.json', (err, data) => {
- let text = Buffer.from(data).toString();
- config = JSON.parse(text);
- getProxys();
- });
- } else {
- let _default = {};
- _default.botNames = ["NeyBots-com"];
- _default.accounts = [""];
- _default.botskin = "";
- _default.useProxyApi = true;
- _default.useAccount = false;
- _default.maxBots = 500;
- fs.writeFile('config.json', Buffer.from(JSON.stringify(_default, null, 20)), () => {});
- config = _default;
- }
- function getProxys() {
- if (config.useProxyApi) {
- request('https://www.proxy-list.download/api/v1/get?type=socks5', (err, req, body) => {
- let proxies = data.toString().replace(/\r/g, '').split('\n');
- proxies.forEach(proxy => {
- return new proxyAgent(`http://${proxy}`);
- });
- console.log(`Got ${proxies.length} proxies!`);
- });
- } else {
- fs.readFile('./proxies.txt', (err, data) => {
- let proxies = data.toString().replace(/\r/g, '').split('\n');
- proxies.forEach(proxy => {
- return new proxyAgent(`http://${proxy}`);
- });
- console.log(`Got ${proxies.length} proxies!`);
- });
- }
- }
- class Bot {
- constructor(origin, client) {
- this.client = client;
- this.pelletsMode=false;
- this.playerNodes = [];
- this.playerNodeIds = [];
- this.allNodes = [];
- this.eatingEvents = [];
- this.headers = JSON.parse(JSON.stringify(defaultHeaders));
- this.originSplit = origin.split('/')[2];
- this.nameInterval = null;
- this.name = true;
- this.proxy = getProxy();
- this.origin = origin;
- this.stopped = true;
- this.ws = true;
- this.ip = true;
- this.sId = 0;
- this.id = id;
- this.started = false;
- this.x = this.y = this.clientX = this.clientY = 0;
- this.moveTo = 'mouse';
- this.mouseInt = 0;
- global.ProtocolVersion = 20;
- global.ProtocolKey = 30411;
- var encryptionKey = createKey;
- function createKey(key) {
- key = Math.imul(key, 1540483477) >> 0;
- key = (Math.imul(key >>> 24 ^ key, 1540483477) >> 0) ^ 114296087;
- key = Math.imul(key >>> 13 ^ key, 1540483477) >> 0;
- key = key >>> 15 ^ key;
- return key;
- }
- }
- connect(ip, balz) {
- if (!balz && this.originSplit == 'balz.io') return this.balz(ip);
- this.stopped = false;
- this.ip = ip;
- this.headers.Origin = this.origin;
- this.ws = new WebSocket(this.ip, {
- headers: this.headers,
- agent: this.proxy
- });
- this.ws.binaryType = 'nodebuffer';
- this.ws.onopen = this.onopen.bind(this);
- this.ws.onmessage = this.onmessage.bind(this);
- this.ws.onerror = this.onerror.bind(this);
- this.ws.onclose = this.onclose.bind(this);
- }
- handleWorldUpdate(buf) {
- let off = 0;
- if (buf.readUInt8(off++) != 16) return false;
- let eatRecordLength = buf.readUInt16LE(off);
- off += 2;
- this.eatingEvents = [];
- for (let i = 0; i < eatRecordLength; i++) {
- this.eatingEvents.push({
- eater: buf.readUInt32LE(off),
- victim: buf.readUInt32LE(off + 4)
- });
- off += 8;
- }
- while (true) {
- let n = new Node();
- n.id = buf.readUInt32LE(off);
- off += 4;
- if (!n.id) break;
- n.x = buf.readInt16LE(off);
- off += 2;
- n.y = buf.readInt16LE(off);
- off += 2;
- n.size = buf.readInt16LE(off);
- off += 2;
- n.color = {
- r: buf.readUInt8(off++),
- g: buf.readUInt8(off++),
- b: buf.readUInt8(off++)
- };
- n.flags = buf.readUInt8(off++);
- if (n.flags & 2) off += 4;
- if (n.flags & 4) off += 8;
- if (n.flags & 8) off += 16;
- let ch = 0;
- n.name = '';
- do {
- n.name += String.fromCharCode((ch = buf.readUInt16LE(off)));
- off += 2;
- } while (ch != 0);
- if (this.allNodes.hasOwnProperty(n.id)) {
- this.allNodes[n.id] = n;
- } else {
- this.allNodes[n.id] = n;
- }
- }
- let removeQueueLength = buf.readUInt32LE(off);
- off += 4;
- for (let i = 0; i < removeQueueLength; i++) {
- let id = buf.readUInt32LE(off);
- off += 4;
- if (this.allNodes.hasOwnProperty(id)) {
- delete this.allNodes[id];
- }
- }
- return true;
- }
- collectPellets(botUserX, botUserY, byteLen) {
- let clientX = 0,
- clientY = 0,
- count = 0,
- smallestSize = 10000;
- for (let i = 0; i < this.playerNodeIds.length; i++) {
- if (this.allNodes.hasOwnProperty(this.playerNodeIds[i])) {
- let node = this.allNodes[this.playerNodeIds[i]];
- clientX += node.x;
- clientY += node.y;
- if (node.size < smallestSize) smallestSize = node.size;
- count++;
- }
- }
- clientX /= count;
- clientY /= count;
- let followNode = null;
- let bestDistance = 10000.0;
- Object.keys(this.allNodes).forEach(key => {
- let node = this.allNodes[key];
- if (node.size < smallestSize * 0.85) {
- let dist = Math.abs(node.x - clientX) + Math.abs(node.y - clientY);
- if (dist < bestDistance) {
- bestDistance = dist;
- followNode = node;
- }
- }
- });
- if (followNode) {
- let moveBuffer = Buffer.alloc(byteLen);
- moveBuffer.writeUInt8(16, 0);
- switch (byteLen) {
- case 13:
- case 9:
- moveBuffer.writeInt32LE(followNode.x, 1);
- moveBuffer.writeInt32LE(followNode.y, 5);
- break;
- case 21:
- moveBuffer.writeDoubleLE(followNode.x, 1);
- moveBuffer.writeDoubleLE(followNode.y, 9);
- break;
- case 16:
- moveBuffer.writeIntDoubleLE(followNode.x, 1) + moveBuffer.writeInDoubleLE(followNode.x, 17) / 2;
- moveBuffer.writeIntDoubleLE(followNode.y, 9) + moveBuffer.writeInDoubleLE(followNode.y, 25) / 2;
- break;
- }
- this.send(moveBuffer);
- }
- //this.sendMoveTo(clientX, clientY);
- }
- getBubbleToken(callback, proxyServer) {
- var requsetWithProxy = request.defaults({'proxy': `http://${proxyServer.proxy.host}:${proxyServer.proxy.port}`});
- var headers = {
- 'Content-Type':'text/xml'
- }
- var options = {
- url: 'http://bubble.am/m',
- method: 'POST',
- headers: headers,
- form: 'tal=1&dm=1'
- }
- requsetWithProxy.post(options, (err, res, body) => {
- if (err || res.statusCode !== 200) {
- console.log('Failed to get response');
- return;
- }
- if(!body) return;
- let token = body.split("\n")[3];
- let buffer = new Buffer.alloc(1 + token.length);
- buffer.writeUInt8(253, 0);
- buffer.write(token, 1);
- this.send(buffer);
- if (this.spawnInterval) return;
- this.spawnInterval = setInterval(function() {
- if(this.botsSpawnSig == 0){
- clearInterval(this.checkConnection);
- clearInterval(this.spawnInterval);
- } else {
- this.spawn();
- }
- }.bind(this), 1750 * 2);
- });
- }
- balz(ip) {
- let finIp = ip.split('?')[0];
- let ws = new WebSocket('wss://balz.io/gateway', {
- agent: this.proxy
- });
- ws.onclose = ws.onerror = ws.onopen = () => {};
- ws.onmessage = msg => {
- msg = JSON.parse(msg.data);
- switch (msg[0]) {
- case 0:
- this.sId = msg[1][0];
- finIp += '?session=' + msg[1][1];
- this.connect(finIp, true);
- break;
- case 1:
- ws.send('[1]');
- break;
- }
- };
- }
- onopen() {
- let inits = Buffer.alloc(5);
- inits.writeUInt8(254, 0); + global.ProtocolVersion;
- switch (this.originSplit) {
- case 'agocell.eu':
- case 'cellz.io':
- case 'www.agarserv.com/':
- case 'ultrex.io':
- case 'agario.top':
- case 'agario.us':
- case 'agariogame.club':
- case 'agar.pro':
- case 'cellagar.ml':
- case 'agar.io':
- case 'game.ex-script.com':
- case 'germs.io':
- case 'agar.lol':
- case 'mk-agario.glitch.me':
- case 'agix.pw':
- case 'Bubble.am':
- case 'germs.io':
- case 'agarios.org':
- case 'dummyclient.glitch.me':
- case 'www.agar-kicoo.tk':
- case 'ac-clan.glitch.me':
- case 'gota.io':
- case 'agar.red':
- case 'senpa.io':
- case 'agar.lol':
- case 'pok.ist':
- case 'ixagar.net':
- case 'agar.black':
- case 'agarcell.ml':
- case 'zgar.glitch.me':
- case 'cells.ga':
- case 'agar.ovh':
- case 'sxold.glitch.me':
- case 'agarx.biz' :
- case 'agario.fun':
- case 'powerline.io':
- case 'nagar.eu':
- case 'agar.bio':
- case 'gaver.io':
- case 'play.mitos.is':
- case 'agariocity.pro':
- case 'gota.io':
- case 'astr.io':
- case 'agariobox.org':
- case 'agar.gold':
- case 'ogar.be':
- case 'play.agario0.com':
- inits.writeUInt32LE(1, 1);
- break;
- case 'agarflix.com':
- case 'Bubble.am':
- case 'www.agarserv.com/':
- inits.writeUInt32LE(4, 1, true);
- break;
- case 'army.ovh':
- case 'game.ex-script.com':
- case 'gaver.io':
- case 'ixagar.net':
- case 'www.agarserv.com/':
- case 'agar.space':
- case 'Bubble.am':
- case 'senpa.io':
- case 'gota.io':
- case 'agario.us':
- case 'agariogame.club':
- case 'cellcraft.io':
- case 'www.cellcraft.io':
- case 'http://cellcraft.io':
- case 'ultrex.io':
- case 'astr.io':
- case 'www.agarserv.com/':
- case 'play.mitos.is':
- case 'http://agar.tv':
- case 'http://agar.wiki':
- case 'bomb.agar.bio':
- case 'm.agar.bio':
- case 'agar.bio':
- case 'agarz.com':
- case 'blobgame.io':
- case 'pok.ist':
- case 'agarioserver.club':
- case 'agarprivateservers.org':
- inits.writeUInt32LE(5, 1);
- break;
- case 'balz.io':
- case 'myagar.pro':
- inits.writeUInt32LE(6, 1);
- break;
- case 'senpa.io':
- let strings = [config.botNames[Math.floor(Math.random() * config.botNames.length)], '', '', '', '']; // ['onxcnk_101', Math.random().toString(36).substr(2, 5)];
- let stringsLen = 0;
- strings.map(a => stringsLen += a.length * 2);
- inits = Buffer.alloc(1 + strings.length * 2 + stringsLen);
- var i = 0;
- inits.writeUInt8(252, i++);
- strings.forEach(string => {
- inits.writeUInt16LE(string.length, i);
- i += 2;
- inits.write(string, i, 'utf16le');
- i += string.length * 2;
- });
- break;
- }
- this.send(inits);
- var t = Buffer.alloc(5);
- inits = Buffer.alloc(5); + global.Protocolkey;
- inits.writeUInt8(255, 0);
- switch (this.originSplit) {
- case 'wreckit.io':
- case 'agar.io':
- case 'agar.pro':
- case 'm.agar.bio':
- case 'agar.bio':
- case 'army.ovh':
- case 'agar.space':
- case 'cellagar.ml':
- case 'agocell.eu':
- case 'agar.one':
- case 'moomoo.io':
- case 'germs.io':
- case 'game.ex-script.com':
- case 'senpa.io':
- case 'mk-agario.glitch.me':
- case 'agix.pw':
- case 'Bubble.am':
- case 'agocell.eu':
- case 'agarios.org':
- case 'biobots.tk':
- case 'dummyclient.glitch.me':
- case 'dual-agar.me':
- case 'agario.us':
- case 'agariogame.club':
- case 'ac-clan.glitch.me':
- case 'agar.red':
- case 'agar.lol':
- case 'agar.black':
- case 'agarcell.ml':
- case 'zgar.glitch.me':
- case 'cells.ga':
- case 'www.agarserv.com/':
- case 'ultrex.io':
- case 'agar.ovh':
- case 'bomb.agar.bio':
- case 'm.agar.bio':
- case 'agar.bio':
- case 'sxold.glitch.me':
- case 'ixagar.net':
- case 'agario.fun':
- case 'powerline.io':
- case 'play.mitos.is':
- case 'nagar.eu':
- case 'agariopvp.org':
- case 'agarprivateservers.org':
- case 'www.agar-kicoo.tk':
- case 'gaver.io':
- case 'gota.io':
- case 'agariocity.pro':
- case 'agariobox.org':
- case 'agar.lol':
- case 'pok.ist':
- case 'agarflix.com':
- case 'agar.gold':
- case 'astr.io':
- case 'ogar.be':
- case 'agar.bio':
- inits.writeUInt32LE(1332175218, 1, true);
- if (config.useAccount && this.originSplit == 'agariohub.io') this.agarHubLogin();
- break;
- case 'agarioserver.club':
- case 'Bubble.am':
- case 'www.agarserv.com/':
- inits.writeUInt32LE(2200049715, 1);
- break;
- case 'bomb.agar.bio':
- case 'm.agar.bio':
- case 'Bubble.am':
- case 'www.agarserv.com/':
- case 'game.ex-script.com':
- case 'agar.bio':
- case 'play.mitos.is':
- case 'http://agario.se/':
- case 'pok.ist':
- case 'ultrex.io':
- case 'http://targ.io/':
- case 'agar.gold':
- case 'http://agar.tv':
- case 'http://agar.wiki':
- case 'agario.us':
- case 'agariogame.club':
- case 'ixagar.net':
- case 'www.agarserv.com/':
- case 'senpa.io':
- case 'http://agario.tech/':
- inits.writeUInt32LE(1, 123456789, true);
- break;
- case 'Bubble.am':
- case 'cellcraft.io':
- case 'www.cellcraft.io':
- case 'http://cellcraft.io':
- case 'www.agarserv.com/':
- case 'play.mitos.is':
- case 'game.ex-script.com':
- case 'ultrex.io':
- inits.writeUInt32LE(1332775218, 1);
- break;
- case 'myagar.pro':
- case 'balz.io':
- inits.writeUInt32LE(1, 1);
- break;
- case 'agarz.com':
- case 'bomb.agar.bio':
- case 'm.agar.bio':
- case 'agar.bio':
- case 'www.agarserv.com/':
- case 'blobgame.io':
- case 'ultrex.io':
- inits.writeUInt32LE(154669603, 1);
- break;
- case 'ixagar.net':
- let strings = [config.botNames[Math.floor(Math.random() * config.botNames.length)], '', '', '', ''];
- let stringsLen = 0;
- strings.map(a => stringsLen += a.length * 2);
- inits = Buffer.alloc(1 + strings.length * 2 + stringsLen);
- var i = 0;
- inits.writeUInt8(30, i++);
- strings.forEach(string => {
- inits.writeUInt16LE(string.length, i);
- i += 2;
- inits.write(string, i, 'utf16le');
- i += string.length * 2;
- });
- this.send(new Buffer.from([130]));
- break;
- }
- this.send(inits);
- switch (this.originSplit) {
- case 'cellcraft.io':
- case 'www.cellcraft.io':
- case 'http://cellcraft.io':
- this.send(Buffer.from([42]));
- this.send(Buffer.from([254,5,0,0,0]));
- this.send(Buffer.from([255,50,137,112,79]));
- this.send(Buffer.from([90,51,24,34,131]));
- break;
- case 'cellz.io':
- this.send(Buffer.from([254, 5, 0, 0, 0]));
- this.send(Buffer.from([255, 0, 0, 0, 0]));
- this.send(Buffer.from([5]));
- this.send(Buffer.from([32, 0]));
- this.send(Buffer.from([2,0,0,0,0,0]));
- this.send(Buffer.from([2]));
- setInterval(function() {
- this.send(Buffer.from([0,123,0,34,0,110,0,97,0,109,0,101,0,34,0,58,0,34,0,70,0,114,0,101,0,101,0,84,0,122,0,89,0,84,0,34,0,44,0,34,0,115,0,107,0,105,0,110,0,34,0,58,0,34,0,34,0,44,0,34,0,115,0,107,0,105,0,110,0,50,0,34,0,58,0,34,0,34,0,125,0]));
- }.bind(this), 1750 * 2)
- break;
- case 'us.biome3d.com':
- this.send(Buffer.from([1,0,0,0,0,0,0,0,0]));
- break;
- case 'agariobox.org':
- this.send(Buffer.from([254]));
- break;
- case 'agario.top':
- this.send(Buffer.from([19]));
- break;
- case 'agarx.biz' :
- this.send(Buffer.from([254, 1, 0, 0, 0]));
- this.send(Buffer.from([255, 114, 97, 103, 79]));
- this.send(Buffer.from([19]));
- break;
- case 'agar.lol':
- this.send(Buffer.from([254, 5, 0, 0, 0]));
- this.send(Buffer.from([255, 51, 24, 34, 131]));
- break;
- case 'gaver.io':
- this.send(Buffer.from([80]));
- break;
- case 'agarflix.com':
- this.send(Buffer.from([254,4,0,0,0]));
- this.send(Buffer.from([255,114,97,103,79]));
- this.send(Buffer.from([17]));
- // this.send(Buffer.from([192,78,0,101,0,121,0,66,0,111,0,116,0,115,0,46,0,99,0,111,0,109,0]));
- break;
- case 'agariocity.pro':
- this.send(Buffer.from([254,1,0,0,0]));
- this.send(Buffer.from([255,114,97,103,79]));
- this.send(Buffer.from([19]));
- break;
- case 'ixagar.net':
- this.send(Buffer.from([252,8,0,108,0,119,0,103,0,97,0,45,0,49,0,49,0,48,0,6,0,69,0,55,0,57,0,111,0,118,0,81,0]));
- this.send(Buffer.from([30,8,0,80,0,114,0,111,0,102,0,105,0,108,0,101,0,49,0,0,0,32,0,104,0,116,0,116,0,112,0,58,0,47,0,47,0,105,0,120,0,97,0,103,0,97,0,114,0,46,0,110,0,101,0,116,0,47,0,115,0,107,0,105,0,110,0,115,0,47,0,114,0,105,0,110,0,103,0,46,0,112,0,110,0,103,0,6,0,69,0,55,0,57,0,111,0,118,0,81,0,32,0,104,0,116,0,116,0,112,0,58,0,47,0,47,0,105,0,120,0,97,0,103,0,97,0,114,0,46,0,110,0,101,0,116,0,47,0,115,0,107,0,105,0,110,0,115,0,47,0,114,0,105,0,110,0,103,0,46,0,112,0,110,0,103,0]));
- this.send(Buffer.from([1]));
- break;
- case 'www.agar-kicoo.tk':
- this.send(Buffer.from([254, 6, 0, 0, 0]));
- this.send(Buffer.from([255, 1, 0, 0, 0]));
- this.send(Buffer.from([1]));
- this.send(Buffer.from([19]));
- this.send(Buffer.from([254]));
- break;
- case 'gota.io':
- this.send(Buffer.from([255, 6, 71, 111, 116, 97, 32, 87, 101, 98, 32, 50, 46, 52, 46, 49, 0]));
- this.send(Buffer.from([255, 1, 0, 0, 0]));
- // this.send(Buffer.from([100, 48, 51, 65, 79, 76, 84, 66, 76, 84, 66, 69, 77, 81, 116, 97, 111, 72, 49, 110, 114, 73, 122, 106, 52, 73, 102, 81, 85, 112, 122, 114, 48, 54, 80, 80, 112, 84, 75, 70, 89, 49, 76, 117, 87, 50, 56, 117, 113, 87, 116, 78, 67, 120, 52, 102, 52, 119, 66, 45, 85, 97, 120, 82, 122, 121, 53, 66, 110, 109, 102, 56, 101, 70, 50, 76, 98, 65, 76, 113, 116, 54, 54, 56, 116, 56, 83, 78, 109, 78, 111, 105, 57, 75, 113, 117, 107, 98 48 82 50 119 71 50 111 65 69 79 113 83 75 80 52 110 68 51 106 76 72 72 111 97 99 71 53 99 78 74 101 120 103 84 85 49 76 121 52 74 117 69 75 77 82 121 56 66 90 57 106 68 98 74 111 65 106 114 51 78 69 70 76 68 121 102 50 95 53 78 75 102 49 55 99 51 85 95 77 95 77 81 55 57 65 53 113 57 45 51 65 97 105 71 117 65 99 104 100 118 76 101 110 45 104 75 112 97 111 84 52 82 51 55 78 48 121 114 83 111 90 107 83 80 77 78 104 45 77 67 87 54 119 114 114 99 77 115 100 69 99 86 83 78 97 55 48 83 99 88 121 120 97 98 118 84 100 78 97 100 52 45 54 52 55 97 66 83 86 113 100 104 101 69 82 103 95 102 105 57 83 56 72 50 48 73 71 121 74 48 80 82 49 88 56 99 104 51 48 73 121 88 117 111 81 97 52 112 52 116 89 45 56 99 120 99 48 95 121 55 87 75 84 79 78 117 118 68 72 88 68 97 108 90 80 77 67 0]));
- // this.send(Buffer.from([19]));
- this.send(Buffer.from([71]));
- break;
- case 'biobots.tk':
- this.send(Buffer.from([19]));
- break;
- case 'play.mitos.is':
- this.send(Buffer.from([0,0,0,4,0,0,0,4,64,0,0,0,0]));
- this.send(Buffer.from([0,0,0,20,0,0,0,19,48,39,163,162,165,132,112,203,217,216,227,251,23,40,66,114,7,171,225,229,8]));
- // this.send(Buffer.from([254]));
- break;
- case 'agario.fun':
- this.send(Buffer.from([19]));
- break;
- case 'agar.pro':
- this.send(Buffer.from([254, 5, 0, 0, 0]));
- this.send(Buffer.from([255, 1, 0, 0, 0]));
- this.send(Buffer.from([19]));
- break;
- case 'myagar.pro':
- this.send(Buffer.from([254, 6, 0, 0, 0]));
- this.send(Buffer.from([255, 0, 0, 0, 0]));
- // this.send(Buffer.from([88,168,203,203,72,168,203,203,72,168,203,203,72]));
- setInterval(() => {
- this.send(Buffer.from([254]));
- }, 500);
- break;
- case 'germs.io':
- this.send(Buffer.from([255]));
- this.send(Buffer.from([123]));
- break
- case 'ogar.be':
- this.send(Buffer.from([254,1,0,0,0]));
- this.send(Buffer.from([255,114,97,103,79]));
- this.send(Buffer.from([19]));
- break;
- case 'agar.red':
- this.send(Buffer.from([254,6,0,0,0]));
- this.send(Buffer.from([255,1,0,0,0]));
- this.send(Buffer.from([99,0,115,0]));
- setInterval(() => {
- this.send(Buffer.from([254]));
- }, 500);
- break;
- case 'powerline.io':
- this.send(Buffer.from([191, 160, 0, 78, 0]));
- this.send(Buffer.from([0]));
- this.send(Buffer.from([7, 94, 0, 78, 0]));
- setInterval(function() {
- this.send(Buffer.from([3, 78, 0, 101, 0, 121, 0, 66, 0, 111, 0, 116, 0, 115, 0, 45, 0, 99, 0, 111, 0, 109, 0, 0, 0]));
- this.send(Buffer.from([12, Math.floor(Math.random() *9)]));
- }.bind(this), 1750 * 2)
- break;
- case 'agar.black':
- this.send(Buffer.from([19]));
- case 'mk-agario.glitch.me':
- case 'dummyclient.glitch.me':
- case 'ac-clan.glitch.me':
- case 'dummyclient.glitch.me':
- case 'ac-clan.glitch.me':
- case 'agarcell.ml':
- case 'sxold.glitch.me':
- this.send(Buffer.from([254, 6, 0, 0, 0]));
- this.send(Buffer.from([255, 1, 0, 0, 0]));
- break;
- case 'game.ex-script.com':
- this.send(Buffer.from([254,19,0,0,0]));
- this.send(Buffer.from([255,114,5,1,4]));
- setInterval(() => {
- this.send(Buffer.from([254]));
- }, 500);
- break;
- case 'cells.ga':
- this.send(Buffer.from([254, 5, 0, 0, 0]));
- this.send(Buffer.from([255, 114, 97, 103, 79]));
- this.send(Buffer.from([19]));
- case 'agariopvp.org':
- this.send(Buffer.from([254, 1, 0, 0, 0]));
- this.send(Buffer.from([255, 114, 97, 103, 79]));
- this.send(Buffer.from([19]));
- break;
- case 'bomb.agar.bio':
- this.send(Buffer.from([254, 1, 0, 0, 0]));
- this.send(Buffer.from([255 ,114 ,97 ,103 ,79]));
- this.send(Buffer.from([19]));
- break;
- case 'nagar.eu':
- // this.send(Buffer.from([254, 6, 0, 0, 0]));
- // this.send(Buffer.from([255, 1, 0, 0, 0]));
- setInterval(() => {
- this.send(Buffer.from([254]));
- }, 500);
- break;
- case 'agar.gold':
- this.send(Buffer.from([254, 5, 0, 0, 0]));
- this.send(Buffer.from([255 ,35 ,18 ,56 ,9]));
- this.send(Buffer.from([90 ,176 ,33 ,231 ,85]));
- this.send(Buffer.from([0, 78 ,0 ,101 ,0 ,121 ,0 ,66 ,0 ,111 ,0 ,116 ,0 ,115 ,0 ,46 ,0 ,99 ,0 ,111 ,0 ,109 ,0 ,42 ,0 ,50 ,0 ,53 ,0 ,52 ,0]));
- this.send(Buffer.from([19]));
- this.send(Buffer.from([1]));
- break;
- case 'pok.ist':
- this.send(Buffer.from([254,4,0,0,0]));
- this.send(Buffer.from([255,114,97,103,79]));
- break;
- case 'www.agar-kicoo.tk':
- this.send(Buffer.from([254, 6, 0, 0, 0]));
- // this.send(Buffer.from([123,103,114,101,97,116,95,122,105,108,108,97,125,78,101,121,66,111,116,115,45,99,111,109,0]));
- this.send(Buffer.from([255, 1, 0, 0, 0]));
- setInterval(() => {
- this.send(Buffer.from([254]));
- }, 500);
- break;
- case 'army.ovh':
- setInterval(() => {
- this.send(Buffer.from([254]));
- }, 500);
- break;
- case 'agarioserver.club':
- this.send(Buffer.from([254,5,0,0,0]));
- this.send(Buffer.from([255,51,24,34,131]));
- // this.send(Buffer.from([80]));
- // this.send(Buffer.from([19]));
- break;
- case 'agix.pw':
- this.send(Buffer.from([0, 100, 0, 117, 0, 109, 0, 109, 0, 121, 0, 98, 0, 111, 0, 116, 0, 115, 0, 46, 0, 110, 0, 101, 0, 116, 0]));
- break;
- case 'www.agarserv.com/':
- this.send(Buffer.from([254, 1, 0, 0, 0]));
- this.send(Buffer.from([255,114,97,103,79]));
- break;
- case 'Bubble.am':
- this.send(Buffer.from([255,51,24,146,131]));
- this.send(Buffer.from([254,4,0,0,0]));
- this.send(Buffer.from([253,55,100,49,54,57,50,100,49,98,57,56,49,57,57,101,102,99,100,53,52,52,53,57,55,53,52,55,49,57,55,57,55,56,98,102,51,49,100,53,50]));
- break;
- case 'gaver.io':
- this.send(Buffer.from([254, 5, 0, 0, 0]));
- this.send(Buffer.from([255, 35, 18, 56, 9]));
- this.send(Buffer.from([19]));
- break;
- case 'agar.io':
- this.send(Buffer.from([254, 20, 0, 0, 0]));
- this.send(Buffer.from([255, 203, 118, 0, 0]));
- this.send(Buffer.from([409])); //encrypted spawn
- console.log(40);
- break;
- case 'agarprivateservers.org':
- this.send(Buffer.from([19]));
- break;
- case 'ultrex.io':
- this.send(Buffer.from([254,6,0,0,0]));
- this.send(Buffer.from([145,110,111,116,97,98,111,116,0]));
- this.send(Buffer.from([146,116,114,117,101,0]));
- this.send(Buffer.from([255,1,0,0,0]));
- this.send(Buffer.from([0,60,110,111,110,101,62,102,114,101,101,116,122,121,116,42,33,42,0]));
- setInterval(() => {
- this.send(Buffer.from([254]));
- }, 500);
- break;
- case 'balz.io':
- // this.send(Buffer.from([255,1,0,0,0]));
- // this.send(Buffer.from([254,6,0,0,0]));
- this.send(Buffer.from([0,0,0,0,3,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,1,0,7,0,0,5,0,0,0,0,0,0,0,0]));
- this.send(Buffer.from([0,2,0,0,0]));
- this.send(Buffer.from([0,6,0,0,0,0,0,0,0]));
- this.send(Buffer.from([0,1,0]));
- setInterval(() => {
- this.send(Buffer.from([254]));
- }, 500);
- break;
- }
- this.spawn();
- this.nameInterval = setInterval(() => {
- //console.log('Spawned');
- // this.sendChat('-');
- this.spawn();
- }, 1000);
- }
- agarHubLogin() {
- let account = config.accounts[Math.floor(Math.random() * config.accounts.length)];
- let loginBuffer = Buffer.alloc(1 + Buffer.byteLength(account, 'utf16le'));
- loginBuffer.writeUInt8(30, 0);
- loginBuffer.write(account, 1, 'utf16le');
- this.send(loginBuffer);
- }
- nameBypass() {
- function _0x67e0x24(_0x67e0x3) {
- for (var _0x67e0x4 = _0x67e0x3; _0x67e0x4 >= 36;) {
- _0x67e0x4 = ~~(_0x67e0x4 / 36) + _0x67e0x4 % 36
- };
- return _0x67e0x4.toString(36)
- }
- var _0x67e0x3 = Math.round(Date.now() / 1e3) % 1e3,
- _0x67e0x4 = 1e3 * (1e3 * (100 + Math.floor(900 * Math.random())) + _0x67e0x3) + (100 + Math.floor(900 * Math.random()));
- return _0x67e0x24(_0x67e0x4) + _0x67e0x4.toString(36) + function (_0x67e0x3) {
- var _0x67e0x4 = 1 / _0x67e0x3;
- for (; _0x67e0x4 < 100;) {
- _0x67e0x4 *= 19
- };
- return _0x67e0x24(~~_0x67e0x4)
- }(_0x67e0x4)
- }
- spawn() {
- let inits = Buffer.alloc(5);
- inits.writeUInt8(254, 0);
- let name = config.botNames[Math.floor(Math.random() * config.botNames.length)];
- let spawnBuffer = null;
- switch (this.originSplit) {
- case 'agar.bio':
- case 'bomb.agar.bio':
- case 'm.agar.bio':
- name = name + id;
- spawnBuffer = Buffer.alloc(1 + Buffer.byteLength(name, 'ucs2'));
- spawnBuffer.write(name, 1, 'ucs2');
- break;
- case 'agar.bio':
- name = this.nameBypass() + '&' + name;
- case 'agar.pro':
- case 'dual-agar.me':
- case 'cellagar.ml':
- name = name + id;
- case 'agario.top':
- name = name + id;
- case 'gaver.io':
- case 'gota.io':
- name = name + Math.floor(Math.random() * 1000);
- // spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- // spawnBuffer.write(name, 3, 'utf16le');
- spawnBuffer = Buffer.alloc(3 * Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.write(name, 1, 'utf16le');
- break;
- case 'ogar.be':
- case 'www.agarserv.com/':
- case 'game.ex-script.com':
- case 'Bubble.am':
- name = name + Math.floor(Math.random() * 1000);
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.write(name, 1, 'utf16le');
- break;
- case 'agario.fun':
- case 'agar.lol' :
- case 'ogar.be':
- case 'play.agario0.com':
- case 'ultrex.io':
- case 'agarioserver.club':
- name = name + Math.floor(Math.random() * 1000);
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.write(name, 1, 'utf16le');
- break;
- case 'sxold.glitch.me':
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.write(name, 5, 'utf16le');
- break;
- case 'blobgame.io':
- // name = name;
- // spawnBuffer = Buffer.alloc(1 + Buffer.byteLength(name, 'utf16le'));
- // spawnBuffer.write(name, 1, 'utf16le');
- var skins = ['fly', 'fish', 'amber', 'spider', 'small_chick', 'carp', 'lobster', 'wasp', 'gopher', 'chick', 'sea_turtle', 'octopus', 'lizard', 'rabbit', 'pug', 'mouse', 'birdie', 'bat', 'owl', 'squirrel', 'rooster', 'cat', 'snake', 'crow', 'parrot', 'prey', 'chihuahua', 'fox', 'desert_fox', 'pig', 'dog', 'blackcat', 'coyote', 'goat', 'deer', 'bullking', 'seal', 'fury_cat', 'penguin', 'blueswirl', 'sly', 'husky', 'sheep', 'panda', 'cute_panda', 'angry_panda', 'bear', 'bear_', 'bearr', 'rhino_boxer', 'cougar', 'wolf', 'wolff', 'spirxo', 'sabertooth', 'panther', 'kempo_tiger', 'dark_wings', 'firebird', 'wolf_', 'lion_', 'yeti', 'lion', 'leo', 'king_lion', 'crocodile', 'croc', 'jackal', 'taurus', 'shark', 'colossus', 'orc_grunt', 'behemoth', 'mammoth', 'silver_tusk', 'dragon', 'beast', 'raptor', 't_rex', 'godzilla', 'basilisk', 'sentinel', 'poseidon', 'kraken', 'red_fiend', 'wendigo', 'jotun', 'ice_lord', 'medusa', 'reaper'];
- var skin = skins[~~(Math.random() * skins.length)];
- var rand = Math.random().toString(36).slice(2 + ~~(Math.random() * 6)); // temporary
- name = `<${skin}>${rand}`;
- spawnBuffer = Buffer.alloc(1 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.write(name, 1, 'utf16le');
- // this.send(spawnBuffer);
- spawnBuffer = Buffer.alloc(1);
- spawnBuffer.writeUInt8(1, 0);
- // this.send(spawnBuffer);
- break;
- case 'agariobox.org':
- name = name + id;
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.write(name, 1, 'utf16le');
- break;
- case 'agarx.biz' :
- name = name + id;
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf8'));
- spawnBuffer.write(name, 3, 'utf8');
- break;
- case 'army.ovh':
- name = name + Math.floor(Math.random() * 1000);
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- // spawnBuffer.writeUInt16LE(59, 1);
- spawnBuffer.write(name, 3, 'utf16le');
- break;
- case 'www.agar-kicoo.tk':
- name = name + id;
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.writeUInt16LE(59, 1);
- spawnBuffer.write(name, 3, 'utf16le');
- break;
- case 'germs.io':
- name = name + Math.floor(Math.random() * 1000);
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'ucs2'));
- spawnBuffer.write(name, 1, 'ucs2');
- break
- case 'cells.ga':
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.write(name, 5, 'utf16le');
- break;
- case 'agar.ovh':
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf8le'));
- spawnBuffer.write(name, 1, 'utf8le');
- break;
- case 'agar.io':
- name = name + id;
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf8'));
- spawnBuffer.write(name, 3, 'utf8');
- break;
- case 'agarprivateservers.org':
- name = this.nameBypass() + '&' + name + id;
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf8'));
- spawnBuffer.write(name, 3, 'utf8');
- break;
- case 'dummyclient.glitch.me':
- case 'agario.us':
- case 'agariogame.club':
- name = name + Math.floor(Math.random() * 1000);
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.write(name, 1, 'utf16le');
- break;
- case 'agarflix.com':
- name = name + Math.floor(Math.random() * 1000);
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.writeUInt16LE(192, 0);
- spawnBuffer.write(name, 1, 'utf16le');
- break;
- case 'www.agar-kicoo.tk':
- case 'agariopvp.org':
- name = this.nameBypass() + '&' + name + id;
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.writeUInt16LE(59, 1);
- spawnBuffer.write(name, 3, 'utf16le');
- break;
- case 'pok.ist':
- name = name + id;
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.writeUInt16LE(192, 0);
- spawnBuffer.write(name, 1, 'utf16le');
- break;
- case 'ac-clan.glitch.me':
- name = name + id;
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.writeUInt16LE(59, 1);
- spawnBuffer.write(name, 3, 'utf16le');
- break;
- case 'biobots.tk':
- name = name + id;
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.writeUInt16LE(59, 1);
- spawnBuffer.write(name, 3, 'utf16le');
- break;
- case 'cellcraft.io':
- case 'www.cellcraft.io':
- case 'http://cellcraft.io':
- name = name + id;
- spawnBuffer = new Buffer.alloc(3 + 2 * name.length);
- spawnBuffer.writeUInt8(0, 0);
- spawnBuffer.writeUInt16LE(59, 1);
- for(let i = 0; i < name.length; i++)
- spawnBuffer.writeUInt16LE(name.charCodeAt(i), 3 + 2 * i);
- this.send(new Uint8Array([29]));
- this.send(new Uint8Array([42]));
- this.send(spawnBuffer);
- break;
- case 'germs.io':
- name = name + id;
- var buffer = new Buffer(1 + 2 * name.length);
- // buffer.writeUInt8(123, 0);
- buffer.writeUInt16LE(123, 0);
- for (let i = 0; i < name.length; i++)
- buffer.writeUInt16LE(name.charCodeAt(i), 1 + 2 * i);
- this.send(buffer);
- break;
- case 'targ.io':
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.write(name, 3, 'utf16le');
- break;
- case 'agarcell.ml':
- name = name + id;
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.write(name, 3, 'utf16le');
- break;
- case 'agar.red':
- name = name + id;
- var buffer = new Buffer.alloc(1 + 2 * name.length);
- buffer.writeUInt8(0, 0);
- buffer.writeUInt16LE(59, 1);
- for (let i = 0; i < name.length; i++)
- buffer.writeUInt16LE(name.charCodeAt(i), 1 + 2 * i);
- this.send(buffer);
- break;
- case 'mk-agario.glitch.me':
- name = name + Math.floor(Math.random() * 1000);
- spawnBuffer = Buffer.alloc(1 + Buffer.byteLength(name, 'ucs2'));
- spawnBuffer.write(name, 1, 'ucs2');
- break;
- case 'agariocity.pro':
- case 'ixagar.net':
- name = name + Math.floor(Math.random() * 1000);
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.writeUInt16LE(59, 1);
- spawnBuffer.write(name, 3, 'utf16le');
- break;
- case 'nagar.eu':
- case 'play.mitos.is':
- name = name + Math.floor(Math.random() * 1000);
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.write(name, 1, 'utf16le');
- break;
- case 'agar.black':
- name = name + id;
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.writeUInt16LE(59, 1);
- spawnBuffer.write(name, 3, 'utf16le');
- break;
- case 'agar.tv':
- name = name + Math.floor(Math.random() * 1000);
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.writeUInt16LE(192, 0);
- spawnBuffer.write(name, 1, 'utf16le');
- break;
- case 'agar.wiki':
- name = name + Math.floor(Math.random() * 1000);
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.writeUInt16LE(192, 0);
- spawnBuffer.write(name, 1, 'utf16le');
- break;
- case 'agix.pw':
- spawnBuffer = Buffer.alloc(3 + Buffer.byteLength(name, 'utf16le'));
- spawnBuffer.writeUInt16LE(59, 1);
- spawnBuffer.write(name, 3, 'utf16le');
- break;
- case 'agar.one':
- name = this.nameBypass() + '&' + name + '&' + id;
- spawnBuffer = Buffer.alloc(1 + Buffer.byteLength(name));
- spawnBuffer.write(name, 1);
- break;
- case 'balz.io':
- case 'myagar.pro':
- name = name + Math.floor(Math.random() * 1000);
- spawnBuffer = Buffer.alloc(1 + Buffer.byteLength(name, 'utf8'));
- spawnBuffer.write(name, 1, 'utf8');
- break;
- }
- this.send(spawnBuffer);
- }
- sendChat(message) {
- let chatBuffer;
- switch (this.originSplit) {
- case 'agar.red':
- case 'ixagar.net':
- case 'game.ex-script.com':
- case 'cellcraft.io':
- case 'www.cellcraft.io':
- case 'http://cellcraft.io':
- case 'agar.pro':
- case 'agar.bio':
- case 'bomb.agar.bio':
- case 'cellz.io':
- case 'army.ovh':
- case 'play.agario0.com':
- case 'agario.top':
- case 'ogar.be':
- case 'agariocity.pro':
- case 'agar.pro':
- case 'myagar.pro':
- case 'cellagar.ml':
- case 'zgar.glitch.me':
- case 'germs.io':
- case 'mk-agario.glitch.me':
- case 'agar.one':
- case 'agocell.eu':
- case 'agix.pw':
- case 'ac-clan.glitch.me':
- case 'dummyclient.glitch.me':
- case 'agar.black':
- case 'senpa.io':
- case 'nagar.eu':
- case 'gaver.io':
- case 'blobgame.io':
- case 'gota.io':
- case 'agariobox.org':
- chatBuffer = Buffer.alloc(2 + message.length * 2);
- chatBuffer.writeUInt8(99, 0);
- chatBuffer.write(message, 2, 'utf16le');
- break;
- case 'balz.io':
- case 'targ.io':
- case 'blobgame.io':
- case 'senpa.io':
- case 'game.ex-script.com':
- case 'ixagar.net':
- case 'mk-agario.glitch.me':
- case 'zgar.glitch.me':
- case 'gaver.io':
- chatBuffer = Buffer.alloc(3 + message.length);
- chatBuffer.writeUInt8(99, 0);
- chatBuffer.write(message, 2);
- break;
- }
- this.send(chatBuffer);
- }
- onmessage(msg) { //not needed at the moment
- msg = msg.data;
- let opcode = msg.readUInt8(0);
- switch (opcode) {
- case 16:
- try {
- this.handleWorldUpdate(msg);
- } catch (e) {}
- break;
- case 32:
- this.playerNodeIds.push(msg.readUInt32LE(1));
- break;
- }
- }
- onclose(error) {
- clearInterval(this.nameInterval);
- if (this.stopped) return;
- this.proxy = getProxy();
- if (this.ip)
- this.connect(this.ip);
- }
- onerror(error) {}
- /* send(buffer) {
- if (this.ws && this.ws.readyState == 1)
- this.ws.send(buffer);
- }*/
- send(buffer) {
- if (!this.ws || this.ws.readyState !== WebSocket.OPEN == 1) return;
- if(this.started == true) return;
- if(this.origin == "http://bubble.am") this.ws.send(buffer);
- else this.ws.send(buffer);
- // console.log(buffer);
- }
- }
- class Node {
- constructor() {
- this.x = 0;
- this.y = 0;
- this.size = 0;
- this.id = 0;
- this.color = null;
- this.flags = 0;
- this.name = null;
- }
- }
- class Client {
- constructor(ws, req) {
- this.origin = req.headers.origin;
- this.botConnectInt = [];
- this.started = false;
- this.bots = [];
- this.pelletsMode = false;
- this.ws = ws;
- this.setup();
- connectedUsers++;
- console.log(`A user has connected! Connected users: ${connectedUsers}`);
- }
- setup() {
- this.ws.on('message', this.onmessage.bind(this));
- this.ws.on('close', this.onclose.bind(this));
- this.ws.on('error', this.onerror.bind(this));
- for (let i = 0; i < config.maxBots; i++)
- this.bots.push(new Bot(this.origin, this));
- this.startBotCount();
- }
- onmessage(message) {
- const json = JSON.parse(message);
- switch (json.type) {
- case 'start':
- this.startBots(json.ip, this.origin);
- console.log('user started bots on ', this.origin, json.ip)
- break;
- case 'updatePos':
- if(this.bots[0].pelletsMode) {
- for(let i = 0; i < this.bots.length; i++) this.bots[i].collectPellets(json.x, json.y, json.byteLen);
- break;
- }
- this.sendBotPos(json.x, json.y, json.byteLen);
- break;
- case 'split':
- this.bots.forEach(bot => {
- bot.send(Buffer.from([17]));
- });
- break;
- case 'pellets':
- this.pelletsMode = !this.pelletsMode;
- for(let i = 0; i < this.bots.length; i++) {
- if(this.pelletsMode) this.bots[i].pelletsMode = true;
- else this.bots[i].pelletsMode = false;
- }
- break;
- case 'chat':
- this.bots.forEach(bot => {
- bot.sendChat(json.msg);
- });
- break;
- case 'eject':
- this.bots.forEach(bot => {
- bot.send(Buffer.from([21]));
- bot.send(Buffer.from([36]));
- });
- break;
- }
- }
- sendMitosis() {
- let buffer = new Buffer(1);
- buffer.writeUInt8(17, 0);
- this.send(buffer);
- }
- sendBotPos(x, y, byteLen) {
- if (!byteLen) return;
- let moveBuffer = Buffer.alloc(byteLen);
- moveBuffer.writeUInt8(16, 0);
- switch (byteLen) {
- case 13:
- case 9:
- moveBuffer.writeInt32LE(x, 1);
- moveBuffer.writeInt32LE(y, 5);
- break;
- case 21:
- moveBuffer.writeDoubleLE(x, 1);
- moveBuffer.writeDoubleLE(y, 9);
- break;
- case 16:
- moveBuffer.writeIntDoubleLE(x, 1) + moveBuffer.writeInDoubleLE(x, 17) / 2;
- moveBuffer.writeIntDoubleLE(y, 9) + moveBuffer.writeInDoubleLE(y, 25) / 2;
- break;
- case 89:
- {
- /*this.botName = this.botName;
- this.buffers.sInit = new Buffer(5 + 2 * this.botName.length);
- var trans = message.readUInt32LE(1);
- var r20 = Math.sqrt(trans - 347712);
- this.buffers.sInit.writeUInt8(28, 0);
- this.buffers.sInit.writeUInt32LE(r20, 1);
- for (var n = 0; n < this.botName.length; n++) {
- this.buffers.sInit.writeUInt16LE(this.botName.charCodeAt(n), 5 + 2 * n, true);
- }
- this.ws.send(this.buffers.Init.Init_3);
- this.ws.send(this.buffers.Init.Init_4);
- this.ws.send(this.buffers.sInit);
- this.sendchat("I ROBOT I WORK!!!" + Math.random());
- console.log("new spawn buffer detect", r20, trans, new Uint8Array(this.buffers.sInit));*/
- }
- break;
- }
- this.bots.forEach(bot => {
- bot.send(moveBuffer);
- });
- }
- startBotCount() {
- this.botCountInt = setInterval(() => {
- let json = {
- type: 'botCount',
- connected: 0,
- maxBots: config.maxBots
- };
- this.bots.forEach(bot => {
- if (bot.ws && bot.ws.readyState == 1)
- json.connected++;
- });
- this.send(json);
- }, 100);
- }
- stopBotCount() {
- clearInterval(this.botCountInt);
- }
- onclose() {
- this.stopBotCount();
- connectedUsers--;
- console.log(`A user has disconnected! Connected users: ${connectedUsers}`);
- }
- startBots(serverip) {
- if (this.started) return;
- this.bots.forEach((bot, i) => {
- this.botConnectInt.push(setTimeout(() => {
- if (!this.started) return;
- bot.connect(serverip.replace('https', 'wss'));
- // console.log(serverip);
- }, 70* i));
- });
- this.started = true;
- }
- onerror() {}
- send(message) {
- if (this.ws && this.ws.readyState == 1) this.ws.send(JSON.stringify(message));
- }
- }
- /*const wss = new WebSocket.Server({
- port: 8080
- });
- wss.on('connection', (ws, req) => {
- ws.Client = new Client(ws, req);
- });*/
- var useSSL = false;
- if (useSSL) {
- var https = require('https');
- var app = https.createServer({
- key: fs.readFileSync('/root/key.pem'),
- cert: fs.readFileSync('/root/cert.pem')
- }).listen(8443);
- const wss = new WebSocket.Server({ server: app });
- wss.on('connection', (ws, req) => {
- ws.Client = new Client(ws, req);
- });
- } else {
- const wss = new WebSocket.Server({ port: 8081 });
- var clients = [];
- wss.on('connection', (ws, req) => {
- ws.Client = new Client(ws, req);
- });
- wss.on('connection', function connection(ws) {
- ws.on('message', function incoming(message) {
- let opcode = message.readUInt8;
- // console.log(message);
- let off = 1;
- switch (opcode) {
- case 0x10:
- clientX = message.readDoubleLE(1);
- clientY = message.readDoubleLE(9);
- break;
- case 0x20:
- for (let i = 0; i < clients.length; i++) {
- clients[i].sendMitosis();
- }
- break;
- case 0x21:
- for (let i = 0; i < clients.length; i++) {
- clients[i].sendEject();
- }
- break;
- case 0x22:
- aiMode = !aiMode;
- break;
- case 0xff:
- if (clients.length > 0) {
- break;
- }
- let ip = '',
- ch = 0;
- let amount = 0;
- amount = Math.min(message.readUInt16LE(off), 500);
- off += 2;
- while (true) {
- ch = message.readUInt16LE(off);
- off += 2;
- if (!ch) break;
- ip += String.fromCharCode(ch);
- }
- console.log(ip, amount);
- for (let i = 0; i < amount; i++) {
- let c = new Client();
- c.connect(ip);
- clients.push(c);
- }
- break;
- case 0xfe:
- clients = [];
- break;
- }
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement