From 264c099fad43bdc8688e002b671c47ec8a161d31 Mon Sep 17 00:00:00 2001 From: Conner Harkness Date: Tue, 11 Mar 2025 08:42:23 -0600 Subject: [PATCH] Added ability to specify custom conf directory --- .gitignore | 1 + comfyui-discord.sh | 0 lib/events.py | 26 +++++++++++++++----------- lib/settings.py | 1 + 4 files changed, 17 insertions(+), 11 deletions(-) mode change 100644 => 100755 comfyui-discord.sh diff --git a/.gitignore b/.gitignore index f7d7393..0c1a696 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ __pycache__/ /*.log.txt /*.log.txt.* /database.db +/conf_2 diff --git a/comfyui-discord.sh b/comfyui-discord.sh old mode 100644 new mode 100755 diff --git a/lib/events.py b/lib/events.py index 73aaa73..92b36e1 100644 --- a/lib/events.py +++ b/lib/events.py @@ -54,6 +54,10 @@ async def on_message_or_reaction(client, obj): # # + settings = get_settings() + + CONFIG_DIR = settings["config_dir"] + chl_topic_parts = [] chl_topic_part_1 = "" if chl.topic is not None: @@ -62,11 +66,11 @@ async def on_message_or_reaction(client, obj): # Try different paths to find workflow .json file: workflow_paths = [ - f"conf/{chl.category.name}/{chl_topic_part_1}", - f"conf/{chl.category.name}/{chl.name}", - f"conf/{chl_topic_part_1}", - f"conf/{chl.name}", - f"conf/{chl.category.name}", + f"{CONFIG_DIR}{chl.category.name}/{chl_topic_part_1}", + f"{CONFIG_DIR}{chl.category.name}/{chl.name}", + f"{CONFIG_DIR}{chl_topic_part_1}", + f"{CONFIG_DIR}{chl.name}", + f"{CONFIG_DIR}{chl.category.name}", ] using_workflow_path = None @@ -86,19 +90,19 @@ async def on_message_or_reaction(client, obj): # setting_paths = [ - f"conf/{chl.category.name}", - f"conf/{chl.name}", + f"{CONFIG_DIR}{chl.category.name}", + f"{CONFIG_DIR}{chl.name}", ] for i in chl_topic_parts: - setting_paths = setting_paths + ["conf/" + i.strip()] + setting_paths = setting_paths + [{CONFIG_DIR} + i.strip()] - setting_paths = setting_paths + [f"conf/{chl.category.name}/{chl.name}"] + setting_paths = setting_paths + [f"{CONFIG_DIR}{chl.category.name}/{chl.name}"] for i in chl_topic_parts: - setting_paths = setting_paths + [f"conf/{chl.category.name}/" + i.strip()] + setting_paths = setting_paths + [f"{CONFIG_DIR}{chl.category.name}/" + i.strip()] - settings = get_settings() + for path in setting_paths: try_path = f"{path}_settings.json" diff --git a/lib/settings.py b/lib/settings.py index 3518a3a..1727e80 100644 --- a/lib/settings.py +++ b/lib/settings.py @@ -8,6 +8,7 @@ def get_settings(initialize=False): "handler_name": "default", "token": "PASTE_TOKEN_HERE", "api_url": "http://127.0.0.1:8188", + "config_dir": "conf/", "allow_repeat": True, "show_repeat": True, "repeat_emoji": "♻️",