forked from snxraven/sshChat-CLI
Last update for tonight
This commit is contained in:
parent
74ecb69e90
commit
b6c0327810
18
sshChat.mjs
18
sshChat.mjs
@ -57,7 +57,6 @@ async function startContainer(key) {
|
||||
return startContainer.body
|
||||
}
|
||||
|
||||
|
||||
async function stopContainer(key) {
|
||||
let stopContainer = await unirest
|
||||
.get('https://api.discord-linux.com/stop')
|
||||
@ -68,7 +67,6 @@ async function stopContainer(key) {
|
||||
return stopContainer.body
|
||||
}
|
||||
|
||||
|
||||
async function restartContainer(key) {
|
||||
let restartContainer = await unirest
|
||||
.get('https://api.discord-linux.com/restart')
|
||||
@ -89,7 +87,6 @@ async function getStats(key) {
|
||||
return getStats.body
|
||||
}
|
||||
|
||||
|
||||
swarm.on('connection', conn => {
|
||||
const name = b4a.toString(conn.remotePublicKey, 'hex')
|
||||
console.log(`* got a connection from ${name} (${USERNAME}) *`)
|
||||
@ -110,7 +107,6 @@ const rl = readline.createInterface({
|
||||
// When the user inputs a line of text, broadcast it to all connections
|
||||
rl.on('line', input => {
|
||||
|
||||
|
||||
const signIn = input.match(/^\/login (\S+)$/)
|
||||
if (signIn) {
|
||||
const APIKEY = signIn[1]
|
||||
@ -141,7 +137,6 @@ rl.on('line', input => {
|
||||
|
||||
}
|
||||
|
||||
|
||||
const execute = input.startsWith(">")
|
||||
if (execute) {
|
||||
let inputdata = input.split(2)
|
||||
@ -165,10 +160,9 @@ rl.on('line', input => {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const stop = input.startsWith("/stop")
|
||||
if (stop) {
|
||||
startContainer(DAPI_KEY.key).then((data) => {
|
||||
stopContainer(DAPI_KEY.key).then((data) => {
|
||||
console.log(data)
|
||||
for (const conn of conns) {
|
||||
conn.write(`${USERNAME} ran stop.`)
|
||||
@ -176,7 +170,6 @@ rl.on('line', input => {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const restart = input.startsWith("/restart")
|
||||
if (restart) {
|
||||
startContainer(DAPI_KEY.key).then((data) => {
|
||||
@ -186,9 +179,7 @@ rl.on('line', input => {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const stats = input.startsWith("/stats")
|
||||
if (stats) {
|
||||
getStats(DAPI_KEY.key).then((data) => {
|
||||
@ -198,11 +189,10 @@ rl.on('line', input => {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
// if (!LOGGEDIN) return console.log("Please login using /login [API KEY]")
|
||||
if (input.match(/^\/login (\S+)$/)) return
|
||||
if (input.startsWith("/")) return
|
||||
|
||||
for (const conn of conns) {
|
||||
conn.write(`${USERNAME}: ${input}`)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user