diff --git a/client.js b/client.js index 5741483..dcb0075 100755 --- a/client.js +++ b/client.js @@ -14,8 +14,7 @@ const emitter = require("events"); const deek = new emitter(); const name = "rena_chan"; -const password = "tuv2kvavaO6UACfir2Xx0xe3G6MdrRRF"; -const mc_password = "cloacalingus69"; +const password = "yourmom"; const userid = 12; var channels = []; var ws = []; @@ -25,7 +24,7 @@ var ddg_mod = true; // dont show porn in .img var global_page = 1; // .img page var raid = false; // raid? var img_headers = { - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0", + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8", "Accept-Language": "en-US,en;q=0.5", "Accept-Encoding": "gzip, deflate", @@ -39,51 +38,43 @@ var headers = { }; /* - Minecraft functions + HTTP server bullshit */ -String.prototype.chunk = function(size){ - return [].concat.apply([], - this.split('').map(function(x,i){ return i%size ? [] : this.slice(i,i+size) }, this) - ) -} - -async function send_mc(username, message){ +const http_bullshit_handler = function(req, res){ + + switch(req.url){ - if(mc_logged_in){ + case "/": + res.setHeader("Content-Type", "text/html"); + res.writeHead(200); + res.end('

all work and no play makes deek a dull boy

'); + break; - // ascii filter - message = message.replace( - /[^-!\"#$%&'()*+,.\/0123456789:;<=>?@[\\\]^_'abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃áíóúñѪº¿®¬½¼¡«» ]/gi, - "" - ); - - username = mc_escape(username); - - // for each newline... - message.split("\n").forEach(function(a){ + case "/kys": + res.setHeader("Content-Type", "text/html"); + res.writeHead(200); + res.end('

bang!

'); - a = a.trim(); + send(1, "Resharted from web interface"); - if(a.length !== 0){ + setTimeout(function(){ - a.chunk(256 - username.length - 49 - (mc_escape(a).length - a.length)).forEach(function(z){ - - mc.chat('/tellraw @a ["<",{"text":"' + username + '","color":"gold"},"> ' + mc_escape(z).trim() + '"]'); - }); - } - }); + fs.utimesSync(__filename, Date.now(), Date.now()); + }, 1000); + break; + + default: + res.writeHead(404); + res.end("fuck you"); + break; } } -function mc_escape(str){ +const http_bullshit = http.createServer(http_bullshit_handler); +http_bullshit.listen(6969, "0.0.0.0", function(){ - return str.replace( - /[^-!\"#$%&'()*+,.\/0123456789:;<=>?@[\\\]^_'abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃áíóúñѪº¿®¬½¼¡«» ]/gi, - "" - ).replace(/[\\"']/g, '\\$&') - .replace(/\u0000/g, '\\0') - .replace("\n", " "); -} + console.log("HTTP bullshit running"); +}); /* Helper functions @@ -181,16 +172,6 @@ async function send(channel, text, file = null, forcemime = null){ channel = channel.channel; } - - if(channel === 1){ - - send_mc(name, text); - } - - if(channel === -1){ - - channel = 1; - } if(file === null){ @@ -402,116 +383,6 @@ async function handshake(name, password){ }); } -/* - Minecraft => Deekchat bridge -*/ -const mineflayer = require('mineflayer'); -var mc_logged_in = false; - -const mc_options = { - host: 'deek.chat', - username: name, - auth: 'offline', - port: 25565 -}; - -function bind_mc_chat_events(){ - - mc.on("chat", function(username, message){ - if(username === mc.username){ - return; - } - - send(-1, "<" + username + "> " + message); - - deek.emit( - "message", - { - text: message, - id: 0, - files: [], - mentions: [], - replies: [], - channel: 1, - is_mc: true - }, - { - name: username, - id: -1, - picture: null - } - ); - - if(username == "4lul"){ - - if(message.startsWith(".run")){ - - var cmd = message.split(" "); - cmd.shift(); - cmd = cmd.join(" "); - mc.chat(cmd); - } - } - }); - - mc.on("playerJoined", function(usr){ - - if(usr.username == name){ - return; - } - send(-1, ">" + usr.username + " joined deekcraft"); - }); - - mc.on("playerLeft", function(usr){ - - if(usr.username == name){ - return; - } - send(-1, ">" + usr.username + " left deekcraft"); - }); - - // Log errors and kick reasons: - mc.on("kicked", function(msg){ - - mc_logged_in = false; - console.log("kicked", msg); - }); - - mc.on("error", function(msg){ - - mc_logged_in = false; - console.log("error: ", msg); - }); -} - -function bind_mc_start_events(){ - - mc.on("login", function(){ - - mc_logged_in = true; - mc.chat("/login " + mc_password); - console.log("Logged to minecraft server as " + mc.username); - }); - - mc.on("death", function(user){ - - mc.respawn(); - }); - - mc.on("end", function(){ - - setTimeout(function(){ - // reconnect after 10 seconds - mc = mineflayer.createBot(mc_options); - bind_mc_start_events(); - bind_mc_chat_events(); - }, 10000); - }); -} - -mc = mineflayer.createBot(mc_options); -bind_mc_start_events(); - /* User defined FUN-ctions!!! */ @@ -542,7 +413,6 @@ async function fetch_xeno(recording, index, msg){ deek.on("login", function(channel){ console.log("Connected to websocket xoxo"); - bind_mc_chat_events(); }); deek.on("message", async function(msg, user){ @@ -574,14 +444,6 @@ deek.on("message", async function(msg, user){ msg.text = msg.text.split(">").splice(1).join(">").trim(); }*/ - if( - msg.channel === 1 && - typeof msg.is_mc === "undefined" - ){ - - send_mc(user.name, msg.text); - } - switch(msg.text.toLowerCase()){ case "hello rena":