diff --git a/ChangeLog b/ChangeLog index 07a3b3da7..3d3b18e3a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ + * Removed supybot.reply.withPrivateNotice and split it into two + separate configuration variables, supybot.reply.withNotice and + supybot.reply.inPrivate. + * Added supybot.log.stdout.wrap, to allow optional (defaulting to True) wrapping of stdout logs. diff --git a/src/callbacks.py b/src/callbacks.py index d75588314..38fba8e8a 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -127,34 +127,32 @@ def reply(msg, s, prefixName=True, private=None, notice=None, to=None, action=None): # Ok, let's make the target: target = ircutils.replyTo(msg) + if notice is None: + notice = conf.supybot.reply.withNotice() + if private is None: + private = conf.supybot.reply.inPrivate() if private: prefixName = False - if to is not None: - target = to - else: + if to is None: target = msg.nick - # XXX: User value. - if conf.supybot.reply.withNoticeWhenPrivate() and notice is None: - notice = True + else: + target = to + # XXX: User value for reply.withNoticeWhenPrivate. if to is None: to = msg.nick # Ok, now let's make the payload: s = ircutils.safeArgument(s) if not s and not action: s = 'Error: I tried to send you an empty message.' - # Let's may sure we don't do, "#channel: foo.". if prefixName and ircutils.isChannel(target): + # Let's may sure we don't do, "#channel: foo.". if not ircutils.isChannel(to): s = '%s: %s' % (to, s) # And now, let's decide whether it's a PRIVMSG or a NOTICE. msgmaker = ircmsgs.privmsg if notice: msgmaker = ircmsgs.notice - if conf.supybot.reply.withPrivateNotice(): - if private is None: - target = msg.nick - if notice is None: - msgmaker = ircmsgs.notice + # We don't use elif here because actions can't be sent as NOTICEs. if action: msgmaker = ircmsgs.action # Finally, we'll return the actual message. diff --git a/test/test_callbacks.py b/test/test_callbacks.py index 9ec4cc198..caa64a88b 100644 --- a/test/test_callbacks.py +++ b/test/test_callbacks.py @@ -458,9 +458,11 @@ class WithPrivateNoticeTestCase(ChannelPluginTestCase): self.failIf(m.command == 'NOTICE') self.failUnless(ircutils.isChannel(m.args[0])) # Check abnormal behavior. - original = conf.supybot.reply.withPrivateNotice() + originalInPrivate = conf.supybot.reply.inPrivate() + originalWithNotice = conf.supybot.reply.withNotice() try: - conf.supybot.reply.withPrivateNotice.setValue(True) + conf.supybot.reply.inPrivate.setValue(True) + conf.supybot.reply.withNotice.setValue(True) m = self.assertNotError('normal') self.failUnless(m.command == 'NOTICE') self.failIf(ircutils.isChannel(m.args[0])) @@ -468,7 +470,8 @@ class WithPrivateNoticeTestCase(ChannelPluginTestCase): self.failIf(m.command == 'NOTICE') self.failUnless(ircutils.isChannel(m.args[0])) finally: - conf.supybot.reply.withPrivateNotice.setValue(original) + conf.supybot.reply.inPrivate.setValue(originalInPrivate) + conf.supybot.reply.withNotice.setValue(originalWithNotice)