From 3a18229a73d146c40b4db2efabe85fee9c22a1ef Mon Sep 17 00:00:00 2001 From: jesopo Date: Sun, 16 Jun 2019 10:03:46 +0100 Subject: [PATCH] Parse inbound bitbot.dev/multi-line batches --- modules/ircv3_multi_line.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/ircv3_multi_line.py b/modules/ircv3_multi_line.py index 54461fbd..a014566c 100644 --- a/modules/ircv3_multi_line.py +++ b/modules/ircv3_multi_line.py @@ -1,6 +1,7 @@ from src import ModuleManager, utils CAP = utils.irc.Capability(None, "bitbot.dev/multi-line") +BATCH = utils.irc.BatchType(None, "bitbot.dev/multi-line") class Module(ModuleManager.BaseModule): @utils.hook("received.cap.ls") @@ -24,3 +25,15 @@ class Module(ModuleManager.BaseModule): batch.add_line(utils.irc.protocol.privmsg(target, line)) for line in batch.get_lines(): event["server"].send(line) + + @utils.hook("received.batch.end") + def batch_end(self, event): + if BATCH.match(event["batch"].type): + messages = [] + lines = event["batch"].get_lines() + for line in lines: + messages.append(line.args[1]) + + target = event["batch"].args[0] + message = "\n".join(messages) + return [IRCLine.ParsedLine("PRIVMSG", [target, message])]