Add permission for /clear and log it

This commit is contained in:
Calvin Montgomery 2014-07-10 20:03:47 -07:00
parent 0e8e0aef54
commit b28fd9e4a8
3 changed files with 11 additions and 3 deletions

View file

@ -375,12 +375,13 @@ ChatModule.prototype.handleCmdSay = function (user, msg, meta) {
};
ChatModule.prototype.handleCmdClear = function (user, msg, meta) {
if (user.account.effectiveRank < 2) {
if (!this.channel.modules.permissions.canClearChat(user)) {
return;
}
this.buffer = [];
this.channel.broadcastAll("clearchat");
this.channel.logger.log("[mod] " + user.getName() + " used /clear");
};
ChatModule.prototype.handleCmdAdminflair = function (user, msg, meta) {

View file

@ -38,7 +38,8 @@ const DEFAULT_PERMISSIONS = {
playlistlock: 2, // Lock/unlock the playlist
leaderctl: 2, // Give/take leader
drink: 1.5, // Use the /d command
chat: 0 // Send chat messages
chat: 0, // Send chat messages
chatclear: 2 // Use the /clear command
};
function PermissionsModule(channel) {
@ -292,6 +293,10 @@ PermissionsModule.prototype.canChat = function (actor) {
return this.hasPermission(actor, "chat");
};
PermissionsModule.prototype.canClearChat = function (actor) {
return this.hasPermission(actor, "chatclear");
};
PermissionsModule.prototype.canSetOptions = function (actor) {
if (actor instanceof User) {
actor = actor.account;
@ -361,7 +366,8 @@ PermissionsModule.prototype.loadUnregistered = function () {
playlistlock: 2, // Lock/unlock the playlist
leaderctl: 0, // Give/take leader
drink: 0, // Use the /d command
chat: 0 // Send chat messages
chat: 0, // Send chat messages
chatclear: 2 // Use the /clear command
};
for (var key in perms) {

View file

@ -1770,6 +1770,7 @@ function genPermissionsEditor() {
addDivider("Misc");
makeOption("Drink calls", "drink", modleader, CHANNEL.perms.drink+"");
makeOption("Chat", "chat", noanon, CHANNEL.perms.chat+"");
makeOption("Clear Chat", "chatclear", modleader, CHANNEL.perms.chatclear+"");
var sgroup = $("<div/>").addClass("form-group").appendTo(form);
var sgroupinner = $("<div/>").addClass("col-sm-8 col-sm-offset-4").appendTo(sgroup);