Implement bitbot.dev/multi-line
This commit is contained in:
parent
919a488e86
commit
33de403685
1 changed files with 25 additions and 0 deletions
25
modules/ircv3_multi_line.py
Normal file
25
modules/ircv3_multi_line.py
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
from src import ModuleManager, utils
|
||||||
|
|
||||||
|
CAP = utils.irc.Capability(None, "bitbot.dev/multi-line")
|
||||||
|
|
||||||
|
class Module(ModuleManager.BaseModule):
|
||||||
|
@utils.hook("received.cap.ls")
|
||||||
|
@utils.hook("received.cap.new")
|
||||||
|
def on_cap(self, event):
|
||||||
|
if CAP.available(event["capabilities"]):
|
||||||
|
return CAP.copy()
|
||||||
|
|
||||||
|
@utils.hook("preprocess.send.privmsg")
|
||||||
|
def preprocess_send_privmsg(self, event):
|
||||||
|
if len(event["line"].args) > 1:
|
||||||
|
if ("\n" in event["line"].args[1] and
|
||||||
|
event["server"].has_capability(CAP)):
|
||||||
|
event["line"].invalidate()
|
||||||
|
|
||||||
|
target = event["line"].args[0]
|
||||||
|
lines = event["line"].args[1].split("\n")
|
||||||
|
batch = utils.irc.IRCSendBatch("bitbot.dev/multi-line", [])
|
||||||
|
for line in lines:
|
||||||
|
batch.add_line(utils.irc.protocol.privmsg(target, line))
|
||||||
|
for line in batch.get_lines():
|
||||||
|
event["server"].send(line)
|
Loading…
Reference in a new issue