]> jfr.im git - erebus.git/commitdiff
bot core - track time connected to server & which server connected to
authorJohn Runyon <redacted>
Sun, 13 Feb 2022 20:58:33 +0000 (14:58 -0600)
committerJohn Runyon <redacted>
Sun, 13 Feb 2022 20:58:33 +0000 (14:58 -0600)
bot.py

diff --git a/bot.py b/bot.py
index a9b7ea91cc9eea696116a75b67ad81953bc9cd6a..578caf2165e2cd974d0665fbbfd790e17af07b04 100644 (file)
--- a/bot.py
+++ b/bot.py
@@ -36,6 +36,11 @@ class Bot(object):
                self.authname = authname
                self.authpass = authpass
 
+               self.connecttime = 0 # time at which we received numeric 001
+               self.server = server # the address we try to (re-)connect to
+               self.port = port
+               self.servername = server # the name of the server we got connected to
+
                curs = self.parent.query("SELECT chname FROM chans WHERE bot = %s AND active = 1", (self.permnick,))
                if curs:
                        chansres = curs.fetchall()
@@ -95,6 +100,7 @@ class Bot(object):
                one = { #things to look for after source
                        'NOTICE': self._gotconnected,
                        '001': self._got001,
+                       '004': self._got004,
                        '376': self._gotRegistered,
                        '422': self._gotRegistered,
                        'PRIVMSG': self._gotprivmsg,
@@ -140,7 +146,10 @@ class Bot(object):
                sys.exit(2)
                os._exit(2)
        def _got001(self, pieces):
-               pass # wait until the end of MOTD instead
+               # We wait until the end of MOTD instead to consider ourselves registered, but consider uptime as of 001
+               self.connecttime = time.time()
+       def _got004(self, pieces):
+               self.servername = pieces[3]
        def _gotRegistered(self, pieces):
                self.conn.registered(True)