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
*/
@ -883,7 +864,13 @@ Channel.prototype.banIP = function (actor, ip, name, reason, range) {
}
// 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 () { };
var self = this;
if (from === after) {
callback("Cannot move playlist item after itself!", null);
return;
}
self.plqueue.queue(function (lock) {
if (self.dead) {
return;
@ -2112,6 +2104,7 @@ Channel.prototype.handleSetLock = function (user, data) {
return;
}
data.locked = Boolean(data.locked);
this.logger.log("*** " + user.name + " set playlist lock to " + 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
*/
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.action = true;
chan.sendMessage(user, msg, meta);
return true;
},
"sp": function (chan, user, msg, meta) {
meta.addClass = "spoiler";
chan.sendMessage(user, msg, meta);
return true;
},
"say": function (chan, user, msg, meta) {
if (user.rank >= 1.5) {
@ -29,11 +31,12 @@ var handlers = {
meta.addClassToNameAndTimestamp = true;
meta.forceShowName = true;
chan.sendMessage(user, msg, meta);
return true;
}
},
"a": function (chan, user, msg, meta) {
if (user.global_rank < 255) {
return;
return false;
}
var superadminflair = {
labelclass: "label-important",
@ -56,47 +59,57 @@ var handlers = {
meta.superadminflair = superadminflair;
meta.forceShowName = true;
chan.sendMessage(user, cargs.join(" "), meta);
return true;
},
"poll": function (chan, user, msg, meta) {
handlePoll(chan, user, msg, false);
return true;
},
"hpoll": function (chan, user, msg, meta) {
handlePoll(chan, user, msg, true);
return true;
},
/* commands that do not send chat messages */
"afk": function (chan, user, msg, meta) {
user.setAFK(!user.meta.afk);
return true;
},
"mute": function (chan, user, msg, meta) {
handleMute(chan, user, msg.split(" "));
return true;
},
"smute": function (chan, user, msg, meta) {
handleShadowMute(chan, user, msg.split(" "));
return true;
},
"unmute": function (chan, user, msg, meta) {
handleUnmute(chan, user, msg.split(" "));
return true;
},
"kick": function (chan, user, msg, meta) {
handleKick(chan, user, msg.split(" "));
return true;
},
"ban": function (chan, user, msg, meta) {
handleBan(chan, user, msg.split(" "));
return true;
},
"ipban": function (chan, user, msg, meta) {
handleIPBan(chan, user, msg.split(" "));
},
"unban": function (chan, user, msg, meta) {
handleUnban(chan, user, msg.split(" "));
return true;
},
"clear": function (chan, user, msg, meta) {
handleClear(chan, user);
return true;
},
"clean": function (chan, user, msg, meta) {
handleClean(chan, user, msg);
return true;
},
"cleantitle": function (chan, user, msg, meta) {
handleCleanTitle(chan, user, msg);
return true;
}
};
@ -114,7 +127,7 @@ function handle(chan, user, msg, meta) {
var m = msg.match(/^\/d(-?[0-9]*)(?:\s|$)(.*)/);
if (m) {
handleDrink(chan, user, m[1], m[2], meta);
return;
return true;
}
for (var i = 0; i < handlerList.length; i++) {
var h = handlerList[i];
@ -125,8 +138,7 @@ function handle(chan, user, msg, meta) {
} else {
rest = "";
}
h.fn(chan, user, rest, meta);
break;
return h.fn(chan, user, rest, meta);
}
}
}
@ -148,7 +160,7 @@ function handleDrink(chan, user, count, msg, meta) {
meta.forceShowName = true;
meta.addClass = "drink";
chan.drinks += count;
chan.broadcastDrinks();
chan.sendDrinks(chan.users);
if (count < 0 && msg.trim() === "") {
return;
}
@ -331,7 +343,7 @@ function handlePoll(chan, user, msg, hidden) {
args.splice(0, 1);
var poll = new Poll(user.name, title, args, hidden === true);
chan.poll = poll;
chan.broadcastPoll();
chan.sendPoll(chan.users);
chan.logger.log("*** " + user.name + " Opened Poll: '" + poll.title + "'");
}
}

View file

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

View file

@ -448,6 +448,24 @@ Callbacks = {
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) {
var tbl = $("#loginhistory table");
// I originally added this check because of a race condition

View file

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