allow karma to happen anywhere in a sentence (rather than just the start), switch to re.search() throughout
This commit is contained in:
parent
b7f2b9bd0e
commit
694f051994
@ -34,7 +34,7 @@ class Karma(Module):
|
||||
Module.__init__(self, config, server, modlist)
|
||||
|
||||
pattern = "(?:([a-zA-Z0-9_'.,]+)|\(([a-zA-Z0-9_'., ]+)\))"
|
||||
karmapattern = '^' + pattern + '(\+\+|--)'
|
||||
karmapattern = pattern + '(\+\+|--)'
|
||||
querypattern = '^rank\s+(.*)'
|
||||
|
||||
self.karmare = re.compile(karmapattern)
|
||||
@ -75,16 +75,16 @@ class Karma(Module):
|
||||
def do(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
|
||||
"""look for karma strings at the start of messages"""
|
||||
|
||||
if (self.karmare.match(what)):
|
||||
if (self.karmare.search(what)):
|
||||
return self.handle_karma_change(connection, nick, userhost, replypath, what)
|
||||
elif (self.queryre.match(what)):
|
||||
elif (self.queryre.search(what)):
|
||||
return 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)
|
||||
match = self.karmare.search(what)
|
||||
key = match.group(1) if match.group(1) else match.group(2)
|
||||
value = match.group(3)
|
||||
if (value == '++'):
|
||||
@ -105,7 +105,7 @@ class Karma(Module):
|
||||
return self.reply(connection, replypath, "sqlite error: " + str(e))
|
||||
|
||||
def handle_karma_query(self, connection, nick, userhost, replypath, what):
|
||||
match = self.queryre.match(what)
|
||||
match = self.queryre.search(what)
|
||||
key = match.group(1)
|
||||
|
||||
conn = self.get_db()
|
||||
|
Loading…
Reference in New Issue
Block a user