From 05fcb33ff7dd75ea03e39a38a72a4426c0db95b3 Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 6 Jun 2019 19:15:34 +0100 Subject: [PATCH] print lines as soon as they're read, don't wait for _post_send --- src/IRCBot.py | 2 +- src/IRCServer.py | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/IRCBot.py b/src/IRCBot.py index 293a76d5..6cd1f4e6 100644 --- a/src/IRCBot.py +++ b/src/IRCBot.py @@ -256,7 +256,7 @@ class Bot(object): server = self.servers[fd] try: - lines = server.socket._send() + lines = server._send() except: self.log.error("Failed to write to %s", [str(server)]) raise diff --git a/src/IRCServer.py b/src/IRCServer.py index 1f2a5b3b..795ccaac 100644 --- a/src/IRCServer.py +++ b/src/IRCServer.py @@ -240,6 +240,17 @@ class Server(IRCObject.Object): return lines + def _send(self) -> typing.List[IRCLine.SentLine]: + lines = self.socket._send() + for line in lines: + self.bot.log.debug("%s (raw send) | %s", [ + str(self), line.parsed_line.format()]) + return lines + def _post_send(self, lines: typing.List[IRCLine.SentLine]): + for line in lines: + self.events.on("raw.send").call_unsafe(server=self, + line=line.parsed_line) + def send(self, line_parsed: IRCLine.ParsedLine, immediate: bool=False): if not self.send_enabled: return None @@ -263,14 +274,6 @@ class Server(IRCObject.Object): def send_raw(self, line: str): return self.send(utils.irc.parse_line(line)) - - def _post_send(self, lines: typing.List[IRCLine.SentLine]): - for line in lines: - self.bot.log.debug("%s (raw send) | %s", [ - str(self), line.parsed_line.format()]) - self.events.on("raw.send").call_unsafe(server=self, - line=line.parsed_line) - def send_user(self, username: str, realname: str) -> IRCLine.SentLine: return self.send(utils.irc.protocol.user(username, realname)) def send_nick(self, nickname: str) -> IRCLine.SentLine: