Karma: ignore trailing chars, spaces, tabs (#1579)

Signed-off-by: Pratyush Desai <pratyush.desai@liberta.casa>
This commit is contained in:
Pratyush Desai 2024-06-28 07:35:11 +05:30 committed by GitHub
parent 7ccaeb088a
commit 01cdfee53e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -272,7 +272,7 @@ class Karma(callbacks.Plugin):
karma = ''
for s in inc:
if thing.endswith(s):
thing = thing[:-len(s)]
thing = thing[:-len(s)].rstrip(",:\t ")
# Don't reply if the target isn't a nick
if onlynicks and thing.lower() not in map(ircutils.toLower,
irc.state.channels[channel].users):
@ -286,7 +286,7 @@ class Karma(callbacks.Plugin):
karma = self.db.get(channel, self._normalizeThing(thing))
for s in dec:
if thing.endswith(s):
thing = thing[:-len(s)]
thing = thing[:-len(s)].rstrip(",:\t ")
if onlynicks and thing.lower() not in map(ircutils.toLower,
irc.state.channels[channel].users):
return

View File

@ -60,6 +60,10 @@ class KarmaTestCase(ChannelPluginTestCase):
'Karma for [\'"]moo[\'"].*increased 1.*total.*1')
self.assertRegexp('karma MoO',
'Karma for [\'"]MoO[\'"].*increased 1.*total.*1')
# Test trailing characters and spaces
self.assertNoResponse('baz, ++', 2)
self.assertRegexp('karma baz',
'Karma for [\'"]baz[\'"].*increased 1.*total.*1')
def testKarmaRankingDisplayConfigurable(self):
try: