mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-22 10:29:25 +01:00
Ignore trailing whitespace when addressing the bot by nick at end (#1563)
This commit is contained in:
parent
5ccc035021
commit
ec9e731fa5
@ -136,8 +136,8 @@ def _addressed(irc, msg, prefixChars=None, nicks=None,
|
||||
continue
|
||||
except ValueError: # split didn't work.
|
||||
continue
|
||||
elif whenAddressedByNickAtEnd and lowered.endswith(nick):
|
||||
rest = payload[:-len(nick)]
|
||||
elif whenAddressedByNickAtEnd and lowered.rstrip().endswith(nick):
|
||||
rest = payload.rstrip()[:-len(nick)]
|
||||
possiblePayload = rest.rstrip(' \t,;')
|
||||
if possiblePayload != rest:
|
||||
# There should be some separator between the nick and the
|
||||
|
@ -272,6 +272,12 @@ class FunctionsTestCase(SupyTestCase):
|
||||
self.assertEqual(callbacks.addressed('bar', msg,
|
||||
whenAddressedByNickAtEnd=True),
|
||||
'baz')
|
||||
# Test that it still works with trailing whitespace:
|
||||
msg = ircmsgs.privmsg('#foo', 'baz, bar \t')
|
||||
self.assertEqual(callbacks.addressed('bar', msg,
|
||||
whenAddressedByNickAtEnd=True),
|
||||
'baz')
|
||||
|
||||
|
||||
def testAddressedPrefixCharsTakePrecedenceOverNickAtEnd(self):
|
||||
irc = getTestIrc()
|
||||
|
Loading…
Reference in New Issue
Block a user