Don't pass around full server details more than we have to.

This commit is contained in:
jesopo 2018-09-21 11:34:38 +01:00
parent cc371e3ae0
commit 62df014b29
3 changed files with 8 additions and 8 deletions

View file

@ -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,

View file

@ -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):

View file

@ -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):