diff options
Diffstat (limited to 'src/core_modules')
| -rw-r--r-- | src/core_modules/commands/__init__.py | 30 | ||||
| -rw-r--r-- | src/core_modules/commands/outs.py | 7 | ||||
| -rw-r--r-- | src/core_modules/more.py | 2 |
3 files changed, 21 insertions, 18 deletions
diff --git a/src/core_modules/commands/__init__.py b/src/core_modules/commands/__init__.py index a5c5faa6..777cb692 100644 --- a/src/core_modules/commands/__init__.py +++ b/src/core_modules/commands/__init__.py @@ -8,8 +8,8 @@ COMMAND_METHOD = "command-method" COMMAND_METHODS = ["PRIVMSG", "NOTICE"] STR_MORE = " (more...)" +STR_CONTINUED = "(...continued) " STR_MORE_LEN = len(STR_MORE.encode("utf8")) -STR_CONTINUED = "(...continued)" WORD_BOUNDARIES = [" "] NON_ALPHANUMERIC = [char for char in string.printable if not char.isalnum()] @@ -237,29 +237,25 @@ class Module(ModuleManager.BaseModule): color = utils.consts.RED line_str = obj.pop() + prefix = "" if obj.prefix: - line_str = "[%s] %s" % ( - utils.irc.color(obj.prefix, color), line_str) + prefix = "[%s] " % utils.irc.color(obj.prefix, color) + if obj._overflowed: + prefix = "%s%s" % (prefix, STR_CONTINUED) method = self._command_method(server, target, is_channel) if not method in ["PRIVMSG", "NOTICE"]: raise ValueError("Unknown command-method '%s'" % method) - line = IRCLine.ParsedLine(method, [target_str, line_str], - tags=tags) - valid, trunc = line.truncate(server.hostmask(), - margin=STR_MORE_LEN) + line = server.new_line(method, [target_str, prefix], tags=tags) + + overflow = line.push_last(line_str, human_trunc=True, + extra_margin=STR_MORE_LEN) + if overflow: + line.push_last(STR_MORE) + obj.insert(overflow) + obj._overflowed = True - if trunc: - if not trunc[0] in WORD_BOUNDARIES: - for boundary in WORD_BOUNDARIES: - left, *right = valid.rsplit(boundary, 1) - if right: - valid = left - trunc = right[0]+trunc - obj.insert("%s %s" % (STR_CONTINUED, trunc)) - valid = valid+STR_MORE - line = IRCLine.parse_line(valid) if obj._assured: line.assure() server.send(line) diff --git a/src/core_modules/commands/outs.py b/src/core_modules/commands/outs.py index e82ceefd..c6b489ae 100644 --- a/src/core_modules/commands/outs.py +++ b/src/core_modules/commands/outs.py @@ -6,6 +6,13 @@ class StdOut(object): self.prefix = prefix self._lines = [] self._assured = False + self._overflowed = False + + def copy_from(self, other): + self.prefix = other.prefix + self._lines = other._lines + self._assured = other._assured + self._overflowed = other._overflowed def assure(self): self._assured = True diff --git a/src/core_modules/more.py b/src/core_modules/more.py index 52849938..bc76fb6b 100644 --- a/src/core_modules/more.py +++ b/src/core_modules/more.py @@ -20,4 +20,4 @@ class Module(ModuleManager.BaseModule): def more(self, event): last_stdout = event["target"]._last_stdout if last_stdout and last_stdout.has_text(): - event["stdout"].write_lines(last_stdout.get_all()) + event["stdout"].copy_from(last_stdout) |
