Added silent-join

This commit is contained in:
Kasper Rynning-Tønnesen
2019-09-17 23:00:25 +02:00
parent 50694e32db
commit f5d9272a42
3 changed files with 49 additions and 2 deletions

View File

@@ -31,6 +31,41 @@ function now_playing(list, fn, socket) {
});
}
function join_silent(msg, socket) {
if (typeof msg === "object" && msg !== undefined && msg !== null) {
var channelName = msg.channel;
var tryingPassword = false;
var password = "";
if(msg.password != "") {
tryingPassword = true;
password = Functions.decrypt_string(msg.password);
password = crypto
.createHash("sha256")
.update(password)
.digest("base64");
}
channelName = channelName.toLowerCase(); //.replace(/ /g,'');
channelName = Functions.removeEmojis(channelName).toLowerCase();
db.collection(channelName + "_settings").find(function(err, docs) {
if(docs.length == 0) {
socket.emit("join_silent_declined", "");
return;
}
if(docs[0].userpass == "" || docs[0].userpass == undefined || docs[0].userpass == password) {
socket.join(channelName);
socket.emit("join_silent_accepted", "");
send_play(channelName, socket);
} else {
socket.emit("join_silent_declined", "");
}
});
} else {
return;
}
}
function list(msg, guid, coll, offline, socket) {
var socketid = socket.zoff_id;
if (typeof msg === "object" && msg !== undefined && msg !== null) {
@@ -1245,6 +1280,7 @@ function getNextSong(coll, socket, callback) {
);
}
module.exports.join_silent = join_silent;
module.exports.sendColor = sendColor;
module.exports.now_playing = now_playing;
module.exports.list = list;