Fixed bug in IrcObjectProxy{Regexp} where actions weren't targetted correctly based on the to/private arguments.

This commit is contained in:
Jeremy Fincher 2004-02-18 13:41:47 +00:00
parent 70ce38a979
commit 2747baf48a
2 changed files with 19 additions and 8 deletions

View File

@ -550,12 +550,11 @@ class IrcObjectProxy(RichReplyMethods):
self.irc.queueMsg(reply(msg, s, self.prefixName,
self.private, self.notice, self.to))
elif self.action:
if self.private:
target = msg.nick
else:
target = msg.args[0]
target = ircutils.replyTo(msg)
if self.to:
target = self.to
elif self.private:
target = msg.nick
self.irc.queueMsg(ircmsgs.action(target, s))
else:
s = ircutils.safeArgument(s)
@ -789,13 +788,18 @@ class IrcObjectProxyRegexp(RichReplyMethods):
def error(self, s, **kwargs):
self.reply('Error: ' + s, **kwargs)
def reply(self, s, action=False, **kwargs):
def reply(self, s, action=False, to=None, private=False, **kwargs):
assert not isinstance(s, ircmsgs.IrcMsg), \
'Old code alert: there is no longer a "msg" argument to reply.'
if action:
self.irc.queueMsg(ircmsgs.action(ircutils.replyTo(self.msg), s))
target = ircutils.replyTo(self.msg)
if to:
target = to
elif private:
target = msg.nick
self.irc.queueMsg(ircmsgs.action(target, s))
else:
self.irc.queueMsg(reply(self.msg, s, **kwargs))
self.irc.queueMsg(reply(self.msg,s,to=to,private=private,**kwargs))
def __getattr__(self, attr):
return getattr(self.irc, attr)

View File

@ -31,7 +31,7 @@
from testsupport import *
class MiscTestCase(ChannelPluginTestCase, PluginDocumentation):
class MiscTestCase(ChannelPluginTestCase):
plugins = ('Misc', 'Utilities', 'Gameknot', 'Ctcp', 'Dict', 'User')
def testAction(self):
self.assertAction('action moos', 'moos')
@ -218,6 +218,13 @@ class MiscTestCase(ChannelPluginTestCase, PluginDocumentation):
self.assertResponse('seconds 1w 1s', '604801')
class MiscNonChannelTestCase(PluginTestCase):
plugins = ('Misc',)
def testAction(self):
self.prefix = 'something!else@somewhere.else'
self.nick = 'something'
m = self.assertAction('action foo', 'foo')
self.failIf(m.args[0] == self.irc.nick)
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: