Keep commands/outs.py tags-agnostic
This commit is contained in:
parent
a031402c1d
commit
11e5cc50c4
2 changed files with 13 additions and 14 deletions
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue