Skip to content

Commit cb6b2ed

Browse files
committed
Fix state of _connect field on IrcClient after connection error
1 parent 931caf7 commit cb6b2ed

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

cloudbot/clients/irc.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,13 @@ def connect(self, timeout=None):
126126
return
127127

128128
if self._connected:
129+
self._connected = False
129130
logger.info("[{}] Reconnecting".format(self.name))
130-
self._transport.close()
131+
if self._transport:
132+
self._transport.close()
131133
else:
132-
self._connected = True
133134
logger.info("[{}] Connecting".format(self.name))
135+
134136
optional_params = {}
135137
if self.local_bind:
136138
optional_params["local_addr"] = self.local_bind
@@ -144,6 +146,8 @@ def connect(self, timeout=None):
144146

145147
self._transport, self._protocol = yield from coro
146148

149+
self._connected = True
150+
147151
tasks = [
148152
self.bot.plugin_manager.launch(hook, Event(bot=self.bot, conn=self, hook=hook))
149153
for hook in self.bot.plugin_manager.connect_hooks

0 commit comments

Comments
 (0)