1
bot.py
1
bot.py
@@ -2,6 +2,7 @@ import asyncio
|
||||
import os
|
||||
import platform
|
||||
import discord
|
||||
|
||||
import BotResources
|
||||
import sound
|
||||
import configparser
|
||||
|
||||
32
main.py
32
main.py
@@ -27,21 +27,18 @@ class BotDeviceNotFound(Exception):
|
||||
|
||||
|
||||
def main(**passed_config):
|
||||
# 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)
|
||||
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
|
||||
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]
|
||||
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...')
|
||||
|
||||
@@ -109,21 +106,20 @@ def cmd_arguments():
|
||||
|
||||
return args
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cmd_args = cmd_arguments()
|
||||
args = cmd_arguments()
|
||||
|
||||
if not all(cmd_args.values()):
|
||||
if not all(args.values()):
|
||||
print("Passed arguments:")
|
||||
for arg in cmd_args:
|
||||
if cmd_args[arg]:
|
||||
print(f"\t{arg}:\t{cmd_args[arg]}")
|
||||
for arg in args:
|
||||
if args[arg]:
|
||||
print(f"\t{arg}:\t{args[arg]}")
|
||||
|
||||
try:
|
||||
print('Starting...')
|
||||
while True:
|
||||
try:
|
||||
main(**cmd_args)
|
||||
main(**args)
|
||||
except BotDeviceNotFound:
|
||||
print("Restarting...")
|
||||
time.sleep(2)
|
||||
|
||||
Reference in New Issue
Block a user