From a888c9b9cb423cb07ab01d45492b7909ef8e1eff Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Sun, 15 Dec 2019 15:38:00 +0000 Subject: Wait for connection registration before trying to join channels and send messages --- http2irc.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/http2irc.py b/http2irc.py index d355ae4..cc06daf 100644 --- a/http2irc.py +++ b/http2irc.py @@ -215,9 +215,6 @@ class IRCClientProtocol(asyncio.Protocol): nickb = self.config.irc.nick.encode('utf-8') self.send(b'NICK ' + nickb) self.send(b'USER ' + nickb + b' ' + nickb + b' ' + nickb + b' :' + self.config.irc.real.encode('utf-8')) - self.send(b'JOIN ' + ','.join(self.channels).encode('utf-8')) #TODO: Split if too long - asyncio.create_task(self.send_messages()) - asyncio.create_task(self.confirm_messages()) def update_channels(self, channels: set): channelsToPart = self.channels - channels @@ -310,6 +307,11 @@ class IRCClientProtocol(asyncio.Protocol): self.send(b'PONG ' + message[5:]) elif message.startswith(b'PONG '): self.pongReceivedEvent.set() + elif message.startswith(b'001 '): + # Connection registered + self.send(b'JOIN ' + ','.join(self.channels).encode('utf-8')) #TODO: Split if too long + asyncio.create_task(self.send_messages()) + asyncio.create_task(self.confirm_messages()) def connection_lost(self, exc): logging.info('The server closed the connection') -- cgit v1.3.1-10-gc9f91