diff options
| author | 2018-10-01 17:26:31 +0100 | |
|---|---|---|
| committer | 2018-10-01 17:26:31 +0100 | |
| commit | 976b6ae335fc7563f35bc6e50d33779f4d69136e (patch) | |
| tree | 0ce1f72b77532562b5e3639092b4a02e0aca7aa4 /modules/commands.py | |
| parent | EventHook._call takes 3 args (diff) | |
| signature | ||
Better support for msgtags with PRIVMSGs; put functionality in to
modules/commands.py to reply to specific messages by use of msgids
Diffstat (limited to 'modules/commands.py')
| -rw-r--r-- | modules/commands.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/modules/commands.py b/modules/commands.py index 9aeb26bb..9c217920 100644 --- a/modules/commands.py +++ b/modules/commands.py @@ -9,15 +9,18 @@ OUT_CUTOFF = 400 REGEX_CUTOFF = re.compile("^.{1,%d}(?:\s|$)" % OUT_CUTOFF) class Out(object): - def __init__(self, module_name, target): + def __init__(self, module_name, target, msgid): self.module_name = module_name self.target = target self._text = "" self.written = False + self._msgid = None + def write(self, text): self._text += text self.written = True return self + def send(self): if self.has_text(): text = self._text @@ -29,10 +32,17 @@ class Out(object): ].decode("utf8").lstrip()) else: self._text = "" - self.target.send_message(text, prefix=Utils.FONT_RESET + "[%s] " % - self.prefix()) + + tags = {} + if self._msgid: + tags["reply"] = self._msgid + + self.target.send_message(text, + prefix=Utils.FONT_RESET + "[%s] " % self.prefix(), tags=tags) + def set_prefix(self, prefix): self.module_name = prefix + def has_text(self): return bool(self._text) @@ -93,8 +103,10 @@ class Module(ModuleManager.BaseModule): module_name = "" if hasattr(hook.function, "__self__"): module_name = hook.function.__self__._name - stdout, stderr = StdOut(module_name, target), StdErr(module_name, - target) + + msgid = event["tags"].get("msgid", None) + stdout = StdOut(module_name, target, msgid) + stderr = StdErr(module_name, target, msgid) returns = self.events.on("preprocess.command").call_unsafe( hook=hook, user=event["user"], server=event["server"], |
