2020-08-10 10:26:38 +02:00
|
|
|
"""
|
|
|
|
Main entrypoint script.
|
|
|
|
Sets up loggers and initiates bot.
|
2020-08-09 22:47:00 +02:00
|
|
|
"""
|
2020-08-05 02:07:29 +02:00
|
|
|
import logging
|
|
|
|
|
2020-07-23 06:21:41 +02:00
|
|
|
from discord.ext.commands import Bot
|
|
|
|
|
2020-08-09 22:47:00 +02:00
|
|
|
from . import load_config
|
2020-07-23 06:21:41 +02:00
|
|
|
from .bot import General
|
|
|
|
from .bot import Plex
|
2020-07-27 06:08:00 +02:00
|
|
|
|
|
|
|
# Load config from file
|
2020-07-23 06:21:41 +02:00
|
|
|
config = load_config("config.yaml")
|
|
|
|
|
|
|
|
BOT_PREFIX = config["discord"]["prefix"]
|
|
|
|
TOKEN = config["discord"]["token"]
|
|
|
|
|
|
|
|
BASE_URL = config["plex"]["base_url"]
|
|
|
|
PLEX_TOKEN = config["plex"]["token"]
|
|
|
|
LIBRARY_NAME = config["plex"]["library_name"]
|
2020-07-27 06:08:00 +02:00
|
|
|
|
2020-09-06 23:32:40 +02:00
|
|
|
LYRICS_TOKEN = config["lyrics"]["token"]
|
|
|
|
|
2020-07-27 06:08:00 +02:00
|
|
|
# Set appropiate log level
|
2020-08-09 08:28:14 +02:00
|
|
|
root_log = logging.getLogger()
|
|
|
|
plex_log = logging.getLogger("Plex")
|
|
|
|
bot_log = logging.getLogger("Bot")
|
|
|
|
|
|
|
|
plex_log.setLevel(config["plex"]["log_level"])
|
|
|
|
bot_log.setLevel(config["discord"]["log_level"])
|
2020-07-23 06:21:41 +02:00
|
|
|
|
2020-09-06 23:32:40 +02:00
|
|
|
plex_args = {
|
|
|
|
"base_url": BASE_URL,
|
|
|
|
"plex_token": PLEX_TOKEN,
|
|
|
|
"lib_name": LIBRARY_NAME,
|
|
|
|
"lyrics_token": LYRICS_TOKEN,
|
|
|
|
}
|
|
|
|
|
2020-07-23 06:21:41 +02:00
|
|
|
bot = Bot(command_prefix=BOT_PREFIX)
|
2020-08-13 10:52:22 +02:00
|
|
|
# Remove help command, we have our own custom one.
|
|
|
|
bot.remove_command("help")
|
2020-07-23 06:21:41 +02:00
|
|
|
bot.add_cog(General(bot))
|
2020-09-06 23:32:40 +02:00
|
|
|
bot.add_cog(Plex(bot, **plex_args))
|
2020-07-23 06:21:41 +02:00
|
|
|
bot.run(TOKEN)
|