Keep commands/outs.py tags-agnostic

This commit is contained in:
jesopo 2019-05-21 12:56:05 +01:00
parent a031402c1d
commit 11e5cc50c4
2 changed files with 13 additions and 14 deletions

View file

@ -132,9 +132,13 @@ class Module(ModuleManager.BaseModule):
if not module_name and hasattr(hook.function, "__self__"): if not module_name and hasattr(hook.function, "__self__"):
module_name = hook.function.__self__._name module_name = hook.function.__self__._name
tags = {}
msgid = MSGID_TAG.get_value(tags) msgid = MSGID_TAG.get_value(tags)
stdout = outs.StdOut(server, module_name, target, msgid, statusmsg) if msgid:
stderr = outs.StdErr(server, module_name, target, msgid, statusmsg) 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) command_method = self._command_method(target, server)
if hook.kwargs.get("remove_empty", True): if hook.kwargs.get("remove_empty", True):
@ -457,8 +461,7 @@ class Module(ModuleManager.BaseModule):
@utils.hook("send.stdout") @utils.hook("send.stdout")
def send_stdout(self, event): def send_stdout(self, event):
stdout = outs.StdOut(event["server"], event["module_name"], stdout = outs.StdOut(event["server"], event["module_name"],
event["target"], event.get("msgid", None), event["target"], {}, event.get("statusmsg", ""))
event.get("statusmsg", ""))
if event.get("hide_prefix", False): if event.get("hide_prefix", False):
stdout.hide_prefix() stdout.hide_prefix()
@ -470,8 +473,7 @@ class Module(ModuleManager.BaseModule):
@utils.hook("send.stderr") @utils.hook("send.stderr")
def send_stderr(self, event): def send_stderr(self, event):
stderr = outs.StdErr(event["server"], event["module_name"], stderr = outs.StdErr(event["server"], event["module_name"],
event["target"], event.get("msgid", None), event["target"], {}, event.get("statusmsg", ""))
event.get("statusmsg", ""))
if event.get("hide_prefix", False): if event.get("hide_prefix", False):
stderr.hide_prefix() stderr.hide_prefix()

View file

@ -5,14 +5,14 @@ STR_MORE = " (more...)"
STR_CONTINUED = "(...continued) " STR_CONTINUED = "(...continued) "
class Out(object): 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.server = server
self.module_name = module_name self.module_name = module_name
self._hide_prefix = False self._hide_prefix = False
self.target = target self.target = target
self._text = "" self._text = ""
self.written = False self.written = False
self._msgid = msgid self._tags = tags
self._statusmsg = statusmsg self._statusmsg = statusmsg
def write(self, text): def write(self, text):
@ -22,10 +22,6 @@ class Out(object):
def send(self, method): def send(self, method):
if self.has_text(): if self.has_text():
tags = {}
if self._msgid:
tags["+draft/reply"] = self._msgid
prefix = "" prefix = ""
if not self._hide_prefix: if not self._hide_prefix:
prefix = utils.consts.RESET + "[%s] " % self.prefix() prefix = utils.consts.RESET + "[%s] " % self.prefix()
@ -34,9 +30,10 @@ class Out(object):
full_text = "%s%s" % (prefix, self._text) full_text = "%s%s" % (prefix, self._text)
if method == "PRIVMSG": if method == "PRIVMSG":
line = self.server.send_message(target_str, full_text, line = self.server.send_message(target_str, full_text,
tags=tags) tags=self._tags)
elif method == "NOTICE": 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: else:
raise ValueError("Unknown command method '%s'" % method) raise ValueError("Unknown command method '%s'" % method)