mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-16 15:39:21 +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
|
continue
|
||||||
except ValueError: # split didn't work.
|
except ValueError: # split didn't work.
|
||||||
continue
|
continue
|
||||||
elif whenAddressedByNickAtEnd and lowered.endswith(nick):
|
elif whenAddressedByNickAtEnd and lowered.rstrip().endswith(nick):
|
||||||
rest = payload[:-len(nick)]
|
rest = payload.rstrip()[:-len(nick)]
|
||||||
possiblePayload = rest.rstrip(' \t,;')
|
possiblePayload = rest.rstrip(' \t,;')
|
||||||
if possiblePayload != rest:
|
if possiblePayload != rest:
|
||||||
# There should be some separator between the nick and the
|
# There should be some separator between the nick and the
|
||||||
|
@ -272,6 +272,12 @@ class FunctionsTestCase(SupyTestCase):
|
|||||||
self.assertEqual(callbacks.addressed('bar', msg,
|
self.assertEqual(callbacks.addressed('bar', msg,
|
||||||
whenAddressedByNickAtEnd=True),
|
whenAddressedByNickAtEnd=True),
|
||||||
'baz')
|
'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):
|
def testAddressedPrefixCharsTakePrecedenceOverNickAtEnd(self):
|
||||||
irc = getTestIrc()
|
irc = getTestIrc()
|
||||||
|
Loading…
Reference in New Issue
Block a user