Skip to content

Commit

Permalink
Karma: ignore trailing chars, spaces, tabs (#1579)
Browse files Browse the repository at this point in the history
Signed-off-by: Pratyush Desai <pratyush.desai@liberta.casa>
  • Loading branch information
prdes authored Jun 28, 2024
1 parent 7ccaeb0 commit 01cdfee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugins/Karma/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def _doKarma(self, irc, msg, channel, thing):
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):
Expand All @@ -286,7 +286,7 @@ def _doKarma(self, irc, msg, channel, thing):
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
Expand Down
4 changes: 4 additions & 0 deletions plugins/Karma/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def testKarma(self):
'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:
Expand Down

0 comments on commit 01cdfee

Please sign in to comment.