mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 03:33:11 +01:00
Fix extra arguments to irc.reply() being ignored by messages returned by '@more'.
This change builds all the ircmsg objects directly in irc.reply, with the original arguments. A side effect is that if a config var is changed between the initial command call and the call to '@more', this commit makes it use the old values, but that shouldn't be too much of an issue. Closes GH-1405.
This commit is contained in:
parent
61b47bb65b
commit
3eb20adaf2
@ -386,17 +386,12 @@ class Misc(callbacks.Plugin):
|
||||
'to see someone else\'s more. To do so, call this '
|
||||
'command with that person\'s nick.'), Raise=True)
|
||||
number = self.registryValue('mores', msg.channel, irc.network)
|
||||
chunks = L[-number:]
|
||||
chunks.reverse()
|
||||
msgs = L[-number:]
|
||||
msgs.reverse()
|
||||
L[-number:] = []
|
||||
if chunks:
|
||||
if L:
|
||||
if len(L) < 2:
|
||||
more = _('1 more message')
|
||||
else:
|
||||
more = _('%i more messages') % len(L)
|
||||
chunks[-1] += format(' \x02(%s)\x0F', more)
|
||||
irc.replies(chunks, noLengthCheck=True, oneToOne=False)
|
||||
if msgs:
|
||||
for msg in msgs:
|
||||
irc.queueMsg(msg)
|
||||
else:
|
||||
irc.error(_('That\'s all, there is no more.'))
|
||||
more = wrap(more, [additional('seenNick')])
|
||||
|
@ -212,9 +212,9 @@ class MiscTestCase(ChannelPluginTestCase):
|
||||
self.assertResponse('echo %s' % ('abc '*400),
|
||||
'abc '*112 + ' \x02(3 more messages)\x02')
|
||||
self.assertResponse('more',
|
||||
'abc '*112 + ' \x02(2 more messages)\x0f')
|
||||
'abc '*112 + ' \x02(2 more messages)\x02')
|
||||
self.assertResponse('more',
|
||||
'abc '*112 + ' \x02(1 more message)\x0f')
|
||||
'abc '*112 + ' \x02(1 more message)\x02')
|
||||
self.assertResponse('more',
|
||||
' '.join(['abc']*(400-112*3)))
|
||||
self.assertResponse('more',
|
||||
@ -225,12 +225,12 @@ class MiscTestCase(ChannelPluginTestCase):
|
||||
self.assertResponse('echo %s' % ('abc '*400),
|
||||
'abc '*112 + ' \x02(3 more messages)\x02')
|
||||
self.assertResponse('more',
|
||||
'abc '*112)
|
||||
'abc '*112 + ' \x02(2 more messages)\x02')
|
||||
m = self.irc.takeMsg()
|
||||
self.assertIsNot(m, None)
|
||||
self.assertEqual(
|
||||
m.args[1],
|
||||
self.nick + ': ' + 'abc '*112 + ' \x02(1 more message)\x0f')
|
||||
'abc '*112 + ' \x02(1 more message)\x02')
|
||||
self.assertResponse('more',
|
||||
' '.join(['abc']*(400-112*3)))
|
||||
self.assertResponse('more',
|
||||
|
@ -968,15 +968,31 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
|
||||
# The '(XX more messages)' may have not the same
|
||||
# length in the current locale
|
||||
allowedLength -= len(_('(XX more messages)')) + 1 # bold
|
||||
msgs = ircutils.wrap(s, allowedLength)
|
||||
msgs.reverse()
|
||||
chunks = ircutils.wrap(s, allowedLength)
|
||||
|
||||
# Last messages to display at the beginning of the list
|
||||
# (which is used like a stack)
|
||||
chunks.reverse()
|
||||
|
||||
msgs = []
|
||||
for (i, chunk) in enumerate(chunks):
|
||||
if i == 0:
|
||||
pass # last message, no suffix to add
|
||||
else:
|
||||
if i == 1:
|
||||
more = _('more message')
|
||||
else:
|
||||
more = _('more messages')
|
||||
n = ircutils.bold('(%i %s)' % (len(msgs), more))
|
||||
chunk = '%s %s' % (chunk, n)
|
||||
msgs.append(_makeReply(self, msg, chunk, **replyArgs))
|
||||
|
||||
instant = conf.get(conf.supybot.reply.mores.instant,
|
||||
channel=target, network=self.irc.network)
|
||||
while instant > 1 and msgs:
|
||||
instant -= 1
|
||||
response = msgs.pop()
|
||||
m = _makeReply(self, msg, response, **replyArgs)
|
||||
sendMsg(m)
|
||||
sendMsg(response)
|
||||
# XXX We should somehow allow these to be returned, but
|
||||
# until someone complains, we'll be fine :) We
|
||||
# can't return from here, though, for obvious
|
||||
@ -985,13 +1001,6 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
|
||||
if not msgs:
|
||||
return
|
||||
response = msgs.pop()
|
||||
if msgs:
|
||||
if len(msgs) == 1:
|
||||
more = _('more message')
|
||||
else:
|
||||
more = _('more messages')
|
||||
n = ircutils.bold('(%i %s)' % (len(msgs), more))
|
||||
response = '%s %s' % (response, n)
|
||||
prefix = msg.prefix
|
||||
if self.to and ircutils.isNick(self.to):
|
||||
try:
|
||||
@ -1004,9 +1013,8 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
|
||||
public = bool(self.msg.channel)
|
||||
private = self.private or not public
|
||||
self._mores[msg.nick] = (private, msgs)
|
||||
m = _makeReply(self, msg, response, **replyArgs)
|
||||
sendMsg(m)
|
||||
return m
|
||||
sendMsg(response)
|
||||
return response
|
||||
finally:
|
||||
self._resetReplyAttributes()
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user