From f85a6375668d2de5e8996680c156bbc35786f893 Mon Sep 17 00:00:00 2001 From: Rich Oberholtzer Date: Sat, 11 Apr 2020 12:20:09 -0400 Subject: [PATCH] added read in of command prefix and updated bot creation to use config. Also moved bot object creation to after read in of prefix config --- r0b3bot.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/r0b3bot.py b/r0b3bot.py index 8b6075e..04f315b 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -17,7 +17,6 @@ from discord.voice_client import VoiceClient import requests import asyncio -bot = commands.Bot(command_prefix='$', description='A derpy derp of a bot.') #Record the time the bot started start_time = time.time() @@ -37,6 +36,10 @@ try: except: print("Error loading config! Please check config file 'bot-config.conf'") +# +# Read in bot configurations +# + # Setup HomeAssistant URL and Headers HASS_TOKEN = config.get('bot-config', 'hass_token') HASS_URL = config.get('bot-config', 'hass_url') @@ -49,6 +52,7 @@ hassHEADERS = { OCTOPRINT_IP_ADDRESS = config.get('bot-config', 'octoprint_ip_address') DISCORD_AUTH_TOKEN = config.get('bot-config', 'discord_auth_token') +BOT_COMMAND_PREFIX = config.get('bot-config', 'bot_command_prefix') STATPING_URL = config.get('bot-config', 'statping_url') STATPING_API_KEY = config.get('bot-config', 'statping_api_key') statpingURL = STATPING_URL + "/api/services" @@ -57,6 +61,9 @@ statpingHEADERS = { 'content-type': 'application/json', } +# Configure bot +bot = commands.Bot(command_prefix=BOT_COMMAND_PREFIX, description='A derpy derp of a bot.') + # Printing configuration details to console print(f"HomeAssistant URL: {hassURL}") print(f"HomeAssistant URL HEADERS: {hassHEADERS}")