aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGravatar jesopo2019-06-10 10:45:02 +0100
committerGravatar jesopo2019-06-10 10:45:02 +0100
commit6c5dc958d037907d98dd6edbc4e37f5ac39768ac (patch)
treea93470e32b894c5cca31b2caf26f763a937ea2e1 /modules
parentAllow preprocess.send callbacks to request a line not be sent at all (diff)
signature
Add `.assure()` to ParsedLine, to make it immune from `.valid()`
Diffstat (limited to 'modules')
-rw-r--r--modules/commands/outs.py27
1 files changed, 18 insertions, 9 deletions
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