Fire preprocess.send per-command - use this to only strip colors from ParsedLine

objects for PRIVMSG and NOTICE
This commit is contained in:
jesopo 2019-02-23 21:40:11 +00:00
parent 5baa688fbc
commit 1473f41b03
2 changed files with 7 additions and 8 deletions

View file

@ -4,7 +4,9 @@ from src import ModuleManager, utils
"help": "Set whether I strip colors from my messages on this server",
"validate": utils.bool_or_none})
class Module(ModuleManager.BaseModule):
@utils.hook("preprocess.send")
@utils.hook("preprocess.send.privmsg")
@utils.hook("preprocess.send.notice")
def preprocess(self, event):
if event["server"].get_setting("strip-color", False):
return utils.irc.strip_font(event["line"])
line = event["line"]
line.args[-1] = utils.irc.strip_font(line.args[-1])

View file

@ -238,13 +238,10 @@ class Server(IRCObject.Object):
return lines
def send(self, line_parsed: IRCLine.ParsedLine):
line = line_parsed.format()
results = self.events.on("preprocess.send").call_unsafe(
server=self, line=line)
results = list(filter(None, results))
if results:
line = results[0]
self.events.on("preprocess.send").on(line_parsed.command
).call_unsafe(server=self, line=line_parsed)
line = line_parsed.format()
line_stripped = line.split("\n", 1)[0].strip("\r")
line_obj = IRCLine.Line(datetime.datetime.utcnow(), self.hostmask(),
line_parsed)