CyTube/chatcommand.js

31 lines
835 B
JavaScript
Raw Normal View History

2013-03-05 20:23:02 +00:00
var Rank = require('./rank.js');
2013-03-05 18:51:58 +00:00
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");
2013-03-05 20:23:02 +00:00
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);
}
}
2013-03-05 18:51:58 +00:00
}
exports.handle = handle;