From 1dce7ea94bf35296dc0cf881597d5e28070a17ce Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Thu, 9 Aug 2012 22:17:33 -0400 Subject: [PATCH] Fixes and cleanup. --- earwigbot/commands/access.py | 8 ++++---- earwigbot/irc/data.py | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/earwigbot/commands/access.py b/earwigbot/commands/access.py index d0c8837..1132348 100644 --- a/earwigbot/commands/access.py +++ b/earwigbot/commands/access.py @@ -59,9 +59,9 @@ class Access(Command): def do_list(self, data, permdb): if len(data.args) > 1: if data.args[1] in ["owner", "owners"]: - name, rules = "owners", permdb.data.get(permdb.OWNERS) + name, rules = "owners", permdb.data.get(permdb.OWNER) elif data.args[1] in ["admin", "admins"]: - name, rules = "admins", permdb.data.get(permdb.ADMINS) + name, rules = "admins", permdb.data.get(permdb.ADMIN) else: msg = "Unknown access level \x0302{0}\x0F." self.reply(data, msg.format(data.args[1])) @@ -72,8 +72,8 @@ class Access(Command): msg = "No bot {0}.".format(name) self.reply(data, msg) else: - owners = len(permdb.data.get(permdb.OWNERS, [])) - admins = len(permdb.data.get(permdb.ADMINS, [])) + owners = len(permdb.data.get(permdb.OWNER, [])) + admins = len(permdb.data.get(permdb.ADMIN, [])) msg = "There are {0} bot owners and {1} bot admins. Use '!{2} list owners' or '!{2} list admins' for details." self.reply(data, msg.format(owners, admins, data.command)) diff --git a/earwigbot/irc/data.py b/earwigbot/irc/data.py index d42ed92..2cf2dc8 100644 --- a/earwigbot/irc/data.py +++ b/earwigbot/irc/data.py @@ -50,7 +50,7 @@ class Data(object): def _parse(self, msgtype): """Parse a line from IRC into its components as instance attributes.""" - sender = re.findall(":(.*?)!(.*?)@(.*?)\Z", self.line[0])[0] + sender = re.findall(r":(.*?)!(.*?)@(.*?)\Z", self.line[0])[0] self._nick, self._ident, self._host = sender self._chan = self.line[2] @@ -84,7 +84,8 @@ class Data(object): self._is_command = True self._trigger = self.command[0] self._command = self.command[1:] # Strip the "!" or "." - elif re.match(r"{0}\W*?$".format(self.my_nick), self.command, re.U): + elif re.match(r"{0}\W*?$".format(re.escape(self.my_nick)), + self.command, re.U): # e.g. "EarwigBot, command arg1 arg2" self._is_command = True self._trigger = self.my_nick @@ -110,7 +111,7 @@ class Data(object): """ for arg in self.args: try: - key, value = re.findall("^(.*?)\=(.*?)$", arg)[0] + key, value = re.findall(r"^(.*?)\=(.*?)$", arg)[0] except IndexError: continue if key and value: