Fix chat commands, fix a few bugs

This commit is contained in:
calzoneman 2014-01-12 17:06:25 -06:00
parent 637ece4044
commit 0a087c6507
8 changed files with 63 additions and 35 deletions

View file

@ -709,25 +709,6 @@ Channel.prototype.handleNameBan = function (actor, name, reason) {
}); });
}; };
/**
* Removes a name ban
*/
Channel.prototype.handleUnbanName = function (actor, name) {
if (!this.hasPermission(actor, "ban")) {
return;
}
if (!this.registered) {
return;
}
this.logger.log("*** " + actor.name + " un-namebanned " + name);
this.sendModMessage(actor.name + " unbanned " + name, this.permissions.ban);
db.channels.unbanName(this.name, name);
// TODO send banlist?
};
/** /**
* Removes a ban by ID * Removes a ban by ID
*/ */
@ -883,7 +864,13 @@ Channel.prototype.banIP = function (actor, ip, name, reason, range) {
} }
// channel, ip, name, reason, ban actor // channel, ip, name, reason, ban actor
db.channels.ban(self.name, ip, name, reason, actor.name); db.channels.ban(self.name, ip, name, reason, actor.name, function (err) {
if (err) {
actor.socket.emit("errorMsg", {
msg: "Ban failed: " + err
});
}
});
}); });
}); });
}; };
@ -1797,6 +1784,11 @@ Channel.prototype.move = function (from, after, callback) {
callback = typeof callback === "function" ? callback : function () { }; callback = typeof callback === "function" ? callback : function () { };
var self = this; var self = this;
if (from === after) {
callback("Cannot move playlist item after itself!", null);
return;
}
self.plqueue.queue(function (lock) { self.plqueue.queue(function (lock) {
if (self.dead) { if (self.dead) {
return; return;
@ -2112,6 +2104,7 @@ Channel.prototype.handleSetLock = function (user, data) {
return; return;
} }
data.locked = Boolean(data.locked); data.locked = Boolean(data.locked);
this.logger.log("*** " + user.name + " set playlist lock to " + data.locked); this.logger.log("*** " + user.name + " set playlist lock to " + data.locked);
this.setLock(data.locked); this.setLock(data.locked);
@ -2121,7 +2114,7 @@ Channel.prototype.handleSetLock = function (user, data) {
* Handles a user message to toggle the locked state of the playlist * Handles a user message to toggle the locked state of the playlist
*/ */
Channel.prototype.handleToggleLock = function (user) { Channel.prototype.handleToggleLock = function (user) {
this.handleSetLock(user, { locked: !this.playlistLocked }); this.handleSetLock(user, { locked: !this.playlistLock });
}; };
/** /**

View file

@ -18,10 +18,12 @@ var handlers = {
meta.addClass = "action"; meta.addClass = "action";
meta.action = true; meta.action = true;
chan.sendMessage(user, msg, meta); chan.sendMessage(user, msg, meta);
return true;
}, },
"sp": function (chan, user, msg, meta) { "sp": function (chan, user, msg, meta) {
meta.addClass = "spoiler"; meta.addClass = "spoiler";
chan.sendMessage(user, msg, meta); chan.sendMessage(user, msg, meta);
return true;
}, },
"say": function (chan, user, msg, meta) { "say": function (chan, user, msg, meta) {
if (user.rank >= 1.5) { if (user.rank >= 1.5) {
@ -29,11 +31,12 @@ var handlers = {
meta.addClassToNameAndTimestamp = true; meta.addClassToNameAndTimestamp = true;
meta.forceShowName = true; meta.forceShowName = true;
chan.sendMessage(user, msg, meta); chan.sendMessage(user, msg, meta);
return true;
} }
}, },
"a": function (chan, user, msg, meta) { "a": function (chan, user, msg, meta) {
if (user.global_rank < 255) { if (user.global_rank < 255) {
return; return false;
} }
var superadminflair = { var superadminflair = {
labelclass: "label-important", labelclass: "label-important",
@ -56,47 +59,57 @@ var handlers = {
meta.superadminflair = superadminflair; meta.superadminflair = superadminflair;
meta.forceShowName = true; meta.forceShowName = true;
chan.sendMessage(user, cargs.join(" "), meta); chan.sendMessage(user, cargs.join(" "), meta);
return true;
}, },
"poll": function (chan, user, msg, meta) { "poll": function (chan, user, msg, meta) {
handlePoll(chan, user, msg, false); handlePoll(chan, user, msg, false);
return true;
}, },
"hpoll": function (chan, user, msg, meta) { "hpoll": function (chan, user, msg, meta) {
handlePoll(chan, user, msg, true); handlePoll(chan, user, msg, true);
return true;
}, },
/* commands that do not send chat messages */ /* commands that do not send chat messages */
"afk": function (chan, user, msg, meta) { "afk": function (chan, user, msg, meta) {
user.setAFK(!user.meta.afk); user.setAFK(!user.meta.afk);
return true;
}, },
"mute": function (chan, user, msg, meta) { "mute": function (chan, user, msg, meta) {
handleMute(chan, user, msg.split(" ")); handleMute(chan, user, msg.split(" "));
return true;
}, },
"smute": function (chan, user, msg, meta) { "smute": function (chan, user, msg, meta) {
handleShadowMute(chan, user, msg.split(" ")); handleShadowMute(chan, user, msg.split(" "));
return true;
}, },
"unmute": function (chan, user, msg, meta) { "unmute": function (chan, user, msg, meta) {
handleUnmute(chan, user, msg.split(" ")); handleUnmute(chan, user, msg.split(" "));
return true;
}, },
"kick": function (chan, user, msg, meta) { "kick": function (chan, user, msg, meta) {
handleKick(chan, user, msg.split(" ")); handleKick(chan, user, msg.split(" "));
return true;
}, },
"ban": function (chan, user, msg, meta) { "ban": function (chan, user, msg, meta) {
handleBan(chan, user, msg.split(" ")); handleBan(chan, user, msg.split(" "));
return true;
}, },
"ipban": function (chan, user, msg, meta) { "ipban": function (chan, user, msg, meta) {
handleIPBan(chan, user, msg.split(" ")); handleIPBan(chan, user, msg.split(" "));
}, return true;
"unban": function (chan, user, msg, meta) {
handleUnban(chan, user, msg.split(" "));
}, },
"clear": function (chan, user, msg, meta) { "clear": function (chan, user, msg, meta) {
handleClear(chan, user); handleClear(chan, user);
return true;
}, },
"clean": function (chan, user, msg, meta) { "clean": function (chan, user, msg, meta) {
handleClean(chan, user, msg); handleClean(chan, user, msg);
return true;
}, },
"cleantitle": function (chan, user, msg, meta) { "cleantitle": function (chan, user, msg, meta) {
handleCleanTitle(chan, user, msg); handleCleanTitle(chan, user, msg);
return true;
} }
}; };
@ -114,7 +127,7 @@ function handle(chan, user, msg, meta) {
var m = msg.match(/^\/d(-?[0-9]*)(?:\s|$)(.*)/); var m = msg.match(/^\/d(-?[0-9]*)(?:\s|$)(.*)/);
if (m) { if (m) {
handleDrink(chan, user, m[1], m[2], meta); handleDrink(chan, user, m[1], m[2], meta);
return; return true;
} }
for (var i = 0; i < handlerList.length; i++) { for (var i = 0; i < handlerList.length; i++) {
var h = handlerList[i]; var h = handlerList[i];
@ -125,8 +138,7 @@ function handle(chan, user, msg, meta) {
} else { } else {
rest = ""; rest = "";
} }
h.fn(chan, user, rest, meta); return h.fn(chan, user, rest, meta);
break;
} }
} }
} }
@ -148,7 +160,7 @@ function handleDrink(chan, user, count, msg, meta) {
meta.forceShowName = true; meta.forceShowName = true;
meta.addClass = "drink"; meta.addClass = "drink";
chan.drinks += count; chan.drinks += count;
chan.broadcastDrinks(); chan.sendDrinks(chan.users);
if (count < 0 && msg.trim() === "") { if (count < 0 && msg.trim() === "") {
return; return;
} }
@ -331,7 +343,7 @@ function handlePoll(chan, user, msg, hidden) {
args.splice(0, 1); args.splice(0, 1);
var poll = new Poll(user.name, title, args, hidden === true); var poll = new Poll(user.name, title, args, hidden === true);
chan.poll = poll; chan.poll = poll;
chan.broadcastPoll(); chan.sendPoll(chan.users);
chan.logger.log("*** " + user.name + " Opened Poll: '" + poll.title + "'"); chan.logger.log("*** " + user.name + " Opened Poll: '" + poll.title + "'");
} }
} }

