From: John Runyon Date: Sun, 13 Feb 2022 20:58:33 +0000 (-0600) Subject: bot core - track time connected to server & which server connected to X-Git-Url: https://jfr.im/git/erebus.git/commitdiff_plain/1e76e96cebd84465303c86976ea8e45607e08ac8?hp=b00fcfc604af8136ccd1abc6ee09f4bcabbfbdd3 bot core - track time connected to server & which server connected to --- diff --git a/bot.py b/bot.py index a9b7ea9..578caf2 100644 --- 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)