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