Undo revert

This commit is contained in:
Logan Cusano
2022-03-16 01:34:02 -04:00
parent 73fa560040
commit a1f9869e8e
2 changed files with 19 additions and 16 deletions

1
bot.py
View File

@@ -2,7 +2,6 @@ import asyncio
import os
import platform
import discord
import BotResources
import sound
import configparser

34
main.py
View File

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