From 39cab9c60d89e32526231e640ac501b1e83f7321 Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 12 Jan 2013 17:10:48 +0000 Subject: [PATCH] Disallow loading modules more than once, with a nice tribute to @samstudio8 if you try to load web [#116] --- modules/admin/admin.js | 14 +++++++++++--- modules/admin/strings.json | 6 ++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/modules/admin/admin.js b/modules/admin/admin.js index 0401585..30d9188 100644 --- a/modules/admin/admin.js +++ b/modules/admin/admin.js @@ -99,9 +99,17 @@ var admin = function(dbot) { // Load new module 'load': function(event) { var moduleName = event.params[1]; - dbot.config.moduleNames.push(moduleName); - dbot.reloadModules(); - event.reply(dbot.t('load_module', {'moduleName': moduleName})); + if(!dbot.config.moduleNames.include(moduleName)) { + dbot.config.moduleNames.push(moduleName); + dbot.reloadModules(); + event.reply(dbot.t('load_module', {'moduleName': moduleName})); + } else { + if(moduleName == 'web') { + event.reply(dbot.t('already_loaded_web')); + } else { + event.reply(dbot.t('already_loaded', {'moduleName': moduleName})); + } + } }, // Unload a loaded module diff --git a/modules/admin/strings.json b/modules/admin/strings.json index 1ca3ed4..7629aec 100644 --- a/modules/admin/strings.json +++ b/modules/admin/strings.json @@ -70,5 +70,11 @@ }, "not_in_channel": { "english": "I'm not in {channel}" + }, + "already_loaded_web": { + "english": "WHY CAN'T I LOAD ALL THIS WEB? (web already loaded)" + }, + "already_loaded": { + "english": "{moduleName} is already loaded." } }