View file

@ -26,8 +26,8 @@ html(lang="en")
#motd #motd
.clear .clear
#announcements.row #announcements.row
#drinkbarwrap.col-lg-12.col-md-12.row #drinkbarwrap.row
#drinkbar #drinkbar.col-lg-12.col-md-12
h1#drinkcount h1#drinkcount
#main.row #main.row
#chatwrap.col-lg-5.col-md-5 #chatwrap.col-lg-5.col-md-5

View file

@ -448,6 +448,24 @@ Callbacks = {
formatCSBanlist(); formatCSBanlist();
}, },
banlistRemove: function (data) {
var entries = $("#cs-banlist table").data("entries") || [];
var found = false;
for (var i = 0; i < entries.length; i++) {
if (entries[i].id === data.id) {
found = i;
break;
}
}
if (found !== false) {
entries.splice(i, 1);
$("#cs-banlist table").data("entries", entries);
}
formatCSBanlist();
},
recentLogins: function(entries) { recentLogins: function(entries) {
var tbl = $("#loginhistory table"); var tbl = $("#loginhistory table");
// I originally added this check because of a race condition // I originally added this check because of a race condition

View file

@ -124,8 +124,13 @@
margin-top: 5px; margin-top: 5px;
} }
#drinkbar { .drink {
margin-left: 0; margin: 10px 10px;
padding: 10px 0px;
border: 2px solid #0000cc;
}
#drinkcount {
background-color: #000000; background-color: #000000;
color: #ffffff; color: #ffffff;
text-align: center; text-align: center;
@ -250,7 +255,7 @@
} }
.queue_temp { .queue_temp {
background-image: url(../img/stripe-diagonal.png); background-image: url(/img/stripe-diagonal.png);
} }
.queue_active { .queue_active {

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
www/img/stripe-diagonal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B