mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 06:49:24 +01:00
Add support for multi-word karmas
This commit is contained in:
parent
c77daeac5c
commit
30d36aae1f
@ -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):
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user