Karma: allow multiple karma expressions per line
This commit is contained in:
parent
c064f6ebe1
commit
e7a573bce1
@ -35,7 +35,7 @@ class Karma(Module):
|
||||
|
||||
Module.__init__(self, irc, config, server)
|
||||
|
||||
pattern = "(?:\((.+)\)|(\S+))"
|
||||
pattern = "(?:\((.+?)\)|(\S+))"
|
||||
karmapattern = pattern + '(\+\+|--|\+-|-\+)' + '(\s+|$)'
|
||||
querypattern = '^!rank\s+(.*)'
|
||||
reportpattern = '^!karma\s+report\s+(highest|lowest|positive|negative|top)'
|
||||
@ -102,19 +102,23 @@ class Karma(Module):
|
||||
"""
|
||||
handle the karma change and storage.
|
||||
"""
|
||||
match = self.karmare.search(what)
|
||||
key = match.group(1) if match.group(1) else match.group(2)
|
||||
value = match.group(3)
|
||||
if (value == '++'):
|
||||
return self.karma_modify(key, 1, nick, userhost)
|
||||
elif (value == '--'):
|
||||
return self.karma_modify(key, -1, nick, userhost)
|
||||
elif (value == '+-'):
|
||||
self.karma_modify(key, 1, nick, userhost)
|
||||
return self.karma_modify(key, -1, nick, userhost)
|
||||
elif (value == '-+'):
|
||||
self.karma_modify(key, -1, nick, userhost)
|
||||
return self.karma_modify(key, 1, nick, userhost)
|
||||
|
||||
if self.karmare.search(what):
|
||||
matches = self.karmare.findall(what)
|
||||
for match in matches:
|
||||
key = match[0] if match[0] else match[1]
|
||||
value = match[2]
|
||||
|
||||
if (value == '++'):
|
||||
self.karma_modify(key, 1, nick, userhost)
|
||||
elif (value == '--'):
|
||||
self.karma_modify(key, -1, nick, userhost)
|
||||
elif (value == '+-'):
|
||||
self.karma_modify(key, 1, nick, userhost)
|
||||
self.karma_modify(key, -1, nick, userhost)
|
||||
elif (value == '-+'):
|
||||
self.karma_modify(key, -1, nick, userhost)
|
||||
self.karma_modify(key, 1, nick, userhost)
|
||||
|
||||
def karma_modify(self, key, value, nick, userhost):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user