Bugfix for nick.atEnd taking precedence over prefixChars.

This commit is contained in:
Jeremy Fincher 2004-10-23 19:26:53 +00:00
parent 1745c6d144
commit d20381336a
2 changed files with 16 additions and 5 deletions

View File

@ -83,6 +83,8 @@ def addressed(nick, msg, prefixChars=None, nicks=None,
assert msg.command == 'PRIVMSG'
(target, payload) = msg.args
if not payload:
return ''
if prefixChars is None:
prefixChars = get(conf.supybot.reply.whenAddressedBy.chars)
if whenAddressedByNick is None:
@ -92,6 +94,12 @@ def addressed(nick, msg, prefixChars=None, nicks=None,
whenAddressedByNickAtEnd = get(r)
if prefixStrings is None:
prefixStrings = get(conf.supybot.reply.whenAddressedBy.strings)
# We have to check this before nicks -- try "@google supybot" with supybot
# and whenAddressedBy.nick.atEnd on to see why.
if any(payload.startswith, prefixStrings):
return stripPrefixStrings(payload)
elif payload[0] in prefixChars:
return payload[1:].strip()
if nicks is None:
nicks = get(conf.supybot.reply.whenAddressedBy.nicks)
nicks = map(ircutils.toLower, nicks)
@ -128,11 +136,7 @@ def addressed(nick, msg, prefixChars=None, nicks=None,
# There should be some separator between the nick and the
# previous alphanumeric character.
return possiblePayload
if payload and any(payload.startswith, prefixStrings):
return stripPrefixStrings(payload)
elif payload and payload[0] in prefixChars:
return payload[1:].strip()
elif conf.supybot.reply.whenNotAddressed():
if conf.supybot.reply.whenNotAddressed():
return payload
else:
return ''

View File

@ -212,6 +212,13 @@ class FunctionsTestCase(SupyTestCase):
self.assertEqual(callbacks.addressed('bar', msg,
whenAddressedByNickAtEnd=True),
'baz')
def testAddressedPrefixCharsTakePrecedenceOverNickAtEnd(self):
msg = ircmsgs.privmsg('#foo', '@echo foo')
self.assertEqual(callbacks.addressed('foo', msg,
whenAddressedByNickAtEnd=True,
prefixChars='@'),
'echo foo')
def testReply(self):