forked from snxraven/sshChat-CLI
Adding discord IDs
This commit is contained in:
parent
7ed15be770
commit
22928e3f9c
@ -1,16 +1,20 @@
|
||||
var unirest = require('unirest');
|
||||
|
||||
async function login(key, conns, MYKEY, USERNAME) {
|
||||
async function login(key, conns, MYKEY, USERNAME, DISCORD_USERID) {
|
||||
getUSERNAME(key)
|
||||
.then((data) => {
|
||||
console.log("Hello, " + data + "\nYou are now logged in.\n\n\n")
|
||||
USERNAME[0] = data
|
||||
MYKEY.push(key)
|
||||
LOGGEDIN = true
|
||||
getDISCORDID(key)
|
||||
.then((discord) => {
|
||||
DISCORD_USERID[0] = [discord]
|
||||
for (const conn of conns) {
|
||||
conn.write(`${USERNAME} is now logged in.`)
|
||||
conn.write(`${USERNAME} | <@${discord}> is now logged in.`)
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
console.log("Invalid Key")
|
||||
for (const conn of conns) {
|
||||
@ -23,9 +27,16 @@ async function login(key, conns, MYKEY, USERNAME) {
|
||||
// API Functions
|
||||
async function getUSERNAME(key) {
|
||||
let requestUSERNAME = await unirest
|
||||
.get('https://api.discord-linux.com/hello')
|
||||
.get('https://api.discord-linux.com/name')
|
||||
.headers({ 'Accept': 'application/json', 'Content-Type': 'application/json', 'x-discord-linux-auth': key })
|
||||
return requestUSERNAME.body.message.replace("Hello, ", "").replace("!", "")
|
||||
return requestUSERNAME.body.message
|
||||
}
|
||||
|
||||
async function getDISCORDID(key) {
|
||||
let requestUSERNAME = await unirest
|
||||
.get('https://api.discord-linux.com/discordid')
|
||||
.headers({ 'Accept': 'application/json', 'Content-Type': 'application/json', 'x-discord-linux-auth': key })
|
||||
return requestUSERNAME.body.message
|
||||
}
|
||||
|
||||
module.exports = { login }
|
25
sshChat.js
25
sshChat.js
@ -25,6 +25,7 @@ let MYKEY = []
|
||||
let conns = []
|
||||
let connectedUsers = [];
|
||||
let USERNAME = ["annon" + rand]
|
||||
let DISCORD_USERID = []
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise((resolve) => {
|
||||
@ -179,7 +180,7 @@ async function handleCommand(input) {
|
||||
start(MYKEY[0])
|
||||
break;
|
||||
case ">login":
|
||||
login(command[1], conns, MYKEY, USERNAME)
|
||||
login(command[1], conns, MYKEY, USERNAME, DISCORD_USERID)
|
||||
break;
|
||||
case ">exit":
|
||||
console.log("Sending close message...")
|
||||
@ -194,12 +195,24 @@ async function handleCommand(input) {
|
||||
console.log("Command not found.")
|
||||
}
|
||||
} else {
|
||||
for (const conn of conns)
|
||||
if (DISCORD_USERID.length !== 0){
|
||||
for (const conn of conns)
|
||||
conn.write(`${DISCORD_USERID[0]}: ${input}`)
|
||||
} else {
|
||||
for (const conn of conns)
|
||||
conn.write(`${USERNAME}: ${input}`)
|
||||
}
|
||||
if (DISCORD_USERID.length !== 0){
|
||||
console.log(`${DISCORD_USERID[0]}: ${input}`)
|
||||
} else {
|
||||
console.log(`${USERNAME}: ${input}`)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
conn.write(`${USERNAME[0]}: ${input}`)
|
||||
|
||||
}
|
||||
console.log(`${USERNAME[0]}: ${input}`)
|
||||
|
||||
|
||||
}
|
||||
|
||||
swarm.on('connection', conn => {
|
||||
|
Loading…
Reference in New Issue
Block a user