Fire preprocess.send per-command - use this to only strip colors from ParsedLine
objects for PRIVMSG and NOTICE
This commit is contained in:
parent
5baa688fbc
commit
1473f41b03
2 changed files with 7 additions and 8 deletions
|
@ -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])
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue