From 35c9bda23f5c1037d474e2347222820b87e4e4a1 Mon Sep 17 00:00:00 2001 From: insert Date: Sun, 12 Jan 2025 00:34:43 -0500 Subject: [PATCH] Short modifications --- .env.example | 1 + .gitignore | 4 +++- newbot.py | 8 +++++--- shell.nix | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index e01f8d1..848b9cb 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,6 @@ TOKEN="" GUILD_ID="" +QUEUE_PATH="" MAX_MIN="8" MAX_QUEUE="5" ALLOW_SKIP="TRUE" diff --git a/.gitignore b/.gitignore index 964cb94..60edee5 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,8 @@ share/python-wheels/ *.mp4 *.vtt testing/ +*.db +next* MANIFEST # PyInstaller @@ -129,7 +131,7 @@ celerybeat.pid # Environments .env -.venv +.*venv env/ venv/ ENV/ diff --git a/newbot.py b/newbot.py index 8b602d0..0296dec 100644 --- a/newbot.py +++ b/newbot.py @@ -19,7 +19,8 @@ import sqlite3 if len(sys.argv) > 1: if sys.argv[1] == "--clear-queue": - os.remove("queue.db") + if os.path.isfile(os.getenv("QUEUE_PATH","queue.db")): + os.remove(os.getenv("QUEUE_PATH","queue.db")) print("Queue cleared!") load_dotenv() @@ -34,7 +35,7 @@ vid_dir = Path(temp_dir.name) download_dir = TemporaryDirectory() full_dl_dir = Path(download_dir.name) vid_details = {"title": "", "channel": ""} -con = sqlite3.connect("queue.db", check_same_thread=False) +con = sqlite3.connect(os.getenv("QUEUE_PATH","queue.db"), check_same_thread=False) cur = con.cursor() def countuser(usrid): @@ -264,7 +265,7 @@ async def stats(inter: disnake.AppCmdInter): message = message + f"Link: <{queue[0]}>\n" playing = obs.get_media_input_status("player") message = message + f"Video Duration: {str(datetime.timedelta(seconds=(round(playing.media_cursor/1000))))}/{str(datetime.timedelta(seconds=(round(playing.media_duration/1000))))}\n" - if inter.permissions.moderate_members and not (os.getenv("PERMANENT_MAX_QUEUE","FALSE") == "TRUE"): + if inter.permissions.moderate_members: res = cur.execute(f"SELECT user FROM queue WHERE hasplayed = true AND link = '{queue[0]}'") res = res.fetchall() #We can't gaurentee the result so just show likely possibilites message = message + f"Users who have queued this video: " @@ -601,4 +602,5 @@ bot.run(os.getenv("TOKEN")) print("cleaning up tempdir") temp_dir.cleanup() download_dir.cleanup() +con.close() obs.set_current_program_scene("nosignal") \ No newline at end of file diff --git a/shell.nix b/shell.nix index 6f714fd..91d8e60 100644 --- a/shell.nix +++ b/shell.nix @@ -10,8 +10,8 @@ pkgs.mkShell { pkgs.python311Packages.python-dotenv pkgs.python311Packages.venvShellHook pkgs.ffmpeg - pkgs.icewm pkgs.discord + pkgs.mpv ]; venvDir = "./.venv"; } \ No newline at end of file