From 9847a05301192f42b4175e3ab99978f5d0e00e4d Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 26 May 2013 14:14:01 +0000 Subject: [PATCH] Add accessOutput command to tell users when they are not authorised to run a command [#467] --- modules/command/command.js | 10 ++++++---- modules/command/config.json | 3 ++- modules/command/strings.json | 3 +++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/command/command.js b/modules/command/command.js index 1066018..b238ce7 100644 --- a/modules/command/command.js +++ b/modules/command/command.js @@ -25,9 +25,11 @@ var command = function(dbot) { dbot.api.ignore.isUserBanned(event.server, event.user, commandName, function(isBanned) { if(isBanned) { event.reply(dbot.t('command_ban', {'user': event.user})); - } else if(!isIgnoring && - hasAccess && - dbot.commands[commandName].disabled !== true) { + } else if(!hasAccess) { + if(this.config.accessOutput) { + event.reply(dbot.t('access_denied', { 'user': event.user })); + } + } else if(!isIgnoring && !dbot.commands[commandName].disabled) { if(this.api.applyRegex(commandName, event)) { try { var command = dbot.commands[commandName]; @@ -45,7 +47,7 @@ var command = function(dbot) { }); } } - if(commandName != 'reload') dbot.api.event.emit('command', [ event ]); + if(_.include(commandName, ['reload', 'load', 'unload'])) dbot.api.event.emit('command', [ event ]); dbot.save(); } else { if(commandName !== '~') { diff --git a/modules/command/config.json b/modules/command/config.json index ead0df9..3cb33e0 100644 --- a/modules/command/config.json +++ b/modules/command/config.json @@ -1,5 +1,6 @@ { "ignorable": false, "dependencies": [ "event", "ignore", "users" ], - "useNickserv": false + "useNickserv": false, + "accessOutput": false } diff --git a/modules/command/strings.json b/modules/command/strings.json index d13553a..26f1b6c 100644 --- a/modules/command/strings.json +++ b/modules/command/strings.json @@ -36,5 +36,8 @@ "loaded_modules": { "en": "Loaded modules: {modules}.", "nl": "Geladen modules: {modules}." + }, + "access_denied": { + "en": "{user}: You don't have the access level to run this command." } }