From fedb9335a2c68230bdc1e4a8957d0d82800049e4 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 20 Jan 2013 16:17:22 +0000 Subject: [PATCH] showconfig command [#145] --- modules/admin/commands.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/admin/commands.js b/modules/admin/commands.js index 51e371e..02dd0af 100644 --- a/modules/admin/commands.js +++ b/modules/admin/commands.js @@ -206,6 +206,27 @@ var commands = function(dbot) { event.reply(configPathString + ": " + currentOption + " -> " + newOption); userConfigPath[configKey] = newOption; dbot.reloadModules(); + }, + + 'showconfig': function(event) { + var configPathString = event.params[1]; + var configKey = _.last(configPathString.split('.')); + var configPath = getCurrentConfigPath(configPathString); + + if(!_.has(configPath['default'], configKey)) { + event.reply("Config path doesn't exist"); + return + } + + if(_.isObject(configPath['default'][configKey])) { + event.reply('Config keys in ' + configPathString + ': ' + Object.keys(configPath['default'][configKey])); + } else { + var currentOption = configPath['default'][configKey]; + if(_.has(configPath['user'][configKey])) { + currentOption = configPath['user'][configKey]; + } + event.reply(configPathString + ': ' + currentOption); + } } }; @@ -214,6 +235,7 @@ var commands = function(dbot) { commands['unload'].access = 'admin'; commands['load'].access = 'admin'; commands['setconfig'].access = 'admin'; + commands['showconfig'].access = 'moderator'; commands['join'].access = 'moderator'; commands['part'].access = 'moderator'; commands['opme'].access = 'moderator';