Converted karma stuff to use addressedRegexps.

This commit is contained in:
Jeremy Fincher 2003-10-09 05:08:18 +00:00
parent aa7efcbad9
commit 7b28caba1b

View File

@ -77,7 +77,7 @@ smileyre = re.compile('|'.join(map(re.escape, smileys)))
frownre = re.compile('|'.join(map(re.escape, frowns))) frownre = re.compile('|'.join(map(re.escape, frowns)))
class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp): class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp):
regexps = sets.Set(['increaseKarma', 'decreaseKarma']) addressedRegexps = sets.Set(['increaseKarma', 'decreaseKarma'])
def __init__(self): def __init__(self):
plugins.ChannelDBHandler.__init__(self) plugins.ChannelDBHandler.__init__(self)
callbacks.PrivmsgCommandAndRegexp.__init__(self) callbacks.PrivmsgCommandAndRegexp.__init__(self)
@ -365,20 +365,16 @@ class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp):
irc.reply(msg, s) irc.reply(msg, s)
def increaseKarma(self, irc, msg, match): def increaseKarma(self, irc, msg, match):
r"^(.)(\S+)\+\+$" r"^(\S+)\+\+$"
(first, name) = match.groups() name = match.group(1)
if first not in conf.prefixChars:
return
db = self.getDb(msg.args[0]) db = self.getDb(msg.args[0])
cursor = db.cursor() cursor = db.cursor()
cursor.execute("""INSERT INTO karma VALUES (NULL, %s, 0, 0)""", name) cursor.execute("""INSERT INTO karma VALUES (NULL, %s, 0, 0)""", name)
cursor.execute("""UPDATE karma SET added=added+1 WHERE name=%s""",name) cursor.execute("""UPDATE karma SET added=added+1 WHERE name=%s""",name)
def decreaseKarma(self, irc, msg, match): def decreaseKarma(self, irc, msg, match):
r"^(.)(\S+)--$" r"^(\S+)--$"
(first, name) = match.groups() name = match.group(1)
if first not in conf.prefixChars:
return
db = self.getDb(msg.args[0]) db = self.getDb(msg.args[0])
cursor = db.cursor() cursor = db.cursor()
cursor.execute("""INSERT INTO karma VALUES (NULL, %s, 0, 0)""", name) cursor.execute("""INSERT INTO karma VALUES (NULL, %s, 0, 0)""", name)