Don't pass around full server details more than we have to.
This commit is contained in:
parent
cc371e3ae0
commit
62df014b29
3 changed files with 8 additions and 8 deletions
|
@ -16,8 +16,7 @@ class Servers(Table):
|
||||||
[hostname, port, password, ipv4, tls, nickname, username, realname])
|
[hostname, port, password, ipv4, tls, nickname, username, realname])
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
return self.database.execute_fetchall(
|
return self.database.execute_fetchall(
|
||||||
"""SELECT server_id, alias, hostname, port, password, ipv4,
|
"SELECT server_id, alias FROM servers")
|
||||||
tls, nickname, username, realname FROM servers""")
|
|
||||||
def get(self, id):
|
def get(self, id):
|
||||||
return self.database.execute_fetchone(
|
return self.database.execute_fetchone(
|
||||||
"""SELECT server_id, alias, hostname, port, password, ipv4,
|
"""SELECT server_id, alias, hostname, port, password, ipv4,
|
||||||
|
|
|
@ -24,9 +24,11 @@ class Bot(object):
|
||||||
self._events.on("timer.reconnect").hook(self.reconnect)
|
self._events.on("timer.reconnect").hook(self.reconnect)
|
||||||
self._events.on("boot.done").hook(self.setup_timers)
|
self._events.on("boot.done").hook(self.setup_timers)
|
||||||
|
|
||||||
def add_server(self, id, alias, hostname, port, password, ipv4, tls,
|
def add_server(self, server_id, connect=True):
|
||||||
nickname, username, realname, connect=False):
|
(_, alias, hostname, port, password, ipv4, tls, nickname,
|
||||||
new_server = IRCServer.Server(self, self._events, id, alias,
|
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,
|
hostname, port, password, ipv4, tls, nickname, username,
|
||||||
realname)
|
realname)
|
||||||
if not new_server.get_setting("connect", True):
|
if not new_server.get_setting("connect", True):
|
||||||
|
|
5
start.py
5
start.py
|
@ -29,10 +29,9 @@ whitelist = bot.get_setting("module-whitelist", [])
|
||||||
blacklist = bot.get_setting("module-blacklist", [])
|
blacklist = bot.get_setting("module-blacklist", [])
|
||||||
bot.modules.load_modules(whitelist=whitelist, blacklist=blacklist)
|
bot.modules.load_modules(whitelist=whitelist, blacklist=blacklist)
|
||||||
|
|
||||||
server_details = database.servers.get_all()
|
|
||||||
servers = []
|
servers = []
|
||||||
for server_detail in server_details:
|
for server_id, alias in database.servers.get_all():
|
||||||
server = bot.add_server(*server_detail)
|
server = bot.add_server(server_id, connect=False)
|
||||||
if not server == None:
|
if not server == None:
|
||||||
servers.append(server)
|
servers.append(server)
|
||||||
if len(servers):
|
if len(servers):
|
||||||
|
|
Loading…
Reference in a new issue