Fix crash when calling .reply(..., action=True) on ReplyIrcProxy

instead of on NestedCommandIrcProxy.

ReplyIrcProxy._sendReply expects action=True to imply noLengthCheck=True, but only
NestedCommandIrcProxy.reply() enforces the latter, not ReplyIrcProxy.reply().

This crash was introduced in 3c1c4a69e9 by
moving NestedCommandIrcProxy's .reply() to ReplyIrcProxy.
This commit is contained in:
Valentin Lorentz 2023-07-18 07:45:26 +02:00
parent 054ee6e410
commit 2b4c5eb78f
2 changed files with 17 additions and 0 deletions

View File

@ -733,6 +733,9 @@ class ReplyIrcProxy(RichReplyMethods):
kwargs['target'] = kwargs.get('to', None) or msg.args[0]
if 'prefixNick' not in kwargs:
kwargs['prefixNick'] = self._defaultPrefixNick(msg)
if kwargs.get("action"):
kwargs["prefixNick"] = False
kwargs["noLengthCheck"] = True
self._sendReply(s, msg=msg, **kwargs)
def __getattr__(self, attr):

View File

@ -684,12 +684,26 @@ class PrivmsgTestCase(ChannelPluginTestCase):
irc.reply('foo', action=True)
irc.reply('bar') # We're going to check that this isn't an action.
def doNotice(self, irc, msg):
irc.reply('foo', action=True)
irc.reply('bar') # We're going to check that this isn't an action.
def testNotActionSecondReply(self):
self.irc.addCallback(self.TwoRepliesFirstAction(self.irc))
self.assertAction('testactionreply', 'foo')
m = self.getMsg(' ')
self.assertFalse(m.args[1].startswith('\x01ACTION'))
def testNotActionSecondReplyNotCommand(self):
"""Same as testNotActionSecondReply, but tests ReplyIrcProxy instead of
NestedCommandsIrcProxy."""
self.irc.addCallback(self.TwoRepliesFirstAction(self.irc))
self.irc.feedMsg(ircmsgs.notice(self.channel, 'test action reply',
prefix=self.prefix))
self.assertAction(' ', 'foo')
m = self.getMsg(' ')
self.assertFalse(m.args[1].startswith('\x01ACTION'))
def testEmptyNest(self):
try:
conf.supybot.reply.whenNotCommand.set('True')