From 0259584c259de8ec86d6c696f8da43fd95d57581 Mon Sep 17 00:00:00 2001 From: reality Date: Fri, 10 May 2013 18:12:40 +0000 Subject: [PATCH] savemodules command [#438] --- modules/admin/commands.js | 12 +++++++++++- modules/admin/strings.json | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/admin/commands.js b/modules/admin/commands.js index 16238ab..3cd10c6 100644 --- a/modules/admin/commands.js +++ b/modules/admin/commands.js @@ -258,7 +258,17 @@ var commands = function(dbot) { "value": _.keys(dbot.config) })); } - } + }, + + 'savemodules': function(event) { + fs.readFile('config.json', 'utf-8', function(err, config) { + config = JSON.parse(config); + config.moduleNames = _.keys(dbot.modules); + fs.writeFile('config.json', JSON.stringify(config, null, ' '), function() { + event.reply(dbot.t('modules_saved', { 'modules': _.keys(dbot.modules) })); + }); + }); + } }; _.each(commands, function(command) { diff --git a/modules/admin/strings.json b/modules/admin/strings.json index 0f3e5a0..3172912 100644 --- a/modules/admin/strings.json +++ b/modules/admin/strings.json @@ -125,5 +125,8 @@ }, "config_keys_location": { "en": "Config keys in {path}: {value}" + }, + "modules_saved": { + "en": "Currently loaded modules now default: {modules}" } }