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

View File

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

View File

@ -23,6 +23,14 @@ function initCallbacks() {
}); });
/* REGION Channel Meta */ /* 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() { socket.on("channelNotRegistered", function() {
showChannelRegistration(); showChannelRegistration();
}); });

View File

@ -28,6 +28,7 @@ var TITLE_BLINK;
var VWIDTH = "670"; var VWIDTH = "670";
var VHEIGHT = "377"; var VHEIGHT = "377";
var IGNORED = []; var IGNORED = [];
var KICKED = false;
var uname = readCookie("sync_uname"); var uname = readCookie("sync_uname");
var pw = readCookie("sync_pw"); 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() { function handleDisconnect() {
if(KICKED)
return;
$("<div/>") $("<div/>")
.addClass("server-msg-disconnect") .addClass("server-msg-disconnect")
.text("Disconnected from server. Attempting reconnection...") .text("Disconnected from server. Attempting reconnection...")

View File

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