]> jfr.im git - erebus.git/blobdiff - bot.py
fix attempting to regain original nick when nick was in use upon connect
[erebus.git] / bot.py
diff --git a/bot.py b/bot.py
index 451786b6eff0cf8e2722989afc8d79fcdfc0da56..b0aec1bc6fb17c8bb850d81c4eb0eed537d88fe0 100644 (file)
--- a/bot.py
+++ b/bot.py
@@ -71,6 +71,7 @@ class Bot(object):
                        self.parse("ERROR :Fake-error from watchdog timer.")
                if self.conn.registered():
                        self.conn.send("PING :%s" % (time.time()))
+                       self._checknick()
                watchdogtimer = MyTimer(int(self.parent.cfg.get('watchdog', 'interval', default=30)), self.watchdog)
                watchdogtimer.start()
 
@@ -145,15 +146,19 @@ class Bot(object):
                self._checknick()
        def _goterror(self, pieces):
                # TODO: better handling, just reconnect that single bot
-               self.parent.mustquit = Exception(' '.join(pieces))
+               error = ' '.join(pieces)
                try:
-                       self.quit("Error detected: %s" % ' '.join(pieces))
+                       raise Exception(error)
+               except Exception as e:
+                       self.parent.mustquit = e
+               try:
+                       self.quit("Error detected: %s" % (error))
                except: pass
                try:
                        curs = self.parent.query("UPDATE bots SET connected = 0")
                        curs.close()
                except: pass
-               sys.exit(2)
+               self.log('!', 'Bot exiting due to: %s' % (error))
        def _got001(self, pieces):
                # We wait until the end of MOTD instead to consider ourselves registered, but consider uptime as of 001
                self.connecttime = time.time()