This commit is contained in:
Jeremy Fincher 2003-10-08 22:38:27 +00:00
parent e903411ef3
commit b0f5674f91
2 changed files with 5 additions and 3 deletions

View File

@ -67,7 +67,8 @@ def addressed(nick, msg):
"""If msg is addressed to 'name', returns the portion after the address. """If msg is addressed to 'name', returns the portion after the address.
Otherwise returns the empty string. Otherwise returns the empty string.
""" """
if msg.args[0] == nick: nick = ircutils.toLower(nick)
if ircutils.nickEqual(msg.args[0], nick):
if msg.args[1][0] in conf.prefixChars: if msg.args[1][0] in conf.prefixChars:
return msg.args[1][1:].strip() return msg.args[1][1:].strip()
else: else:
@ -77,7 +78,7 @@ def addressed(nick, msg):
(maybeNick, rest) = msg.args[1].split(None, 1) (maybeNick, rest) = msg.args[1].split(None, 1)
while not ircutils.isNick(maybeNick): while not ircutils.isNick(maybeNick):
maybeNick = maybeNick[:-1] maybeNick = maybeNick[:-1]
if maybeNick == nick: if ircutils.nickEqual(maybeNick, nick):
return rest return rest
else: else:
return '' return ''

View File

@ -116,7 +116,8 @@ class FunctionsTestCase(unittest.TestCase):
nick = 'supybot' nick = 'supybot'
conf.prefixChars = '~!@' conf.prefixChars = '~!@'
inChannel = ['~foo', '@foo', '!foo', inChannel = ['~foo', '@foo', '!foo',
'%s: foo' % nick, '%s foo' % nick] '%s: foo' % nick, '%s foo' % nick,
'%s: foo' % nick.capitalize(), '%s: foo' % nick.upper()]
inChannel = [ircmsgs.privmsg('#foo', s) for s in inChannel] inChannel = [ircmsgs.privmsg('#foo', s) for s in inChannel]
badmsg = ircmsgs.privmsg('#foo', '%s:foo' % nick) badmsg = ircmsgs.privmsg('#foo', '%s:foo' % nick)
self.failIf(callbacks.addressed(nick, badmsg)) self.failIf(callbacks.addressed(nick, badmsg))