Made increase/decrease karma stuff work more like moobot (i.e., require a prefixchar and disallow spaces)

This commit is contained in:
Jeremy Fincher 2003-08-25 07:24:11 +00:00
parent d73abebb36
commit eb7b696ce9

View File

@ -319,24 +319,20 @@ class ChannelDB(callbacks.PrivmsgCommandAndRegexp, ChannelDBHandler):
irc.reply(msg, s) irc.reply(msg, s)
def increaseKarma(self, irc, msg, match): def increaseKarma(self, irc, msg, match):
r"^(.)(.*)\+\+$" r"^(.)(\S+)\+\+$"
(first, rest) = match.groups() (first, name) = match.groups()
if first in conf.prefixChars: if first not in conf.prefixChars:
name = rest return
else:
name = first + rest
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"^(.)(.*)--$" r"^(.)(\S+)--$"
(first, rest) = match.groups() (first, name) = match.groups()
if first in conf.prefixChars: if first not in conf.prefixChars:
name = rest return
else:
name = first + rest
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)