Fix bugs in wrapping IRC messages.

This commit is contained in:
Valentin Lorentz 2019-01-06 16:48:04 +01:00
parent 922012a307
commit a03a89730a
3 changed files with 5 additions and 3 deletions

View File

@ -939,7 +939,7 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
return m
# The '(XX more messages)' may have not the same
# length in the current locale
allowedLength -= len(_('(XX more messages)'))
allowedLength -= len(_('(XX more messages)')) + 1 # bold
msgs = ircutils.wrap(s, allowedLength)
msgs.reverse()
instant = conf.get(conf.supybot.reply.mores.instant,target)

View File

@ -540,6 +540,10 @@ class FormatContext(object):
IRC string."""
prefix_size = self.bold + self.reverse + self.underline + \
bool(self.fg) + bool(self.bg)
if self.fg and self.bg:
prefix_size += 6 # '\x03xx,yy%s'
elif self.fg or self.bg:
prefix_size += 3 # '\x03xx%s'
if prefix_size:
return prefix_size + 1 # '\x0f'
else:

View File

@ -229,10 +229,8 @@ class FunctionsTestCase(SupyTestCase):
s = '\x02\x16 barbazqux' + ('foobarbazqux ' * 20)[0:-1]
r = ircutils.wrap(s, 91)
print(list(map(pred, r)))
self.assertTrue(max(map(pred, r)) <= 91)
def testSafeArgument(self):
s = 'I have been running for 9 seconds'
bolds = ircutils.bold(s)