From 11e5cc50c439248f021451ad59ab565b8c01a192 Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 21 May 2019 12:56:05 +0100 Subject: [PATCH] Keep commands/outs.py tags-agnostic --- modules/commands/__init__.py | 14 ++++++++------ modules/commands/outs.py | 13 +++++-------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/modules/commands/__init__.py b/modules/commands/__init__.py index 880ea4ae..19bf59c2 100644 --- a/modules/commands/__init__.py +++ b/modules/commands/__init__.py @@ -132,9 +132,13 @@ class Module(ModuleManager.BaseModule): if not module_name and hasattr(hook.function, "__self__"): module_name = hook.function.__self__._name + tags = {} msgid = MSGID_TAG.get_value(tags) - stdout = outs.StdOut(server, module_name, target, msgid, statusmsg) - stderr = outs.StdErr(server, module_name, target, msgid, statusmsg) + if msgid: + tags["+draft/reply"] = msgid + + stdout = outs.StdOut(server, module_name, target, tags, statusmsg) + stderr = outs.StdErr(server, module_name, target, tags, statusmsg) command_method = self._command_method(target, server) if hook.kwargs.get("remove_empty", True): @@ -457,8 +461,7 @@ class Module(ModuleManager.BaseModule): @utils.hook("send.stdout") def send_stdout(self, event): stdout = outs.StdOut(event["server"], event["module_name"], - event["target"], event.get("msgid", None), - event.get("statusmsg", "")) + event["target"], {}, event.get("statusmsg", "")) if event.get("hide_prefix", False): stdout.hide_prefix() @@ -470,8 +473,7 @@ class Module(ModuleManager.BaseModule): @utils.hook("send.stderr") def send_stderr(self, event): stderr = outs.StdErr(event["server"], event["module_name"], - event["target"], event.get("msgid", None), - event.get("statusmsg", "")) + event["target"], {}, event.get("statusmsg", "")) if event.get("hide_prefix", False): stderr.hide_prefix() diff --git a/modules/commands/outs.py b/modules/commands/outs.py index 0f931247..acd67a7f 100644 --- a/modules/commands/outs.py +++ b/modules/commands/outs.py @@ -5,14 +5,14 @@ STR_MORE = " (more...)" STR_CONTINUED = "(...continued) " class Out(object): - def __init__(self, server, module_name, target, msgid, statusmsg): + def __init__(self, server, module_name, target, tags, statusmsg): self.server = server self.module_name = module_name self._hide_prefix = False self.target = target self._text = "" self.written = False - self._msgid = msgid + self._tags = tags self._statusmsg = statusmsg def write(self, text): @@ -22,10 +22,6 @@ class Out(object): def send(self, method): if self.has_text(): - tags = {} - if self._msgid: - tags["+draft/reply"] = self._msgid - prefix = "" if not self._hide_prefix: prefix = utils.consts.RESET + "[%s] " % self.prefix() @@ -34,9 +30,10 @@ class Out(object): full_text = "%s%s" % (prefix, self._text) if method == "PRIVMSG": line = self.server.send_message(target_str, full_text, - tags=tags) + tags=self._tags) elif method == "NOTICE": - line = self.server.send_notice(target_str, full_text, tags=tags) + line = self.server.send_notice(target_str, full_text, + tags=self._tags) else: raise ValueError("Unknown command method '%s'" % method)