forked from snxraven/sshChat-CLI
working on commands
This commit is contained in:
parent
744ab922d6
commit
60bb59831e
565
package-lock.json
generated
565
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
39
sshChat.mjs
39
sshChat.mjs
@ -54,7 +54,7 @@ async function startContainer(key) {
|
||||
'Accept': 'application/json', 'Content-Type': 'application/json',
|
||||
'x-discord-linux-auth': key
|
||||
})
|
||||
return startContainer.body.completed
|
||||
return startContainer.body
|
||||
}
|
||||
|
||||
|
||||
@ -65,9 +65,10 @@ async function stopContainer(key) {
|
||||
'Accept': 'application/json', 'Content-Type': 'application/json',
|
||||
'x-discord-linux-auth': key
|
||||
})
|
||||
return stopContainer.body.completed
|
||||
return stopContainer.body
|
||||
}
|
||||
|
||||
|
||||
async function restartContainer(key) {
|
||||
let restartContainer = await unirest
|
||||
.get('https://api.discord-linux.com/restart')
|
||||
@ -75,18 +76,17 @@ async function restartContainer(key) {
|
||||
'Accept': 'application/json', 'Content-Type': 'application/json',
|
||||
'x-discord-linux-auth': key
|
||||
})
|
||||
return restartContainer.body.completed
|
||||
return restartContainer.body
|
||||
}
|
||||
|
||||
async function getStats(key) {
|
||||
let getStats = await unirest
|
||||
.get('https://api.discord-linux.com/restart')
|
||||
.get('https://api.discord-linux.com/stats')
|
||||
.headers({
|
||||
'Accept': 'application/json', 'Content-Type': 'application/json',
|
||||
'x-discord-linux-auth': key
|
||||
})
|
||||
console.log(getStats.body)
|
||||
return getStats.body.data
|
||||
return getStats.body
|
||||
}
|
||||
|
||||
|
||||
@ -155,52 +155,51 @@ rl.on('line', input => {
|
||||
})
|
||||
}
|
||||
|
||||
const start = input.match(/^\/start (\S+)$/)
|
||||
const start = input.startsWith("/start")
|
||||
if (start) {
|
||||
const cmdToRun = start[1]
|
||||
startContainer(DAPI_KEY.key).then((data) => {
|
||||
console.log(data)
|
||||
for (const conn of conns) {
|
||||
console.log(data)
|
||||
conn.write(`${USERNAME} ran start: \n` + data)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const stop = input.match(/^\/stop (\S+)$/)
|
||||
const stop = input.startsWith("/stop")
|
||||
if (stop) {
|
||||
const cmdToRun = stop[1]
|
||||
stopContainer(DAPI_KEY.key).then((data) => {
|
||||
startContainer(DAPI_KEY.key).then((data) => {
|
||||
console.log(data)
|
||||
for (const conn of conns) {
|
||||
console.log(data)
|
||||
conn.write(`${USERNAME} ran stop: \n` + data)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const restart = input.match(/^\/restart (\S+)$/)
|
||||
|
||||
const restart = input.startsWith("/restart")
|
||||
if (restart) {
|
||||
const restart = restart[1]
|
||||
restartContainer(DAPI_KEY.key).then((data) => {
|
||||
startContainer(DAPI_KEY.key).then((data) => {
|
||||
console.log(data)
|
||||
for (const conn of conns) {
|
||||
console.log(data)
|
||||
conn.write(`${USERNAME} ran restart: \n` + data)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const stats = input.match(/^\/stats (\S+)$/)
|
||||
|
||||
const stats = input.startsWith("/stats")
|
||||
if (stats) {
|
||||
const stats = stats[1]
|
||||
getStats(DAPI_KEY.key).then((data) => {
|
||||
console.log(data)
|
||||
for (const conn of conns) {
|
||||
console.log(data)
|
||||
conn.write(`${USERNAME} ran stats: \n` + data)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
// if (!LOGGEDIN) return console.log("Please login using /login [API KEY]")
|
||||
if (input.match(/^\/login (\S+)$/)) return
|
||||
|
Loading…
Reference in New Issue
Block a user