commit dd48c9bc50d70e5d4116cc8163fe175becc7639b Author: lolcat Date: Sat Jul 22 14:48:38 2023 -0400 done diff --git a/README.md b/README.md new file mode 100644 index 0000000..d96fab7 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# Rena Client +This is a CLI client for Deekchat. It looks super cool. + +## Why +nokiaposting. + +## Singular piece of shit screenshot +![screenshot](screenshot.png) + +## Installation +```sh +# install nodejs and npm too lazy to type it out here its 2am +# once you got this piece of junk installed run that thing +git clone https://git.lolcat.ca/lolcat/rena_client +npm install neo-blessed ws node-fetch@v2 form-data he + +# to run just use +node client.js + +# ok good night xoxo +``` diff --git a/client.js b/client.js new file mode 100644 index 0000000..d93cf92 --- /dev/null +++ b/client.js @@ -0,0 +1,674 @@ +const blessed = require("neo-blessed"); + +var screen = + blessed.screen({ + smartCSR: true + }); + +screen.key(['escape', 'C-c'], function(ch, key) { + return process.exit(0); +}); + +var screen_msg = + blessed.message({ + parent:screen, + top:'center', + left:'center', + height:'shrink', + width:'shrink', + align:'center', + tags:true, + hidden:true, + border:'line' + }); + +const fs = require("fs"); + +// Read config +var config_file = fs.readFileSync("./settings.conf", "utf8"); + +config_file = config_file.split("\n"); +config = {}; + +for(i=0; i/g, + "{light-gray-fg}:$1:{/light-gray-fg}" + ) + .replace( + /<[^>]+>/ig, + "" + ) + ); + + return html; +} + +/* + Websocket functions +*/ +async function send(channel, text){ + + if(typeof channel == "object"){ + + channel = channel.channel; + } + + for(var i=0; i{/red-fg}{/bold} " + + msg.text.trim() + .replace( + /^>[^>].*/gm, + function(match){ + return "{light-green-fg}" + match + "{/light-green-fg}" + } + ) + .replace( + /^<[^<].*/gm, + function(match){ + return "{light-red-fg}" + match + "{/light-red-fg}" + } + ) + + filetext + ); + + if(render){ + messagelist.setScrollPerc(100); + screen.render(); + } +} + +deek.on("login", function(channel){ + + messagelist = + blessed.box({ + parent:screen, + label:'{bold}{cyan-fg}#' + channel.name + '{/cyan-fg}{/bold}', + tags:true, + border:'line', + width:"100%", + top:0, + left:0, + bottom:1, + scrollable:true, + scrollbar:{ + ch:'', + track:{ + bg:'cyan' + }, + style:{ + inverse:true + } + } + }); + + var input = + blessed.textarea({ + parent:screen, + bottom:0, + height:1, + inputOnFocus:true + }); + + /* + Append messages to list + */ + for(var i=0; i {bold}/help{/bold}\n{light-gray-fg} * Client side commands:\n * /help\n * /list\n * /exit{/light-gray-fg}"); + check = true; + break; + + case "/list": + + var users = ""; + for(var i=0; i {bold}/list{/bold}\n{light-gray-fg} * There are " + i + " deekers online:\n * " + users + "{/light-gray-fg}"); + + check = true; + break; + + case "/exit": + process.exit(0); + break; + } + } + + if(check === false){ + send(channel.id, sendmessage); + } + + this.clearValue(); + messagelist.setScrollPerc(100); + screen.render(); + }); +}); + +deek.on("enter", async function(user){ + + messagelist.pushLine("{light-gray-fg} * {bold}" + blessed.escape(user.name) + "{/bold} from " + user.country.name + " has joined{/light-gray-fg}"); + messagelist.setScrollPerc(100); + screen.render(); +}); + +deek.on("exit", async function(user){ + + messagelist.pushLine("{light-gray-fg} * {bold}" + blessed.escape(user.name) + "{/bold} has left{/light-gray-fg}"); + messagelist.setScrollPerc(100); + screen.render(); +}); + +deek.on("message", async function(msg, user){ + + appendmessage(msg, user); +}); + +deek.on("close", async function(channel){ + + messagelist.pushLine("{light-red-fg}It's over. Disconnected from channel " + channel.name + " (id:" + channel.id + "){/light-red-fg}"); + messagelist.setScrollPerc(100); + screen.render(); +}); + +deek.on("error", async function(message){ + + screen_msg.display("{light-red-fg}{bold}Serber error{/bold}\n" + message + ".\nUse CTRL+C to exit{/light-red-fg}"); + screen.render(); +}); + +// connect to serber +handshake(); diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..d97a621 Binary files /dev/null and b/screenshot.png differ diff --git a/settings.conf b/settings.conf new file mode 100644 index 0000000..6ec060c --- /dev/null +++ b/settings.conf @@ -0,0 +1,6 @@ +# Rena Client configuartion file +# Now with 100% less accidently commited passwords +# Create an account by visiting https://deek.chat + +username=your_user_name_here +password=your_password_here