add margin
arg to ParsedLine.truncate so commands/outs.py doesn't do it
manually and cause potential issues with multi-byte chars
This commit is contained in:
parent
d00d026461
commit
938e1db963
2 changed files with 7 additions and 9 deletions
|
@ -44,13 +44,11 @@ class Out(object):
|
|||
if self._assured:
|
||||
line.assure()
|
||||
|
||||
valid, truncated = line.truncate(self.server.hostmask())
|
||||
valid, truncated = line.truncate(self.server.hostmask(),
|
||||
margin=STR_MORE_LEN)
|
||||
|
||||
if truncated:
|
||||
truncated = valid[-STR_MORE_LEN:]+truncated
|
||||
new_line = valid[:-STR_MORE_LEN]+STR_MORE
|
||||
line = utils.irc.parse_line(new_line)
|
||||
|
||||
line = utils.irc.parse_line(valid+STR_MORE)
|
||||
self._text = "%s%s" % (STR_CONTINUED, truncated)
|
||||
else:
|
||||
self._text = ""
|
||||
|
|
|
@ -111,13 +111,13 @@ class ParsedLine(object):
|
|||
else:
|
||||
return line
|
||||
|
||||
def _line_max(self, hostmask: str) -> int:
|
||||
return LINE_MAX-len((":%s " % hostmask).encode("utf8"))
|
||||
def truncate(self, hostmask: str) -> typing.Tuple[str, str]:
|
||||
def _line_max(self, hostmask: str, margin: int) -> int:
|
||||
return LINE_MAX-len((":%s " % hostmask).encode("utf8"))-margin
|
||||
def truncate(self, hostmask: str, margin: int=0) -> typing.Tuple[str, str]:
|
||||
valid_bytes = b""
|
||||
valid_index = -1
|
||||
|
||||
line_max = self._line_max(hostmask)
|
||||
line_max = self._line_max(hostmask, margin)
|
||||
|
||||
tags_formatted, line_formatted = self._format()
|
||||
for i, char in enumerate(line_formatted):
|
||||
|
|
Loading…
Reference in a new issue