Browse Source

Fixes and cleanup.

tags/v0.1^2
Ben Kurtovic 12 years ago
parent
commit
1dce7ea94b
2 changed files with 8 additions and 7 deletions
  1. +4
    -4
      earwigbot/commands/access.py
  2. +4
    -3
      earwigbot/irc/data.py

+ 4
- 4
earwigbot/commands/access.py View File

@@ -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))



+ 4
- 3
earwigbot/irc/data.py View File

@@ -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:


Loading…
Cancel
Save