diff options
Diffstat (limited to 'code/bot.py')
-rw-r--r-- | code/bot.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/code/bot.py b/code/bot.py index aafeb0d..2864e85 100644 --- a/code/bot.py +++ b/code/bot.py @@ -6,6 +6,7 @@ import openai import utils.config as config from utils.command_tree import Tree +from utils.media_api_key import get_media_api_key class MyBot(commands.Bot): @@ -19,6 +20,7 @@ class MyBot(commands.Bot): async def setup_hook(self): get_access_token.start() + refresh_media_api_key.start() config.LOG.info("Loading cogs...") for ext in os.listdir("./code/cogs"): if ext.endswith(".py"): @@ -59,6 +61,18 @@ async def get_access_token(): bot.spotify_headers = {"Authorization": f"Bearer {access_token}"} +@tasks.loop(hours=24) +async def refresh_media_api_key(): + media_api_key = get_media_api_key() + if media_api_key is not None: + bot.apple_headers = { + "Authorization": f"Bearer {media_api_key}", + "Origin": "https://apple.com", + } + else: + bot.apple_headers = None + + if __name__ == "__main__": config.load_config() bot.run(config.TOKEN) |