Tweaks to Leaders, add kick messages

This commit is contained in:
calzoneman 2013-04-14 12:38:00 -05:00
parent 78c7a4d77a
commit 4e2e349196
6 changed files with 34 additions and 14 deletions

View File

@ -260,6 +260,7 @@ Channel.prototype.userJoin = function(user) {
// GTFO
if(user.ip in this.ipbans && this.ipbans[user.ip] != null) {
this.logger.log("--- Kicking " + user.ip + " - banned");
this.kick(user, "You're banned!");
user.socket.disconnect(true);
return;
}
@ -347,6 +348,16 @@ Channel.prototype.userLeave = function(user) {
this.logger.log("--- /" + user.ip + " (" + user.name + ") left");
}
Channel.prototype.kick = function(user, reason) {
user.socket.emit("kick", {
reason: reason
});
if(user.socket.disconnected) {
this.userLeave(user);
}
user.socket.disconnect(true);
}
Channel.prototype.sendRankStuff = function(user) {
if(Rank.hasPermission(user, "ipban")) {
var ents = [];
@ -806,7 +817,7 @@ Channel.prototype.tryMove = function(user, data) {
/* REGION Polls */
Channel.prototype.tryClosePoll = function(user) {
if(!Rank.hasPermission(user, "poll")) {
if(!Rank.hasPermission(user, "poll") && this.leader != user) {
return;
}

View File

@ -19,7 +19,7 @@ function handle(chan, user, msg) {
else if(msg.indexOf("/sp ") == 0)
chan.sendMessage(user.name, msg.substring(4), "spoiler");
else if(msg.indexOf("/say ") == 0) {
if(Rank.hasPermission(user, "shout")) {
if(Rank.hasPermission(user, "shout") || chan.leader == user) {
chan.sendMessage(user.name, msg.substring(5), "shout");
}
}
@ -52,10 +52,9 @@ function handleKick(chan, user, args) {
}
if(kickee) {
chan.logger.log("*** " + user.name + " kicked " + args[0]);
if(kickee.socket.disconnected) {
chan.userLeave(kickee);
}
kickee.socket.disconnect(true);
args[0] = "";
var reason = args.join(" ");
chan.kick(kickee, reason);
}
}
}
@ -71,10 +70,9 @@ function handleBan(chan, user, args) {
}
if(kickee && kickee.rank < user.rank) {
chan.logger.log("*** " + user.name + " banned " + args[0]);
if(kickee.socket.disconnected) {
chan.userLeave(kickee);
}
chan.banIP(user, kickee);
args[0] = "";
var reason = args.join(" ");
chan.kick(kickee, "(banned) " + reason);
}
}
}
@ -87,7 +85,7 @@ function handleUnban(chan, user, args) {
}
function handlePoll(chan, user, msg) {
if(Rank.hasPermission(user, "poll")) {
if(Rank.hasPermission(user, "poll") || chan.leader == user) {
var args = msg.split(",");
var title = args[0];
args.splice(0, 1);
@ -112,12 +110,12 @@ function handleDrink(chan, user, msg) {
chan.drinks += count;
chan.broadcastDrinks();
if(count < 0) {
if(count < 0 && msg.trim() == "") {
return;
}
msg = msg + " drink!";
if(count > 1)
if(count != 1)
msg += " (x" + count + ")";
chan.sendMessage(user.name, msg, "drink");
}

View File

@ -23,6 +23,14 @@ function initCallbacks() {
});
/* REGION Channel Meta */
socket.on("kick", function(data) {
KICKED = true;
$("<div/>")
.addClass("server-msg-disconnect")
.text("Kicked: " + data.reason)
.appendTo($("#messagebuffer"));
});
socket.on("channelNotRegistered", function() {
showChannelRegistration();
});

View File

@ -28,6 +28,7 @@ var TITLE_BLINK;
var VWIDTH = "670";
var VHEIGHT = "377";
var IGNORED = [];
var KICKED = false;
var uname = readCookie("sync_uname");
var pw = readCookie("sync_pw");

View File

@ -10,6 +10,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
*/
function handleDisconnect() {
if(KICKED)
return;
$("<div/>")
.addClass("server-msg-disconnect")
.text("Disconnected from server. Attempting reconnection...")

View File

@ -91,7 +91,7 @@ Media.prototype.initVimeo = function() {
this.player = $f(iframe[0]);
$f(iframe[0]).addEvent("ready", function() {
this.player = $f(iframe[0]);
this.play();
this.player.api("play");
this.player.addEvent("finish", function() {
if(LEADER) {