Disallow loading modules more than once, with a nice tribute to @samstudio8 if you try to load web [#116]

This commit is contained in:
reality 2013-01-12 17:10:48 +00:00
parent 73ec2bb182
commit 39cab9c60d
2 changed files with 17 additions and 3 deletions

View File

@ -99,9 +99,17 @@ var admin = function(dbot) {
// Load new module // Load new module
'load': function(event) { 'load': function(event) {
var moduleName = event.params[1]; var moduleName = event.params[1];
dbot.config.moduleNames.push(moduleName); if(!dbot.config.moduleNames.include(moduleName)) {
dbot.reloadModules(); dbot.config.moduleNames.push(moduleName);
event.reply(dbot.t('load_module', {'moduleName': 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 // Unload a loaded module

View File

@ -70,5 +70,11 @@
}, },
"not_in_channel": { "not_in_channel": {
"english": "I'm 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."
} }
} }