diff options
author | Parker <contact@pkrm.dev> | 2025-01-19 23:41:53 -0600 |
---|---|---|
committer | Parker <contact@pkrm.dev> | 2025-01-19 23:41:53 -0600 |
commit | b5bd2e36b6597303985eb9dc897e04d452950372 (patch) | |
tree | 697e269911c752ce8c196c7be486df5b5871b85a /code/bot.py | |
parent | 86b12da175593f91cb5e3266826a60d1b26f6144 (diff) |
Overhaul + Sonarr support!
Diffstat (limited to 'code/bot.py')
-rw-r--r-- | code/bot.py | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/code/bot.py b/code/bot.py index e8dc418..b7654c6 100644 --- a/code/bot.py +++ b/code/bot.py @@ -1,13 +1,10 @@ import discord from discord.ext import commands from discord.ext import tasks -import datetime -import sqlite3 import os -from validate_config import create_config -from func.jellyfin import delete_jellyfin_account -from global_variables import LOG, BOT_TOKEN +import utils.config as config +from utils.jellyfin_delete import delete_accounts class MyBot(commands.Bot): @@ -18,7 +15,6 @@ class MyBot(commands.Bot): ) async def setup_hook(self): - create_config() delete_old_temp_accounts.start() for ext in os.listdir("./code/cogs"): if ext.endswith(".py"): @@ -31,21 +27,14 @@ bot.remove_command("help") @bot.event async def on_ready(): - LOG.info(f"{bot.user} has connected to Discord.") + config.LOG.info(f"{bot.user} has connected to Discord.") @tasks.loop(seconds=60) async def delete_old_temp_accounts(): - # Get all jellyfin user IDs that have passed their deletion time - db = sqlite3.connect("cordarr.db") - cursor = db.cursor() - cursor.execute("SELECT jellyfin_user_id FROM jellyfin_accounts WHERE deletion_time < ?", (datetime.datetime.now(),)) - jellyfin_user_ids = cursor.fetchall() - - # Delete the Jellyfin accounts - for jellyfin_user_id in jellyfin_user_ids: - delete_jellyfin_account(jellyfin_user_id[0]) + delete_accounts() if __name__ == "__main__": - bot.run(BOT_TOKEN) + config.load_config() + bot.run(config.BOT_TOKEN) |