mirror of https://github.com/calzoneman/sync.git
Add ability to kick clients
This commit is contained in:
parent
1a88c9e27e
commit
7aafcd7b08
|
@ -1,8 +1,29 @@
|
|||
var Rank = require('./rank.js');
|
||||
|
||||
function handle(chan, user, msg) {
|
||||
if(msg.indexOf("/me ") == 0)
|
||||
chan.sendMessage(user.name, msg.substring(4), "action");
|
||||
else if(msg.indexOf("/sp ") == 0)
|
||||
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;
|
||||
|
|
1
rank.js
1
rank.js
|
@ -15,6 +15,7 @@ exports.Siteadmin = 255;
|
|||
var permissions = {
|
||||
queue: exports.Moderator,
|
||||
assignLeader: exports.Moderator,
|
||||
kick: exports.Moderator,
|
||||
search: exports.Guest,
|
||||
chat: exports.Guest,
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
||||
var promote = $('<li />').appendTo(ul);
|
||||
|
|
Loading…
Reference in New Issue