diff --git a/bot.py b/bot.py index 5f3f88f..8fa73b5 100755 --- a/bot.py +++ b/bot.py @@ -76,12 +76,6 @@ class Fulvia(irc.IRCClient): A class with some basic interactions for the bot's sqlite3 databse. """ - self._callables = {} - """ - A dictionary containing all callable functions loaded from - modules. Keys are the functions name. - """ - self._hooks = [] """ A list containing all function names to be hooked with every message @@ -120,7 +114,6 @@ class Fulvia(irc.IRCClient): Find and load all of our modules. """ print(f"Loading modules...") - self._callables = {} self._hooks = [] self.commands = {} self._times = {} @@ -152,20 +145,11 @@ class Fulvia(irc.IRCClient): convenient table. """ if hasattr(func, 'commands'): - self._callables[func.__name__] = func for cmd in func.commands: - self.commands[cmd] = tools.Command(cmd) - self.commands[cmd]._func_name = func.__name__ - self.commands[cmd].priv = func.priv - self.commands[cmd].doc = func._docs - if cmd in func.aliases: - self.commands[cmd].canonical = False - aliases = [a for a in func.commands if a != cmd] - self.commands[cmd].aliases = aliases + self.commands[cmd] = func if func.hook: - self._callables[func.__name__] = func - self._hooks.append(func.__name__) + self._hooks.append(func) if func.rate or func.channel_rate or func.global_rate: self._times[func.__name__] = {} @@ -187,12 +171,10 @@ class Fulvia(irc.IRCClient): return if hasattr(func, 'commands'): - self._callables.pop(func.__name__) for command in func.commands: self.commands.pop(command) if func.hook: - self._callables.pop(func.__name__) self._hooks.remove(func.__name__) if func.rate or func.channel_rate or func.global_rate: @@ -268,19 +250,18 @@ class Fulvia(irc.IRCClient): line = "<" + opSym + nick + ">" + " " + message self.log(channel, line) - func_names = [] + funcs = [] if message.startswith(self.prefix) and message != self.prefix: - command, _, _ = message.partition(" ") + command = message.partition(" ")[0] command = command.replace(self.prefix, "", 1) cmd = self.commands.get(command) if not cmd: return - func_names.append(cmd._func_name) + funcs.append(cmd) - func_names += self._hooks + funcs += self._hooks - for func_name in func_names: - func = self._callables[func_name] + for func in funcs: trigger = Trigger(user, channel, message, "PRIVMSG", self.config) bot = FulviaWrapper(self, trigger) diff --git a/loader.py b/loader.py index 80ca9b9..0b3d39e 100755 --- a/loader.py +++ b/loader.py @@ -30,6 +30,7 @@ def unload_module(bot, name): bot.unregister_callable(obj) del old_module + delattr(sys.modules['modules'], name) del sys.modules[name] diff --git a/module.py b/module.py index 94246a5..c0ed17b 100755 --- a/module.py +++ b/module.py @@ -236,7 +236,7 @@ def example(ex_input, ex_output=None): def url_callback(url): """ - Decore a function with a callback to the URL module. + Decorate a function with a callback to the URL module. This URL will be added to the bot.url_callbacks dictionary in the bot's memory which the URL module will compare it's URL's against. If a key in diff --git a/modules/adalwulf__.py b/modules/adalwulf__.py index 5311a08..75f3eea 100644 --- a/modules/adalwulf__.py +++ b/modules/adalwulf__.py @@ -26,8 +26,6 @@ def new_bot_name(number): @user_joined(True) def adalwulf_(bot, trigger): """Renames adalwulf__.""" - print(True) - print(trigger.nick) if not trigger.nick.startswith('defaultnick'): return names = bot.channels[trigger.channel].users diff --git a/modules/reload.py b/modules/reload.py index 55d9790..7cc62d8 100755 --- a/modules/reload.py +++ b/modules/reload.py @@ -72,4 +72,4 @@ def f_unload(bot, trigger): return bot.msg(f"Module '{name}' not loaded, try the 'load' command.") loader.unload_module(bot, name) - bot.msg(f"Module '{name}' unloaded.") \ No newline at end of file + bot.msg(f"Module '{name}' unloaded.") diff --git a/tools/__init__.py b/tools/__init__.py index 145ef86..05da197 100755 --- a/tools/__init__.py +++ b/tools/__init__.py @@ -187,20 +187,6 @@ class Channel(object): self.privileges[new] = self.privileges.pop(old) -class Command(): - """ - A representation of a command and associated documentation and other - atributes. - """ - def __init__(self, name): - self.name = name - self._func_name = "" - self.priv = 0 - self.doc = None - self.canonical = True - self.aliases = [] - - def configureHostMask(mask): """ Returns a valid hostmask based on user input.