Files
Discord-Radio-Bot/main.py
Logan Cusano 72ccb1f737 - Updates to bot responses
- Added BotResources.py
- Updates to saving and loading of config file
  - Updated how you call the save config function
  - Allowed saving of one variable
2021-12-10 02:30:07 -05:00

61 lines
1.6 KiB
Python

import os
import time
import bot
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'
#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():
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()
print('Starting Bot...')
discord_bot_client = bot.Bot(config['Bot Token'], config['Device ID'], config['Device Name'],
config['Mention Group'], config['Channel ID'])
print(f"Verifying audio device:\t{config['Device Name']}")
if not discord_bot_client.check_device():
raise BotDeviceNotFound(config['Device Name'])
print("Bot started!")
discord_bot_client.start_bot()
if __name__ == '__main__':
#main()
#atexit.register()
try:
print('Starting...')
while True:
try:
main()
except BotDeviceNotFound:
print("Restarting...")
time.sleep(2)
except KeyboardInterrupt:
print("Exiting...")