|
11 | 11 | from socket import gethostname
|
12 | 12 | from optparse import OptionParser
|
13 | 13 | from collections import defaultdict
|
| 14 | +from socket import error as SocketError |
14 | 15 | from re import compile as compile_regex
|
15 | 16 | from datetime import date, datetime, timedelta
|
16 | 17 | from os import environ, getcwd, makedirs, path
|
@@ -160,7 +161,8 @@ def init(self, host, port=6667, opts=None):
|
160 | 161 | Debugger(events=opts.verbose).register(self)
|
161 | 162 |
|
162 | 163 | # Add TCPClient and IRC to the system.
|
163 |
| - self += (TCPClient(channel=self.channel) + IRC(channel=self.channel)) |
| 164 | + self.transport = TCPClient(channel=self.channel).register(self) |
| 165 | + self.protocol = IRC(channel=self.channel).register(self) |
164 | 166 |
|
165 | 167 | # Logger(s)
|
166 | 168 | for ircchannel in self.ircchannels:
|
@@ -188,6 +190,11 @@ def ready(self, component):
|
188 | 190 | def keep_alive(self):
|
189 | 191 | self.fire(Write(b"\x00"))
|
190 | 192 |
|
| 193 | + def error(self, etype, evalue, etraceback, handler=None): |
| 194 | + if isinstance(evalue, SocketError): |
| 195 | + if not self.transport.connected: |
| 196 | + Timer(5, Connect(self.host, self.port)).register(self) |
| 197 | + |
191 | 198 | def connected(self, host, port):
|
192 | 199 | """Connected Event
|
193 | 200 |
|
|
0 commit comments