Parse inbound bitbot.dev/multi-line batches
This commit is contained in:
parent
ef10207a73
commit
3a18229a73
1 changed files with 13 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
from src import ModuleManager, utils
|
from src import ModuleManager, utils
|
||||||
|
|
||||||
CAP = utils.irc.Capability(None, "bitbot.dev/multi-line")
|
CAP = utils.irc.Capability(None, "bitbot.dev/multi-line")
|
||||||
|
BATCH = utils.irc.BatchType(None, "bitbot.dev/multi-line")
|
||||||
|
|
||||||
class Module(ModuleManager.BaseModule):
|
class Module(ModuleManager.BaseModule):
|
||||||
@utils.hook("received.cap.ls")
|
@utils.hook("received.cap.ls")
|
||||||
|
@ -24,3 +25,15 @@ class Module(ModuleManager.BaseModule):
|
||||||
batch.add_line(utils.irc.protocol.privmsg(target, line))
|
batch.add_line(utils.irc.protocol.privmsg(target, line))
|
||||||
for line in batch.get_lines():
|
for line in batch.get_lines():
|
||||||
event["server"].send(line)
|
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])]
|
||||||
|
|
Loading…
Reference in a new issue