utils.cli shouldn't know about Database
This commit is contained in:
parent
46e4b75f6b
commit
40a340e94f
2 changed files with 11 additions and 5 deletions
10
bitbotd
10
bitbotd
|
@ -103,9 +103,15 @@ if args.remove_server:
|
|||
sys.stderr.write("Unknown server '%s'\n" % alias)
|
||||
sys.exit(0)
|
||||
|
||||
def _add_server():
|
||||
details = utils.cli.add_server()
|
||||
|
||||
database.servers.add(details.alias, details.hostname, details.port,
|
||||
details.password, details.tls, details.bindhost, details.nickname,
|
||||
details.username, details.realname)
|
||||
if args.add_server:
|
||||
print("Adding a new server")
|
||||
utils.cli.add_server(database)
|
||||
_add_server()
|
||||
sys.exit(0)
|
||||
|
||||
cache = Cache.Cache()
|
||||
|
@ -169,7 +175,7 @@ if len(server_configs):
|
|||
else:
|
||||
try:
|
||||
if utils.cli.bool_input("no servers found, add one?"):
|
||||
utils.cli.add_server(database)
|
||||
_add_server()
|
||||
except KeyboardInterrupt:
|
||||
print()
|
||||
pass
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
from src import Database
|
||||
from . import irc
|
||||
|
||||
def bool_input(s: str):
|
||||
result = input("%s (Y/n): " % s)
|
||||
return not result or result[0].lower() in ["", "y"]
|
||||
|
||||
def add_server(database: "Database.Database"):
|
||||
def add_server():
|
||||
alias = input("alias: ")
|
||||
hostname = input("hostname: ")
|
||||
port = int(input("port: "))
|
||||
|
@ -15,5 +15,5 @@ def add_server(database: "Database.Database"):
|
|||
realname = input("realname: ")
|
||||
bindhost = input("bindhost?: ")
|
||||
|
||||
server_id = database.servers.add(alias, hostname, port, password, tls,
|
||||
return irc.IRCConnectionParameters(-1, alias, hostname, port, password, tls,
|
||||
bindhost, nickname, username, realname)
|
||||
|
|
Loading…
Reference in a new issue