Removed reply.withPrivate notice, replaced with two separate variables, reply.withNotice and reply.inPrivate.

This commit is contained in:
Jeremy Fincher 2004-08-08 17:34:59 +00:00
parent efc34691bf
commit 3fa477dc90
3 changed files with 20 additions and 15 deletions

View File

@ -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 * Added supybot.log.stdout.wrap, to allow optional (defaulting to
True) wrapping of stdout logs. True) wrapping of stdout logs.

View File

@ -127,34 +127,32 @@ def reply(msg, s, prefixName=True, private=None,
notice=None, to=None, action=None): notice=None, to=None, action=None):
# Ok, let's make the target: # Ok, let's make the target:
target = ircutils.replyTo(msg) target = ircutils.replyTo(msg)
if notice is None:
notice = conf.supybot.reply.withNotice()
if private is None:
private = conf.supybot.reply.inPrivate()
if private: if private:
prefixName = False prefixName = False
if to is not None: if to is None:
target = to
else:
target = msg.nick target = msg.nick
# XXX: User value. else:
if conf.supybot.reply.withNoticeWhenPrivate() and notice is None: target = to
notice = True # XXX: User value for reply.withNoticeWhenPrivate.
if to is None: if to is None:
to = msg.nick to = msg.nick
# Ok, now let's make the payload: # Ok, now let's make the payload:
s = ircutils.safeArgument(s) s = ircutils.safeArgument(s)
if not s and not action: if not s and not action:
s = 'Error: I tried to send you an empty message.' 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): if prefixName and ircutils.isChannel(target):
# Let's may sure we don't do, "#channel: foo.".
if not ircutils.isChannel(to): if not ircutils.isChannel(to):
s = '%s: %s' % (to, s) s = '%s: %s' % (to, s)
# And now, let's decide whether it's a PRIVMSG or a NOTICE. # And now, let's decide whether it's a PRIVMSG or a NOTICE.
msgmaker = ircmsgs.privmsg msgmaker = ircmsgs.privmsg
if notice: if notice:
msgmaker = ircmsgs.notice msgmaker = ircmsgs.notice
if conf.supybot.reply.withPrivateNotice(): # We don't use elif here because actions can't be sent as NOTICEs.
if private is None:
target = msg.nick
if notice is None:
msgmaker = ircmsgs.notice
if action: if action:
msgmaker = ircmsgs.action msgmaker = ircmsgs.action
# Finally, we'll return the actual message. # Finally, we'll return the actual message.

View File

@ -458,9 +458,11 @@ class WithPrivateNoticeTestCase(ChannelPluginTestCase):
self.failIf(m.command == 'NOTICE') self.failIf(m.command == 'NOTICE')
self.failUnless(ircutils.isChannel(m.args[0])) self.failUnless(ircutils.isChannel(m.args[0]))
# Check abnormal behavior. # Check abnormal behavior.
original = conf.supybot.reply.withPrivateNotice() originalInPrivate = conf.supybot.reply.inPrivate()
originalWithNotice = conf.supybot.reply.withNotice()
try: try:
conf.supybot.reply.withPrivateNotice.setValue(True) conf.supybot.reply.inPrivate.setValue(True)
conf.supybot.reply.withNotice.setValue(True)
m = self.assertNotError('normal') m = self.assertNotError('normal')
self.failUnless(m.command == 'NOTICE') self.failUnless(m.command == 'NOTICE')
self.failIf(ircutils.isChannel(m.args[0])) self.failIf(ircutils.isChannel(m.args[0]))
@ -468,7 +470,8 @@ class WithPrivateNoticeTestCase(ChannelPluginTestCase):
self.failIf(m.command == 'NOTICE') self.failIf(m.command == 'NOTICE')
self.failUnless(ircutils.isChannel(m.args[0])) self.failUnless(ircutils.isChannel(m.args[0]))
finally: finally:
conf.supybot.reply.withPrivateNotice.setValue(original) conf.supybot.reply.inPrivate.setValue(originalInPrivate)
conf.supybot.reply.withNotice.setValue(originalWithNotice)