Fix reconnection PEBCAK

- reset connection attributes BEFORE attempting a reconnect
 - otherwise certain fields (self.registered) have improper values
This commit is contained in:
theunkn0wn1 2018-12-30 19:57:20 -08:00 committed by Joshua Salzedo
parent 159e178549
commit 6821cf3fdb
2 changed files with 4 additions and 4 deletions

View File

@ -121,7 +121,6 @@ class BasicClient:
if self._ping_checker_handle:
self._ping_checker_handle.cancel()
# Schedule disconnect.
await self._disconnect(expected)
@ -129,6 +128,9 @@ class BasicClient:
# Shutdown connection.
await self.connection.disconnect()
# Reset any attributes.
self._reset_attributes()
# Callback.
await self.on_disconnect(expected)
@ -143,9 +145,6 @@ class BasicClient:
if expected and self.own_eventloop:
self.connection.stop()
# Reset any attributes.
self._reset_attributes()
async def _connect(self, hostname, port, reconnect=False, channels=[],
encoding=protocol.DEFAULT_ENCODING, source_address=None):
""" Connect to IRC host. """

View File

@ -31,6 +31,7 @@ class CapabilityNegotiationSupport(rfc1459.RFC1459Support):
async def _register(self):
""" Hijack registration to send a CAP LS first. """
if self.registered:
self.logger.debug("skipping cap registration, already registered!")
return
# Ask server to list capabilities.