Parse inbound bitbot.dev/multi-line batches

This commit is contained in:
jesopo 2019-06-16 10:03:46 +01:00
parent ef10207a73
commit 3a18229a73

View file

@ -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])]