diff --git a/sopel/loader.py b/sopel/loader.py index dc0e48e56f..fd92d73223 100644 --- a/sopel/loader.py +++ b/sopel/loader.py @@ -167,10 +167,13 @@ def clean_callable(func, config): func.rule = getattr(func, 'rule', []) for command in getattr(func, 'commands', []): regexp = get_command_regexp(prefix, command) - func.rule.append(regexp) + if regexp not in func.rule: + # TODO: Maybe func.rule should be a set() instead? + func.rule.append(regexp) for command in getattr(func, 'nickname_commands', []): regexp = get_nickname_command_regexp(nick, command, alias_nicks) - func.rule.append(regexp) + if regexp not in func.rule: + func.rule.append(regexp) if hasattr(func, 'example'): example = func.example[0]["example"] example = example.replace('$nickname', nick) diff --git a/sopel/modules/reload.py b/sopel/modules/reload.py index 99fe786a95..62f4eae1f8 100644 --- a/sopel/modules/reload.py +++ b/sopel/modules/reload.py @@ -48,7 +48,7 @@ def f_reload(bot, trigger): return bot.reply('done') - if (name not in sys.modules and name not in sopel.loader.enumerate_modules(bot.config)): + if name not in sys.modules or name not in sopel.loader.enumerate_modules(bot.config): return bot.reply('"%s" not loaded, try the `load` command' % name) reload_module_tree(bot, name) @@ -66,7 +66,7 @@ def reload_module_tree(bot, name, seen=None, silent=False): old_callables = {} for obj_name, obj in iteritems(vars(old_module)): - if callable(obj): + if callable(obj) and '.' not in name: bot.unregister(obj) elif (type(obj) is ModuleType and obj.__name__.startswith(name + '.') and