Add ability to kick clients

This commit is contained in:
calzoneman 2013-03-05 14:23:02 -06:00
parent 1a88c9e27e
commit 7aafcd7b08
3 changed files with 31 additions and 0 deletions

View File

@ -1,8 +1,29 @@
var Rank = require('./rank.js');
function handle(chan, user, msg) { function handle(chan, user, msg) {
if(msg.indexOf("/me ") == 0) if(msg.indexOf("/me ") == 0)
chan.sendMessage(user.name, msg.substring(4), "action"); chan.sendMessage(user.name, msg.substring(4), "action");
else if(msg.indexOf("/sp ") == 0) else if(msg.indexOf("/sp ") == 0)
chan.sendMessage(user.name, msg.substring(4), "spoiler"); chan.sendMessage(user.name, msg.substring(4), "spoiler");
else if(msg.indexOf("/kick ") == 0) {
handleKick(chan, user, msg.substring(6).split(' '));
}
}
function handleKick(chan, user, args) {
if(Rank.hasPermission(user, "kick") && args.length > 0) {
var kickee;
for(var i = 0; i < chan.users.length; i++) {
if(chan.users[i].name == args[0]) {
kickee = chan.users[i];
break;
}
}
if(kickee) {
kickee.socket.disconnect();
chan.userLeave(kickee);
}
}
} }
exports.handle = handle; exports.handle = handle;

View File

@ -15,6 +15,7 @@ exports.Siteadmin = 255;
var permissions = { var permissions = {
queue: exports.Moderator, queue: exports.Moderator,
assignLeader: exports.Moderator, assignLeader: exports.Moderator,
kick: exports.Moderator,
search: exports.Guest, search: exports.Guest,
chat: exports.Guest, chat: exports.Guest,
}; };

View File

@ -65,6 +65,15 @@ function addUserDropdown(entry, name) {
}); });
}); });
var kick = $('<li />').appendTo(ul);
var a = $('<a />').attr("tabindex", "-1").attr("href", "#").appendTo(kick);
a.text("Kick");
a.click(function() {
socket.emit('chatMsg', {
msg: "/kick " + name
});
});
$('<li />').addClass("divider").appendTo(ul); $('<li />').addClass("divider").appendTo(ul);
var promote = $('<li />').appendTo(ul); var promote = $('<li />').appendTo(ul);