]> jfr.im git - erebus.git/commitdiff
fix bot sitting inactive when a write error occurs
authorzonidjan <redacted>
Mon, 16 Sep 2019 02:19:42 +0000 (21:19 -0500)
committerzonidjan <redacted>
Mon, 16 Sep 2019 02:19:42 +0000 (21:19 -0500)
push socket write errors to bot._goterror

bot.py

diff --git a/bot.py b/bot.py
index 61b52163280da8511a06d3f3167bf5d77c8f7f8a..416934b2caf5b0b1218e897d6a5c49d056a2b5b3 100644 (file)
--- a/bot.py
+++ b/bot.py
@@ -129,8 +129,11 @@ class Bot(object):
                self.conn.send("PONG %s" % (pieces[1]))
                self._checknick()
        def _goterror(self, pieces):
+               # TODO: better handling, just reconnect that single bot
                try:
                        self.quit("Error detected: %s" % ' '.join(pieces))
+               except: pass
+               try:
                        curs = self.parent.query("UPDATE bots SET connected = 0")
                        curs.close()
                except: pass
@@ -496,7 +499,10 @@ class BotConnection(object):
                if self.parent.parent.cfg.getboolean('debug', 'io'):
                        self.parent.log('O', line)
                self.bytessent += len(line)
-               self._write(line)
+               try:
+                       self._write(line)
+               except socket.error as e:
+                       self.parent._goterror(repr(e))
 
        def _write(self, line):
                self.socket.sendall(line.encode('utf-8', 'backslashreplace')+b"\r\n")