diff --git a/bot.py b/bot.py index 6a45d3f..6b77d31 100755 --- a/bot.py +++ b/bot.py @@ -203,7 +203,7 @@ class Fulvia(irc.IRCClient): or users alike. """ func_names = [] - if message.startswith(self.prefix): + if message.startswith(self.prefix) and message != self.prefix: command, _, _ = message.partition(" ") command = command.replace(self.prefix, "", 1) func_name = self.commands.get(command)._func_name diff --git a/module.py b/module.py index 50cc569..8ca17a9 100755 --- a/module.py +++ b/module.py @@ -154,13 +154,17 @@ def require_privilege(level, message=None): user does not have the privilege, `message` will be said if given. If it is a private message, no checking will be done. """ + def add_attribute(function): + function.priv = level + return add_attribute + def actual_decorator(function): @functools.wraps(function) def guarded(bot, trigger, *args, **kwargs): # If this is a privmsg, ignore privilege requirements if trigger.is_privmsg or trigger.admin: return function(bot, trigger, *args, **kwargs) - channel_privs = bot.privileges[trigger.channel] + channel_privs = bot.channels[trigger.channel].privileges allowed = channel_privs.get(trigger.nick, 0) >= level if not allowed: if message and not callable(message): @@ -168,7 +172,7 @@ def require_privilege(level, message=None): else: return function(bot, trigger, *args, **kwargs) return guarded - return actual_decorator + return add_attribute(actual_decorator) def require_admin(message=None):