From 0e2a2bcd00ca7c7a37e85c74fc6b401ceca2f19c Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 15 Apr 2020 21:10:24 +0100 Subject: [PATCH] create a fake echo-message when we have not CAP negotiated echo-message --- ircrobots/server.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ircrobots/server.py b/ircrobots/server.py index 7d9b248..ffeb611 100644 --- a/ircrobots/server.py +++ b/ircrobots/server.py @@ -166,6 +166,13 @@ class Server(IServer): async def line_send(self, line: Line): pass + async def _on_write_line(self, line: Line): + if (line.command == "PRIVMSG" and + not self.cap_agreed(CAP_ECHO)): + new_line = line.with_source(self.hostmask()) + emits = self.parse_tokens(new_line) + self._read_queue.append((new_line, emits)) + async def _write_lines(self) -> List[Line]: lines: List[SentLine] = [] @@ -183,6 +190,7 @@ class Server(IServer): for line in lines: line.future.set_result(line) + await self._on_write_line(line.line) await self.line_send(line.line) return [l.line for l in lines]