67 lines
1.9 KiB
Python
67 lines
1.9 KiB
Python
import os
|
|
import time
|
|
import bot
|
|
import argparse
|
|
from BotResources import check_if_config_exists, write_config_file, read_config_file
|
|
|
|
# Jorn
|
|
#token = 'OTE1MDY0OTk2OTk0NjMzNzI5.YaWKsA.Y9yaCGg_VXRL_qQVbs05vo7gSAc'
|
|
|
|
# Greada
|
|
#token = 'NzU2MzI3MjcxNTk3NDczODYz.X2QOqQ.LVLj2b-RXQzPmhNuBC1eGFMcYls'
|
|
|
|
# Brent
|
|
#token = OTQzNzQyMDQwMjU1MTE1MzA0.Yg3eRA.ZxEbRr55xahjfaUmPY8pmS-RHTY
|
|
|
|
#name = "VoiceMeeter Output"
|
|
|
|
|
|
class BotDeviceNotFound(Exception):
|
|
def __init__(self, device):
|
|
print(f"Unable to find the device: {device}")
|
|
try:
|
|
os.remove('./config.ini')
|
|
except OSError:
|
|
print("Config file not found, restarting.")
|
|
#os.execv(__file__, sys.argv)
|
|
|
|
|
|
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, **passed_config)
|
|
|
|
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:
|
|
config[sub] = passed_config[sub]
|
|
|
|
print('Starting Bot...')
|
|
|
|
discord_bot_client = bot.Bot(Token=config['Bot Token'], Device_ID=config['Device ID'], Device_Name=config['Device Name'],
|
|
Mention_Group=config['Mention Group'], Channel_ID=config['Channel ID'], Handler=config['Handler'])
|
|
|
|
print(f"Verifying audio device:\t{config['Device Name']}")
|
|
|
|
if not discord_bot_client.check_device():
|
|
raise BotDeviceNotFound(config['Device Name'])
|
|
|
|
discord_bot_client.start_bot()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
try:
|
|
print('Starting...')
|
|
while True:
|
|
try:
|
|
main()
|
|
except BotDeviceNotFound:
|
|
print("Restarting...")
|
|
time.sleep(2)
|
|
except KeyboardInterrupt:
|
|
print("Exiting...")
|