Add support for multi-word karmas

This commit is contained in:
James Vega 2004-09-07 20:28:24 +00:00
parent c77daeac5c
commit 30d36aae1f
3 changed files with 15 additions and 11 deletions

View File

@ -494,7 +494,7 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
return s
_forceRe = re.compile(r'^no[,: -]+', re.I)
_karmaRe = re.compile(r'^\S+(?:\+\+|--)(?:\s+)?$')
_karmaRe = re.compile(r'^(?:\S+|\(.+\))(?:\+\+|--)(?:\s+)?$')
def doPrivmsg(self, irc, msg):
try:
if ircmsgs.isCtcp(msg):

View File

@ -295,11 +295,11 @@ class Karma(callbacks.PrivmsgCommandAndRegexp):
clear = privmsgs.checkChannelCapability(clear, 'op')
def increaseKarma(self, irc, msg, match):
r"^(\S+)\+\+\s*$"
r"^(\S+|\(.+\))\+\+\s*$"
channel = msg.args[0]
if not ircutils.isChannel(channel):
return
name = match.group(1)
name = match.group(1).strip('()')
if not self.registryValue('allowSelfRating', msg.args[0]):
if ircutils.strEqual(name, msg.nick):
return
@ -308,11 +308,11 @@ class Karma(callbacks.PrivmsgCommandAndRegexp):
irc.replySuccess()
def decreaseKarma(self, irc, msg, match):
r"^(\S+)--\s*$"
r"^(\S+|\(.+\))--\s*$"
channel = msg.args[0]
if not ircutils.isChannel(channel):
return
name = match.group(1)
name = match.group(1).strip('()')
if not self.registryValue('allowSelfRating', msg.args[0]):
if ircutils.strEqual(name, msg.nick):
return

View File

@ -190,6 +190,10 @@ if sqlite is not None:
self.assertNotError('load Infobot')
self.assertNoResponse('foo++')
def testMultiWordKarma(self):
self.assertNoResponse('(foo bar)++', 1)
self.assertRegexp('karma "foo bar"', '1')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: