From d069d4b83fa0b8bef741458f2a6eb96c0b1f8b7d Mon Sep 17 00:00:00 2001 From: panicbit Date: Wed, 9 Oct 2019 20:53:50 +0200 Subject: [PATCH 1/2] Adjust line splitpoints to word boundaries --- modules/commands/outs.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/commands/outs.py b/modules/commands/outs.py index 2677d1bf..a1733d18 100644 --- a/modules/commands/outs.py +++ b/modules/commands/outs.py @@ -4,6 +4,7 @@ from src import utils STR_MORE = " (more...)" STR_MORE_LEN = len(STR_MORE.encode("utf8")) STR_CONTINUED = "(...continued) " +WORD_BOUNDARY = ' ' class Out(object): def __init__(self, server, module_name, target, target_str, tags): @@ -54,6 +55,8 @@ class Out(object): margin=STR_MORE_LEN) if truncated: + valid, truncated = self._adjust_to_word_boundaries(valid, truncated) + line = utils.irc.parse_line(valid+STR_MORE) self._text = "%s%s" % (STR_CONTINUED, truncated) else: @@ -61,6 +64,18 @@ class Out(object): sent_line = self.server.send(line) + @staticmethod + def _adjust_to_word_boundaries(left, right): + if right[0] == WORD_BOUNDARY: + return left, right + + parts = left.rsplit(WORD_BOUNDARY, 1) + + if len(parts) != 2: + return left, right + + return parts[0], parts[1] + right + def _default_prefix(self, s: str): return s def set_prefix(self, prefix): From c94327b58b99bc1d4380f026f8e592efd265b357 Mon Sep 17 00:00:00 2001 From: panicbit Date: Sat, 12 Oct 2019 18:30:22 +0200 Subject: [PATCH 2/2] Remove @staticmethod --- modules/commands/outs.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/commands/outs.py b/modules/commands/outs.py index a1733d18..c81883ab 100644 --- a/modules/commands/outs.py +++ b/modules/commands/outs.py @@ -64,8 +64,7 @@ class Out(object): sent_line = self.server.send(line) - @staticmethod - def _adjust_to_word_boundaries(left, right): + def _adjust_to_word_boundaries(self, left, right): if right[0] == WORD_BOUNDARY: return left, right