fixing username

This commit is contained in:
raven 2023-01-12 10:29:32 -05:00
parent 0ba92e4b60
commit 4d31a133a9
2 changed files with 7 additions and 7 deletions

View File

@ -1,12 +1,12 @@
var unirest = require('unirest');
async function login(key, conns, MYKEY) {
async function login(key, conns, MYKEY, USERNAME) {
getUSERNAME(key)
.then((data) => {
process.stdout.write("\033[2J")
process.stdout.write("\033[0f")
console.log("Hello, " + data + "\nYou are now logged in.\n\n\n")
USERNAME = data
USERNAME[0] = data
MYKEY.push(key)
LOGGEDIN = true
for (const conn of conns) {

View File

@ -19,10 +19,10 @@ let rand = Math.floor(Math.random() * 99999).toString();
let USERPWD = "/"
let DAPI_KEY
let USERNAME = "anon" + rand
let LOGGEDIN = false
let MYKEY = []
let conns = []
let USERNAME = ["annon" + rand]
function sleep(ms) {
return new Promise((resolve) => {
@ -83,7 +83,7 @@ async function handleCommand(input) {
start(MYKEY[0])
break;
case ">login":
login(command[1], conns, MYKEY)
login(command[1], conns, MYKEY, USERNAME)
break;
case ">exit":
console.log("Sending close message...")
@ -100,10 +100,10 @@ async function handleCommand(input) {
} else {
for (const conn of conns)
conn.write(`${USERNAME}: ${input}`)
conn.write(`${USERNAME[0]}: ${input}`)
}
console.log(`${USERNAME}: ${input}`)
console.log(`${USERNAME[0]}: ${input}`)
clearCursor()
}
@ -121,7 +121,7 @@ swarm.on('connection', conn => {
})
const name = b4a.toString(conn.remotePublicKey, 'hex')
console.log(`* got a connection from ${name} (${USERNAME}) *`)
console.log(`* got a connection from ${name} (${USERNAME[0]}) *`)
conns.push(conn)
conn.once('close', () => conns.splice(conns.indexOf(conn), 1))
conn.on('data', data => {