mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-02 07:59:32 +01:00
Misc: Fix drop of the last (nb_mores % plugins.Misc.mores) messages.
If the last batch had less than plugins.Misc.mores messages; getting the last messages of the batch would raise an IndexError, causing the whole batch to be dropped.
This commit is contained in:
parent
f19079c75e
commit
5e91a68ab0
@ -381,8 +381,15 @@ class Misc(callbacks.Plugin):
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
L = irc._mores[userHostmask]
|
L = irc._mores[userHostmask]
|
||||||
number = self.registryValue('mores', msg.channel, irc.network)
|
except KeyError:
|
||||||
chunks = [L.pop() for x in range(0, number)]
|
irc.error(_('You haven\'t asked me a command; perhaps you want '
|
||||||
|
'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()
|
||||||
|
L[-number:] = []
|
||||||
|
if chunks:
|
||||||
if L:
|
if L:
|
||||||
if len(L) < 2:
|
if len(L) < 2:
|
||||||
more = _('1 more message')
|
more = _('1 more message')
|
||||||
@ -390,11 +397,7 @@ class Misc(callbacks.Plugin):
|
|||||||
more = _('%i more messages') % len(L)
|
more = _('%i more messages') % len(L)
|
||||||
chunks[-1] += format(' \x02(%s)\x0F', more)
|
chunks[-1] += format(' \x02(%s)\x0F', more)
|
||||||
irc.replies(chunks, noLengthCheck=True, oneToOne=False)
|
irc.replies(chunks, noLengthCheck=True, oneToOne=False)
|
||||||
except KeyError:
|
else:
|
||||||
irc.error(_('You haven\'t asked me a command; perhaps you want '
|
|
||||||
'to see someone else\'s more. To do so, call this '
|
|
||||||
'command with that person\'s nick.'))
|
|
||||||
except IndexError:
|
|
||||||
irc.error(_('That\'s all, there is no more.'))
|
irc.error(_('That\'s all, there is no more.'))
|
||||||
more = wrap(more, [additional('seenNick')])
|
more = wrap(more, [additional('seenNick')])
|
||||||
|
|
||||||
|
@ -231,6 +231,8 @@ class MiscTestCase(ChannelPluginTestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
m.args[1],
|
m.args[1],
|
||||||
self.nick + ': ' + 'abc '*112 + ' \x02(1 more message)\x0f')
|
self.nick + ': ' + 'abc '*112 + ' \x02(1 more message)\x0f')
|
||||||
|
self.assertResponse('more',
|
||||||
|
' '.join(['abc']*(400-112*3)))
|
||||||
self.assertResponse('more',
|
self.assertResponse('more',
|
||||||
"Error: That's all, there is no more.")
|
"Error: That's all, there is no more.")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user