From 3aedb305f98369c1bde64d2dd09c1b2ca214f8c7 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Mon, 30 Aug 2004 04:35:51 +0000 Subject: [PATCH] Fix for possible bugz0r with reply.withNoticeWhenPrivate. --- src/callbacks.py | 4 +++- test/test_callbacks.py | 14 +++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/callbacks.py b/src/callbacks.py index 5ec7dbb77..ad5d4c68b 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -163,7 +163,9 @@ def reply(msg, s, prefixName=True, private=None, target = to # XXX: User value for reply.withNoticeWhenPrivate. if conf.supybot.reply.withNoticeWhenPrivate(): # global, no getConfig. - notice = True + if not ircutils.isChannel(target): + # to=channel, private=True (see RSS for an example) + notice = True if to is None: to = msg.nick # Ok, now let's make the payload: diff --git a/test/test_callbacks.py b/test/test_callbacks.py index 4bfdd1043..97d8cbb5f 100644 --- a/test/test_callbacks.py +++ b/test/test_callbacks.py @@ -443,7 +443,7 @@ class RichReplyMethodsTestCase(PluginTestCase): class WithPrivateNoticeTestCase(ChannelPluginTestCase): - plugins = () + plugins = ('Utilities',) class WithPrivateNotice(callbacks.Privmsg): def normal(self, irc, msg, args): irc.reply('should be with private notice') @@ -489,6 +489,18 @@ class WithPrivateNoticeTestCase(ChannelPluginTestCase): finally: conf.supybot.reply.withNoticeWhenPrivate.setValue(orig) + def testWithNoticeWhenPrivateNotChannel(self): + original = conf.supybot.reply.withNoticeWhenPrivate() + try: + conf.supybot.reply.withNoticeWhenPrivate.setValue(True) + m = self.assertNotError("eval irc.reply('y',to='x',private=True)") + self.failUnless(m.command == 'NOTICE') + m = self.getMsg(' ') + m = self.assertNotError("eval irc.reply('y',to='#x',private=True)") + self.failIf(m.command == 'NOTICE') + finally: + conf.supybot.reply.withNoticeWhenPrivate.setValue(original) + # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: