Make sure more than one hook can catch preprocess.send but still respect any

that return a change to the output (src/IRCServer.py)
This commit is contained in:
jesopo 2019-01-26 11:05:25 +00:00
parent ed44e6f78b
commit 8dcd6b2937

View file

@ -297,9 +297,12 @@ class Server(IRCObject.Object):
return self.until_read_timeout == 0 return self.until_read_timeout == 0
def send(self, line: str): def send(self, line: str):
returned = self.events.on("preprocess.send").call_unsafe_for_result( results = self.events.on("preprocess.send").call_unsafe(
server=self, line=line) server=self, line=line)
line = returned or line for result in results:
if result:
line = result
break
encoded = line.split("\n")[0].strip("\r").encode("utf8") encoded = line.split("\n")[0].strip("\r").encode("utf8")
if len(encoded) > 450: if len(encoded) > 450: