Browse Source

Wait for connection registration before trying to join channels and send messages

master
JustAnotherArchivist 4 years ago
parent
commit
a888c9b9cb
1 changed files with 5 additions and 3 deletions
  1. +5
    -3
      http2irc.py

+ 5
- 3
http2irc.py View File

@@ -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')


Loading…
Cancel
Save