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