diff --git a/bot.py b/bot.py index 24e9e25..e35d144 100644 --- a/bot.py +++ b/bot.py @@ -2,7 +2,6 @@ import asyncio import os import platform import discord - import BotResources import sound import configparser diff --git a/main.py b/main.py index f401c0e..8887442 100644 --- a/main.py +++ b/main.py @@ -27,18 +27,21 @@ class BotDeviceNotFound(Exception): def main(**passed_config): - print('Checking config file...') - if not check_if_config_exists(): - print("No config file exists, please enter this information now") - write_config_file(init=True) + # Don't create a config if the user passed parameters + if len(passed_config.keys()) == 0: + print('Checking config file...') + if not check_if_config_exists(): + print("No config file exists, please enter this information now") + write_config_file(init=True) config = read_config_file() # Overwrite config options if they were passed - for sub in config: - # checking if key present in other dictionary - if sub in passed_config and passed_config[sub]: - config[sub] = passed_config[sub] + if len(passed_config.keys()) == 0: + for sub in config: + # checking if key present in other dictionary + if sub in passed_config and passed_config[sub]: + config[sub] = passed_config[sub] print('Starting Bot...') @@ -106,20 +109,21 @@ def cmd_arguments(): return args -if __name__ == '__main__': - args = cmd_arguments() - if not all(args.values()): +if __name__ == '__main__': + cmd_args = cmd_arguments() + + if not all(cmd_args.values()): print("Passed arguments:") - for arg in args: - if args[arg]: - print(f"\t{arg}:\t{args[arg]}") + for arg in cmd_args: + if cmd_args[arg]: + print(f"\t{arg}:\t{cmd_args[arg]}") try: print('Starting...') while True: try: - main(**args) + main(**cmd_args) except BotDeviceNotFound: print("Restarting...") time.sleep(2)