changeset 204:6388579c701d

auto-reconnect in irclib, restart if bot's IRC connection was lost Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Fri, 26 Feb 2010 20:59:20 +0100
parents 2a81c480439a
children 85a8b457c4b4
files irclib.py
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/irclib.py
+++ b/irclib.py
@@ -240,7 +240,13 @@ class IRC:
                 if s == c._get_socket():
                     c.lock.acquire()
                     if hasattr(c, 'socket'):
-                        c.process_data()
+                        try:
+                            c.process_data()
+                        except ServerNotConnectedError:
+                            if c.real_nickname == self.bot.nickname:
+                                self.bot.restart()
+                            else:
+                                c.connect()
                     c.lock.release()
 
     def process_timeout(self):