voiced in chan can quiet

This commit is contained in:
reality 2013-09-07 17:55:48 +00:00
parent 4940eec5ce
commit a238994e0f
3 changed files with 13 additions and 5 deletions

View File

@ -5,16 +5,24 @@ var api = function(dbot) {
/** /**
* Does the user have the correct access level to use the command? * Does the user have the correct access level to use the command?
*/ */
'hasAccess': function(user, command, callback) { 'hasAccess': function(user, channel, command, callback) {
var accessNeeded = dbot.commands[command].access; var accessNeeded = dbot.commands[command].access;
if(accessNeeded == 'admin' || accessNeeded == 'moderator' || accessNeeded == 'power_user') { if(accessNeeded == 'admin' || accessNeeded == 'moderator' ||
accessNeeded == 'power_user' || accessNeeded == 'voice') {
var allowedNicks = dbot.config.admins; var allowedNicks = dbot.config.admins;
if(accessNeeded == 'moderator') allowedNicks = _.union(allowedNicks, dbot.config.moderators); if(accessNeeded == 'moderator') allowedNicks = _.union(allowedNicks, dbot.config.moderators);
if(accessNeeded == 'power_user') { if(accessNeeded == 'power_user') {
allowedNicks = _.union(allowedNicks, dbot.config.moderators); allowedNicks = _.union(allowedNicks, dbot.config.moderators);
allowedNicks = _.union(allowedNicks, dbot.config.power_users); allowedNicks = _.union(allowedNicks, dbot.config.power_users);
} }
if(accessNeeded == 'voice') {
allowedNicks = _.union(allowedNicks, dbot.config.moderators);
allowedNicks = _.union(allowedNicks, dbot.config.power_users);
allowedNicks = _.union(allowedNicks, _.filter(channel, function(nick) {
return nick.op == true || nick.voice == true;
}));
}
if(!_.include(allowedNicks, user.primaryNick)) { if(!_.include(allowedNicks, user.primaryNick)) {
callback(false); callback(false);

View File

@ -61,7 +61,7 @@ var command = function(dbot) {
} }
} }
this.api.hasAccess(event.rUser, commandName, function(hasAccess) { this.api.hasAccess(event.rUser, event.channel, commandName, function(hasAccess) {
dbot.api.ignore.isUserIgnoring(event.rUser, commandName, function(isIgnoring) { dbot.api.ignore.isUserIgnoring(event.rUser, commandName, function(isIgnoring) {
dbot.api.ignore.isUserBanned(event.rUser, commandName, function(isBanned) { dbot.api.ignore.isUserBanned(event.rUser, commandName, function(isBanned) {
if(isBanned) { if(isBanned) {

View File

@ -269,8 +269,8 @@ var commands = function(dbot) {
commands['~kickcount'].access = 'regular'; commands['~kickcount'].access = 'regular';
commands['~kickstats'].access = 'regular'; commands['~kickstats'].access = 'regular';
commands['~quiet'].access = 'power_user'; commands['~quiet'].access = 'voice';
commands['~unquiet'].access = 'power_user'; commands['~unquiet'].access = 'voice';
commands['~ckick'].regex = [/^~ckick ([^ ]+) ([^ ]+) (.+)$/, 4]; commands['~ckick'].regex = [/^~ckick ([^ ]+) ([^ ]+) (.+)$/, 4];
commands['~nban'].regex = /^~nban ([\d\.^ ]+)?([^ ]+) (.+)$/; commands['~nban'].regex = /^~nban ([\d\.^ ]+)?([^ ]+) (.+)$/;