From 6c5dc958d037907d98dd6edbc4e37f5ac39768ac Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 10 Jun 2019 10:45:02 +0100 Subject: Add `.assure()` to ParsedLine, to make it immune from `.valid()` --- modules/commands/outs.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'modules') diff --git a/modules/commands/outs.py b/modules/commands/outs.py index 7df60436..7ed49cd6 100644 --- a/modules/commands/outs.py +++ b/modules/commands/outs.py @@ -14,6 +14,10 @@ class Out(object): self._text = "" self.written = False self._tags = tags + self._assured = False + + def assure(self): + self._assured = True def write(self, text): self._text += text @@ -27,20 +31,25 @@ class Out(object): prefix = utils.consts.RESET + "[%s] " % self.prefix() full_text = "%s%s" % (prefix, self._text) + line_factory = None if method == "PRIVMSG": - line = self.server.send_message(self._target_str, full_text, - tags=self._tags) + line_factory = utils.irc.protocol.privmsg elif method == "NOTICE": - line = self.server.send_notice(self._target_str, full_text, - tags=self._tags) + line_factory = utils.irc.protocol.notice else: raise ValueError("Unknown command method '%s'" % method) - line.truncate_marker = STR_MORE - if line.truncated(): - self._text = "%s%s" % (STR_CONTINUED, line.truncated()) - else: - self._text = "" + line = line_factory(self._target_str, full_text, tags=self._tags) + if self._assured: + line.assure() + sent_line = self.server.send(line) + + if sent_line: + line.truncate_marker = STR_MORE + if line.truncated(): + self._text = "%s%s" % (STR_CONTINUED, line.truncated()) + else: + self._text = "" def set_prefix(self, prefix): self.module_name = prefix -- cgit v1.3.1-10-gc9f91