]> jfr.im git - z_archive/twitter.git/blobdiff - twitter/ircbot.py
archiver: soft fail on 404 when given profile does not exist
[z_archive/twitter.git] / twitter / ircbot.py
index b9fd895510e0c416a1cdb767afade412b42071ab..9310d0c05278fcb0e81b02fc27663dd5917532f3 100644 (file)
@@ -274,7 +274,7 @@ class TwitterBot(object):
                 "%s%s has asked me to stop following %s" %(
                     get_prefix('inform'), userNick, name))
 
-    def run(self):
+    def _irc_connect(self):
         self.ircServer.connect(
             self.config.get('irc', 'server'),
             self.config.getint('irc', 'port'),
@@ -283,6 +283,9 @@ class TwitterBot(object):
         for channel in channels:
             self.ircServer.join(channel)
 
+    def run(self):
+        self._irc_connect()
+
         while True:
             try:
                 self.sched.run_forever()
@@ -292,6 +295,10 @@ class TwitterBot(object):
                 # twitter.com is probably down because it
                 # sucks. ignore the fault and keep going
                 pass
+            except irclib.ServerNotConnectedError:
+                # Try and reconnect to IRC.
+                self._irc_connect()
+
 
 def load_config(filename):
     # Note: Python ConfigParser module has the worst interface in the