clean up karma module

This commit is contained in:
Mike Bloy 2010-10-24 09:36:15 -05:00
parent b1fe99d5a2
commit e453778791
1 changed files with 59 additions and 54 deletions

View File

@ -46,10 +46,18 @@ class Karma(Module):
self.queryre = re.compile(querypattern)
def do(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
"""look for karma strings."""
"""look for karma strings at the start of messages"""
if (self.karmare.match(what)):
self.handle_karma_change(connection, nick, userhost, replypath, what)
elif (self.queryre.match(what)):
self.handle_karma_query(connection, nick, userhost, replypath, what)
def handle_karma_change(self, connection, nick, userhost, replypath, what):
"""
handle the karma change and storage.
"""
match = self.karmare.match(what)
key = match.group(1)
value = match.group(2)
@ -90,10 +98,8 @@ class Karma(Module):
reply = "karma change for '" + key + "' (" + str(value) + ") by " + nick
self.reply(connection, replypath, reply)
return
if (self.queryre.match(what)):
# tell about karma
def handle_karma_query(self, connection, nick, userhost, replypath, what):
match = self.queryre.match(what)
key = match.group(1)
@ -107,7 +113,6 @@ class Karma(Module):
karma.close()
self.reply(connection, replypath, reply)
return
if __name__ == "__main__":
print "Hello World"