mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 20:59:27 +01:00
Bugfix for nick.atEnd taking precedence over prefixChars.
This commit is contained in:
parent
1745c6d144
commit
d20381336a
@ -83,6 +83,8 @@ def addressed(nick, msg, prefixChars=None, nicks=None,
|
|||||||
|
|
||||||
assert msg.command == 'PRIVMSG'
|
assert msg.command == 'PRIVMSG'
|
||||||
(target, payload) = msg.args
|
(target, payload) = msg.args
|
||||||
|
if not payload:
|
||||||
|
return ''
|
||||||
if prefixChars is None:
|
if prefixChars is None:
|
||||||
prefixChars = get(conf.supybot.reply.whenAddressedBy.chars)
|
prefixChars = get(conf.supybot.reply.whenAddressedBy.chars)
|
||||||
if whenAddressedByNick is None:
|
if whenAddressedByNick is None:
|
||||||
@ -92,6 +94,12 @@ def addressed(nick, msg, prefixChars=None, nicks=None,
|
|||||||
whenAddressedByNickAtEnd = get(r)
|
whenAddressedByNickAtEnd = get(r)
|
||||||
if prefixStrings is None:
|
if prefixStrings is None:
|
||||||
prefixStrings = get(conf.supybot.reply.whenAddressedBy.strings)
|
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:
|
if nicks is None:
|
||||||
nicks = get(conf.supybot.reply.whenAddressedBy.nicks)
|
nicks = get(conf.supybot.reply.whenAddressedBy.nicks)
|
||||||
nicks = map(ircutils.toLower, 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
|
# There should be some separator between the nick and the
|
||||||
# previous alphanumeric character.
|
# previous alphanumeric character.
|
||||||
return possiblePayload
|
return possiblePayload
|
||||||
if payload and any(payload.startswith, prefixStrings):
|
if conf.supybot.reply.whenNotAddressed():
|
||||||
return stripPrefixStrings(payload)
|
|
||||||
elif payload and payload[0] in prefixChars:
|
|
||||||
return payload[1:].strip()
|
|
||||||
elif conf.supybot.reply.whenNotAddressed():
|
|
||||||
return payload
|
return payload
|
||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
|
@ -213,6 +213,13 @@ class FunctionsTestCase(SupyTestCase):
|
|||||||
whenAddressedByNickAtEnd=True),
|
whenAddressedByNickAtEnd=True),
|
||||||
'baz')
|
'baz')
|
||||||
|
|
||||||
|
def testAddressedPrefixCharsTakePrecedenceOverNickAtEnd(self):
|
||||||
|
msg = ircmsgs.privmsg('#foo', '@echo foo')
|
||||||
|
self.assertEqual(callbacks.addressed('foo', msg,
|
||||||
|
whenAddressedByNickAtEnd=True,
|
||||||
|
prefixChars='@'),
|
||||||
|
'echo foo')
|
||||||
|
|
||||||
|
|
||||||
def testReply(self):
|
def testReply(self):
|
||||||
prefix = 'foo!bar@baz'
|
prefix = 'foo!bar@baz'
|
||||||
|
Loading…
Reference in New Issue
Block a user