From 62df014b2923a6534e272a09c51da0aa90756803 Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 21 Sep 2018 11:34:38 +0100 Subject: [PATCH] Don't pass around full server details more than we have to. --- Database.py | 3 +-- IRCBot.py | 8 +++++--- start.py | 5 ++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Database.py b/Database.py index 4f3d22fd..1e186025 100644 --- a/Database.py +++ b/Database.py @@ -16,8 +16,7 @@ class Servers(Table): [hostname, port, password, ipv4, tls, nickname, username, realname]) def get_all(self): return self.database.execute_fetchall( - """SELECT server_id, alias, hostname, port, password, ipv4, - tls, nickname, username, realname FROM servers""") + "SELECT server_id, alias FROM servers") def get(self, id): return self.database.execute_fetchone( """SELECT server_id, alias, hostname, port, password, ipv4, diff --git a/IRCBot.py b/IRCBot.py index 14a70fcf..536e01ee 100644 --- a/IRCBot.py +++ b/IRCBot.py @@ -24,9 +24,11 @@ class Bot(object): self._events.on("timer.reconnect").hook(self.reconnect) self._events.on("boot.done").hook(self.setup_timers) - def add_server(self, id, alias, hostname, port, password, ipv4, tls, - nickname, username, realname, connect=False): - new_server = IRCServer.Server(self, self._events, id, alias, + def add_server(self, server_id, connect=True): + (_, alias, hostname, port, password, ipv4, tls, nickname, + username, realname) = self.database.servers.get(server_id) + + new_server = IRCServer.Server(self, self._events, server_id, alias, hostname, port, password, ipv4, tls, nickname, username, realname) if not new_server.get_setting("connect", True): diff --git a/start.py b/start.py index a69ad0d6..8c700080 100755 --- a/start.py +++ b/start.py @@ -29,10 +29,9 @@ whitelist = bot.get_setting("module-whitelist", []) blacklist = bot.get_setting("module-blacklist", []) bot.modules.load_modules(whitelist=whitelist, blacklist=blacklist) -server_details = database.servers.get_all() servers = [] -for server_detail in server_details: - server = bot.add_server(*server_detail) +for server_id, alias in database.servers.get_all(): + server = bot.add_server(server_id, connect=False) if not server == None: servers.append(server) if len(servers):