diff --git a/lib/channel/chat.js b/lib/channel/chat.js index fc67e9e7..0a1731d8 100644 --- a/lib/channel/chat.js +++ b/lib/channel/chat.js @@ -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) { diff --git a/lib/channel/permissions.js b/lib/channel/permissions.js index 33966674..54b18a04 100644 --- a/lib/channel/permissions.js +++ b/lib/channel/permissions.js @@ -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) { diff --git a/www/js/util.js b/www/js/util.js index 31dc2c67..6bdf421f 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -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 = $("
").addClass("form-group").appendTo(form); var sgroupinner = $("
").addClass("col-sm-8 col-sm-offset-4").appendTo(sgroup);