adding exit

This commit is contained in:
raven 2023-01-11 16:53:49 -05:00
parent 61a7e442c9
commit 0ba92e4b60
2 changed files with 12 additions and 1 deletions

View File

@ -8,6 +8,7 @@ async function AIRequest(prompt) {
.post('https://codex-ai-v9q6.onrender.com/') .post('https://codex-ai-v9q6.onrender.com/')
.headers({ 'Accept': 'application/json', 'Content-Type': 'application/json' }) .headers({ 'Accept': 'application/json', 'Content-Type': 'application/json' })
.send({ "prompt": prompt }) .send({ "prompt": prompt })
console.log(AIRequest.body.bot)
return AIRequest.body.bot return AIRequest.body.bot
} }

View File

@ -58,6 +58,7 @@ for (const file of commandFiles) {
async function handleCommand(input) { async function handleCommand(input) {
if (input.startsWith("!") || input.startsWith(">")) { if (input.startsWith("!") || input.startsWith(">")) {
const command = input.split(" ") const command = input.split(" ")
if (!command) return consoile.log("Please either send a message or enter a command.")
switch (command[0]) { switch (command[0]) {
case "!": case "!":
AIRequest(command.slice(1).join(" ")) AIRequest(command.slice(1).join(" "))
@ -84,6 +85,15 @@ async function handleCommand(input) {
case ">login": case ">login":
login(command[1], conns, MYKEY) login(command[1], conns, MYKEY)
break; 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: default:
console.log("Command not found.") console.log("Command not found.")
} }
@ -163,7 +173,7 @@ setTimeout(() => {
discovery.flushed().then(() => { discovery.flushed().then(() => {
console.log(`joined topic: ${b4a.toString(topic, 'hex')}\n(Share this key to others so they may join.)`) 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('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); }, 1000);