aboutsummaryrefslogtreecommitdiff
path: root/code/bot.py
diff options
context:
space:
mode:
Diffstat (limited to 'code/bot.py')
-rw-r--r--code/bot.py23
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)