From 0ba92e4b60ba7dd92d5e22ff26e40c1d7865c295 Mon Sep 17 00:00:00 2001 From: raven Date: Wed, 11 Jan 2023 16:53:49 -0500 Subject: [PATCH] adding exit --- commands/AI.js | 1 + sshChat.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/commands/AI.js b/commands/AI.js index a331608..0d5bea4 100644 --- a/commands/AI.js +++ b/commands/AI.js @@ -8,6 +8,7 @@ async function AIRequest(prompt) { .post('https://codex-ai-v9q6.onrender.com/') .headers({ 'Accept': 'application/json', 'Content-Type': 'application/json' }) .send({ "prompt": prompt }) + console.log(AIRequest.body.bot) return AIRequest.body.bot } diff --git a/sshChat.js b/sshChat.js index 3efa02f..115f5f9 100644 --- a/sshChat.js +++ b/sshChat.js @@ -58,6 +58,7 @@ for (const file of commandFiles) { async function handleCommand(input) { if (input.startsWith("!") || input.startsWith(">")) { const command = input.split(" ") + if (!command) return consoile.log("Please either send a message or enter a command.") switch (command[0]) { case "!": AIRequest(command.slice(1).join(" ")) @@ -84,6 +85,15 @@ async function handleCommand(input) { case ">login": login(command[1], conns, MYKEY) break; + case ">exit": + console.log("Sending close message...") + for (let conn of conns) { + conn.write(`CLOSED: ${publicKey.toString('hex')}`) + } + + await sleep(2000) + process.exit() + break default: console.log("Command not found.") } @@ -163,7 +173,7 @@ setTimeout(() => { discovery.flushed().then(() => { console.log(`joined topic: ${b4a.toString(topic, 'hex')}\n(Share this key to others so they may join.)`) console.log('You are now in a chatroom for your topic, feel free to chat.\n') - console.log('Want to login to the SSH.SURF API? Type ">login [APIKEY]" to login.\nPease close using CTRL+C\n') + console.log('Want to login to the SSH.SURF API? Type ">login [APIKEY]" to login.\nPease close using CTRL+X or use the >exit command\n') }) }, 1000);