mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 12:49:24 +01:00
irclib: Fix target computation
It mistakenly used the bot's nick as target when the message is in private, so 'more' after a private message always answered the user did not send a command before (because said command was attributed to the bot)
This commit is contained in:
parent
710d16f301
commit
e59e0f6908
@ -32,6 +32,35 @@ import re
|
|||||||
|
|
||||||
from supybot.test import *
|
from supybot.test import *
|
||||||
|
|
||||||
|
|
||||||
|
class MiscTestCase(PluginTestCase):
|
||||||
|
plugins = ('Misc', 'Utilities')
|
||||||
|
def testMore(self):
|
||||||
|
newprefix = 'fooo!bar@baaaaaaaaaaaaaaz'
|
||||||
|
|
||||||
|
# just for the sale of filling irc.state.nicksToHostmasks:
|
||||||
|
self.irc.feedMsg(ircmsgs.IrcMsg(command='CHGHOST', args=(self.nick, 'baz'),
|
||||||
|
prefix=self.prefix))
|
||||||
|
self.irc.feedMsg(ircmsgs.IrcMsg(command='CHGHOST', args=('foo', 'baz'),
|
||||||
|
prefix='foo!bar@oldbaz'))
|
||||||
|
|
||||||
|
self.assertResponse('echo %s' % ('abc '*400),
|
||||||
|
'abc '*112 + ' \x02(3 more messages)\x02',
|
||||||
|
frm=newprefix)
|
||||||
|
m = self.assertResponse('more',
|
||||||
|
'abc '*112 + ' \x02(2 more messages)\x02',
|
||||||
|
frm=newprefix)
|
||||||
|
self.assertResponse('more',
|
||||||
|
'abc '*112 + ' \x02(1 more message)\x02',
|
||||||
|
frm=newprefix)
|
||||||
|
self.assertResponse('more',
|
||||||
|
' '.join(['abc']*(400-112*3)),
|
||||||
|
frm=newprefix)
|
||||||
|
self.assertResponse('more',
|
||||||
|
"Error: That's all, there is no more.",
|
||||||
|
frm=newprefix)
|
||||||
|
|
||||||
|
|
||||||
class MiscTestCase(ChannelPluginTestCase):
|
class MiscTestCase(ChannelPluginTestCase):
|
||||||
plugins = ('Misc', 'Utilities', 'Anonymous', 'Plugin',
|
plugins = ('Misc', 'Utilities', 'Anonymous', 'Plugin',
|
||||||
'Channel', 'Dict', 'User', 'String')
|
'Channel', 'Dict', 'User', 'String')
|
||||||
|
@ -511,7 +511,10 @@ class RichReplyMethods(object):
|
|||||||
# change the state of this Irc object.
|
# change the state of this Irc object.
|
||||||
if to is not None:
|
if to is not None:
|
||||||
self.to = self.to or to
|
self.to = self.to or to
|
||||||
target = self.private and self.to or self.msg.args[0]
|
if self.private or self.msg.channel is None:
|
||||||
|
target = self.msg.nick
|
||||||
|
else:
|
||||||
|
target = self.to or self.msg.args[0]
|
||||||
return target
|
return target
|
||||||
|
|
||||||
def replies(self, L, prefixer=None, joiner=None,
|
def replies(self, L, prefixer=None, joiner=None,
|
||||||
@ -703,11 +706,17 @@ class ReplyIrcProxy(RichReplyMethods):
|
|||||||
'Old code alert: there is no longer a "msg" argument to reply.'
|
'Old code alert: there is no longer a "msg" argument to reply.'
|
||||||
kwargs.pop('noLengthCheck', None)
|
kwargs.pop('noLengthCheck', None)
|
||||||
if 'target' not in kwargs:
|
if 'target' not in kwargs:
|
||||||
target = kwargs.get('private', False) and kwargs.get('to', None) \
|
# TODO: deduplicate this with _getTarget
|
||||||
or msg.args[0]
|
# TODO: it looks like 'target' is never in kwargs.
|
||||||
|
# (an old version of this code crashed when 'target' was
|
||||||
|
# not given, but no one complained). Remove the conditional?
|
||||||
|
if kwargs.get('private', False) or msg.channel is None:
|
||||||
|
kwargs['target'] = msg.nick
|
||||||
|
else:
|
||||||
|
kwargs['target'] = kwargs.get('to', None) or msg.args[0]
|
||||||
if 'prefixNick' not in kwargs:
|
if 'prefixNick' not in kwargs:
|
||||||
kwargs['prefixNick'] = self._defaultPrefixNick(msg)
|
kwargs['prefixNick'] = self._defaultPrefixNick(msg)
|
||||||
self._sendReply(s, target=target, msg=msg, **kwargs)
|
self._sendReply(s, msg=msg, **kwargs)
|
||||||
|
|
||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
return getattr(self.irc, attr)
|
return getattr(self.irc, attr)
|
||||||
|
Loading…
Reference in New Issue
Block a user