mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-23 11:12:47 +01:00
Fix for bug about reply.withPrivateNotice overriding stuff.
This commit is contained in:
parent
16c832bd62
commit
3db50c1a2b
@ -123,8 +123,8 @@ def canonicalName(command):
|
||||
command = command[:-1]
|
||||
return command.translate(string.ascii, special).lower() + reAppend
|
||||
|
||||
def reply(msg, s, prefixName=True, private=False,
|
||||
notice=False, to=None, action=False):
|
||||
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 private:
|
||||
@ -134,7 +134,7 @@ def reply(msg, s, prefixName=True, private=False,
|
||||
else:
|
||||
target = msg.nick
|
||||
# XXX: User value.
|
||||
if conf.supybot.reply.withNoticeWhenPrivate():
|
||||
if conf.supybot.reply.withNoticeWhenPrivate() and notice is None:
|
||||
notice = True
|
||||
if to is None:
|
||||
to = msg.nick
|
||||
@ -151,8 +151,10 @@ def reply(msg, s, prefixName=True, private=False,
|
||||
if notice:
|
||||
msgmaker = ircmsgs.notice
|
||||
if conf.supybot.reply.withPrivateNotice():
|
||||
target = msg.nick
|
||||
msgmaker = ircmsgs.notice
|
||||
if private is None:
|
||||
target = msg.nick
|
||||
if notice is None:
|
||||
msgmaker = ircmsgs.notice
|
||||
if action:
|
||||
msgmaker = ircmsgs.action
|
||||
# Finally, we'll return the actual message.
|
||||
@ -467,10 +469,10 @@ class IrcObjectProxy(RichReplyMethods):
|
||||
|
||||
def _resetReplyAttributes(self):
|
||||
self.to = None
|
||||
self.action = False
|
||||
self.notice = False
|
||||
self.private = False
|
||||
self.noLengthCheck = False
|
||||
self.action = None
|
||||
self.notice = None
|
||||
self.private = None
|
||||
self.noLengthCheck = None
|
||||
self.prefixName = conf.supybot.reply.withNickPrefix()
|
||||
|
||||
def evalArgs(self):
|
||||
@ -571,7 +573,7 @@ class IrcObjectProxy(RichReplyMethods):
|
||||
self._callCommand(name, command, cb)
|
||||
|
||||
def reply(self, s, noLengthCheck=False, prefixName=True,
|
||||
action=False, private=False, notice=False, to=None, msg=None):
|
||||
action=None, private=None, notice=None, to=None, msg=None):
|
||||
"""reply(s) -> replies to msg with s
|
||||
|
||||
Keyword arguments:
|
||||
@ -593,10 +595,14 @@ class IrcObjectProxy(RichReplyMethods):
|
||||
'Old code alert: there is no longer a "msg" argument to reply.'
|
||||
if msg is None:
|
||||
msg = self.msg
|
||||
self.action = action or self.action
|
||||
self.notice = notice or self.notice
|
||||
self.private = private or self.private
|
||||
self.to = to or self.to
|
||||
if action is not None:
|
||||
self.action = self.action or action
|
||||
if notice is not None:
|
||||
self.notice = self.notice or notice
|
||||
if private is not None:
|
||||
self.private = self.private or private
|
||||
if to is not None:
|
||||
self.to = self.to or to
|
||||
# action=True implies noLengthCheck=True and prefixName=False
|
||||
self.prefixName = prefixName and self.prefixName and not self.action
|
||||
self.noLengthCheck=noLengthCheck or self.noLengthCheck or self.action
|
||||
|
@ -439,4 +439,38 @@ class RichReplyMethodsTestCase(PluginTestCase):
|
||||
self.irc.addCallback(self.NoCapability())
|
||||
self.assertRegexp('error', 'admin')
|
||||
|
||||
|
||||
class WithPrivateNoticeTestCase(ChannelPluginTestCase):
|
||||
plugins = ()
|
||||
class WithPrivateNotice(callbacks.Privmsg):
|
||||
def normal(self, irc, msg, args):
|
||||
irc.reply('should be with private notice')
|
||||
def explicit(self, irc, msg, args):
|
||||
irc.reply('should not be with private notice',
|
||||
private=False, notice=False)
|
||||
def test(self):
|
||||
self.irc.addCallback(self.WithPrivateNotice())
|
||||
# Check normal behavior.
|
||||
m = self.assertNotError('normal')
|
||||
self.failIf(m.command == 'NOTICE')
|
||||
self.failUnless(ircutils.isChannel(m.args[0]))
|
||||
m = self.assertNotError('explicit')
|
||||
self.failIf(m.command == 'NOTICE')
|
||||
self.failUnless(ircutils.isChannel(m.args[0]))
|
||||
# Check abnormal behavior.
|
||||
original = conf.supybot.reply.withPrivateNotice()
|
||||
try:
|
||||
conf.supybot.reply.withPrivateNotice.setValue(True)
|
||||
m = self.assertNotError('normal')
|
||||
self.failUnless(m.command == 'NOTICE')
|
||||
self.failIf(ircutils.isChannel(m.args[0]))
|
||||
m = self.assertNotError('explicit')
|
||||
self.failIf(m.command == 'NOTICE')
|
||||
self.failUnless(ircutils.isChannel(m.args[0]))
|
||||
finally:
|
||||
conf.supybot.reply.withPrivateNotice.setValue(original)
|
||||
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
Loading…
Reference in New Issue
Block a user