Merge branch 'master' of git.incorporeal.org:dr.botzo
This commit is contained in:
commit
97259eb6b3
@ -35,7 +35,7 @@ class Karma(Module):
|
|||||||
|
|
||||||
Module.__init__(self, irc, config, server)
|
Module.__init__(self, irc, config, server)
|
||||||
|
|
||||||
pattern = "(?:\((.+)\)|(\S+))"
|
pattern = "(?:\((.+?)\)|(\S+))"
|
||||||
karmapattern = pattern + '(\+\+|--|\+-|-\+)' + '(\s+|$)'
|
karmapattern = pattern + '(\+\+|--|\+-|-\+)' + '(\s+|$)'
|
||||||
querypattern = '^!rank\s+(.*)'
|
querypattern = '^!rank\s+(.*)'
|
||||||
reportpattern = '^!karma\s+report\s+(highest|lowest|positive|negative|top)'
|
reportpattern = '^!karma\s+report\s+(highest|lowest|positive|negative|top)'
|
||||||
@ -89,9 +89,11 @@ class Karma(Module):
|
|||||||
def do(self, connection, event, nick, userhost, what, admin_unlocked):
|
def do(self, connection, event, nick, userhost, what, admin_unlocked):
|
||||||
"""look for karma strings at the start of messages"""
|
"""look for karma strings at the start of messages"""
|
||||||
|
|
||||||
|
# don't return anything, do this attempt regardless
|
||||||
if (self.karmare.search(what)):
|
if (self.karmare.search(what)):
|
||||||
return self.reply(connection, event, self.handle_karma_change(connection, nick, userhost, what))
|
self.handle_karma_change(connection, nick, userhost, what)
|
||||||
elif (self.queryre.search(what)):
|
|
||||||
|
if (self.queryre.search(what)):
|
||||||
return self.reply(connection, event, self.handle_karma_query(connection, nick, userhost, what))
|
return self.reply(connection, event, self.handle_karma_query(connection, nick, userhost, what))
|
||||||
elif (self.statre.search(what)):
|
elif (self.statre.search(what)):
|
||||||
return self.reply(connection, event, self.handle_stat_query(connection, nick, userhost, what))
|
return self.reply(connection, event, self.handle_stat_query(connection, nick, userhost, what))
|
||||||
@ -102,19 +104,23 @@ class Karma(Module):
|
|||||||
"""
|
"""
|
||||||
handle the karma change and storage.
|
handle the karma change and storage.
|
||||||
"""
|
"""
|
||||||
match = self.karmare.search(what)
|
|
||||||
key = match.group(1) if match.group(1) else match.group(2)
|
if self.karmare.search(what):
|
||||||
value = match.group(3)
|
matches = self.karmare.findall(what)
|
||||||
|
for match in matches:
|
||||||
|
key = match[0] if match[0] else match[1]
|
||||||
|
value = match[2]
|
||||||
|
|
||||||
if (value == '++'):
|
if (value == '++'):
|
||||||
return self.karma_modify(key, 1, nick, userhost)
|
self.karma_modify(key, 1, nick, userhost)
|
||||||
elif (value == '--'):
|
elif (value == '--'):
|
||||||
return self.karma_modify(key, -1, nick, userhost)
|
self.karma_modify(key, -1, nick, userhost)
|
||||||
elif (value == '+-'):
|
elif (value == '+-'):
|
||||||
self.karma_modify(key, 1, nick, userhost)
|
self.karma_modify(key, 1, nick, userhost)
|
||||||
return self.karma_modify(key, -1, nick, userhost)
|
self.karma_modify(key, -1, nick, userhost)
|
||||||
elif (value == '-+'):
|
elif (value == '-+'):
|
||||||
self.karma_modify(key, -1, nick, userhost)
|
self.karma_modify(key, -1, nick, userhost)
|
||||||
return self.karma_modify(key, 1, nick, userhost)
|
self.karma_modify(key, 1, nick, userhost)
|
||||||
|
|
||||||
def karma_modify(self, key, value, nick, userhost):
|
def karma_modify(self, key, value, nick, userhost):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user