From e47a42370d91e3cf2cce12e324f7cf293a5f0174 Mon Sep 17 00:00:00 2001 From: Conner Harkness Date: Wed, 12 Mar 2025 12:13:38 -0600 Subject: [PATCH] Changed cascading configuration to reflect old project's method --- .gitignore | 35 ++++++++++++++++-- .../put_category_names_or_ids_here | 0 .../put_channel_names_or_ids_here | 0 .../example-workflow.json} | 0 conf/defaults/put_channel_topic_tokens_here | 0 .../put_guild_names_or_ids_here | 0 conf/role_defaults/put_role_names_or_ids_here | 0 conf/user_defaults/put_user_names_or_ids_here | 0 conf/{ => workflows}/example-workflow.json | 0 conf/workflows/put_comfyui_api_workflows_here | 0 lib/comfyui.py | 2 - lib/events.py | 37 +++++++++---------- 12 files changed, 49 insertions(+), 25 deletions(-) create mode 100644 conf/category_defaults/put_category_names_or_ids_here create mode 100644 conf/channel_defaults/put_channel_names_or_ids_here rename conf/{example-workflow_settings.json => defaults/example-workflow.json} (100%) create mode 100644 conf/defaults/put_channel_topic_tokens_here create mode 100644 conf/guild_defaults/put_guild_names_or_ids_here create mode 100644 conf/role_defaults/put_role_names_or_ids_here create mode 100644 conf/user_defaults/put_user_names_or_ids_here rename conf/{ => workflows}/example-workflow.json (100%) create mode 100644 conf/workflows/put_comfyui_api_workflows_here diff --git a/.gitignore b/.gitignore index 0c1a696..399c547 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,41 @@ +# Ignore Python-related directories: __pycache__/ /venv/ + +# Ignore auto-generated settings.json: /settings.json -/conf/* -!/conf/example-workflow.json -!/conf/example-workflow_settings.json + +# Ignore configuration in subdirectories: +/conf/category_defaults/* +/conf/channel_defaults/* +/conf/defaults/* +/conf/guild_defaults/* +/conf/role_defaults/* +/conf/user_defaults/* +/conf/workflows/* + +# Keep stubs for directory structure: +!/conf/category_defaults/put_category_names_or_ids_here +!/conf/channel_defaults/put_channel_names_or_ids_here +!/conf/defaults/put_channel_topic_tokens_here +!/conf/guild_defaults/put_guild_names_or_ids_here +!/conf/role_defaults/put_role_names_or_ids_here +!/conf/user_defaults/put_user_names_or_ids_here +!/conf/workflows/put_comfyui_api_workflows_here + +# Keep example .json files: +!/conf/defaults/example-workflow.json +!/conf/workflows/example-workflow.json + +# Ignore rotating logs: /log.txt /log.txt.* /*.log.txt /*.log.txt.* + +# Ignore statistics logging database: /database.db + +# Ignore proposed alternative config directory: /conf_2 +/conf_2/ diff --git a/conf/category_defaults/put_category_names_or_ids_here b/conf/category_defaults/put_category_names_or_ids_here new file mode 100644 index 0000000..e69de29 diff --git a/conf/channel_defaults/put_channel_names_or_ids_here b/conf/channel_defaults/put_channel_names_or_ids_here new file mode 100644 index 0000000..e69de29 diff --git a/conf/example-workflow_settings.json b/conf/defaults/example-workflow.json similarity index 100% rename from conf/example-workflow_settings.json rename to conf/defaults/example-workflow.json diff --git a/conf/defaults/put_channel_topic_tokens_here b/conf/defaults/put_channel_topic_tokens_here new file mode 100644 index 0000000..e69de29 diff --git a/conf/guild_defaults/put_guild_names_or_ids_here b/conf/guild_defaults/put_guild_names_or_ids_here new file mode 100644 index 0000000..e69de29 diff --git a/conf/role_defaults/put_role_names_or_ids_here b/conf/role_defaults/put_role_names_or_ids_here new file mode 100644 index 0000000..e69de29 diff --git a/conf/user_defaults/put_user_names_or_ids_here b/conf/user_defaults/put_user_names_or_ids_here new file mode 100644 index 0000000..e69de29 diff --git a/conf/example-workflow.json b/conf/workflows/example-workflow.json similarity index 100% rename from conf/example-workflow.json rename to conf/workflows/example-workflow.json diff --git a/conf/workflows/put_comfyui_api_workflows_here b/conf/workflows/put_comfyui_api_workflows_here new file mode 100644 index 0000000..e69de29 diff --git a/lib/comfyui.py b/lib/comfyui.py index 7db71c0..4de7ec5 100644 --- a/lib/comfyui.py +++ b/lib/comfyui.py @@ -22,8 +22,6 @@ async def get_comfyui_generations(api_url, workflow): continue break - print(resp_json) - # Read the output history anmd fetch each image: history = resp_json[prompt_id] output_images = [] diff --git a/lib/events.py b/lib/events.py index 92b36e1..ac472c2 100644 --- a/lib/events.py +++ b/lib/events.py @@ -64,19 +64,9 @@ async def on_message_or_reaction(client, obj): chl_topic_parts = chl.topic.split(",") chl_topic_part_1 = chl_topic_parts[0] - # Try different paths to find workflow .json file: - workflow_paths = [ - 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 - using_settings_path = None - for path in workflow_paths: + for path in [f"{CONFIG_DIR}workflows/{chl_topic_part_1}"]: try_path = f"{path}.json" if os.path.isfile(try_path): using_workflow_path = try_path @@ -90,22 +80,29 @@ async def on_message_or_reaction(client, obj): # setting_paths = [ - f"{CONFIG_DIR}{chl.category.name}", - f"{CONFIG_DIR}{chl.name}", + f"{CONFIG_DIR}guild_defaults/{chl.guild.id}", + f"{CONFIG_DIR}guild_defaults/{chl.guild.name}", + f"{CONFIG_DIR}category_defaults/{chl.category.id}", + f"{CONFIG_DIR}category_defaults/{chl.category.name}", + f"{CONFIG_DIR}channel_defaults/{chl.id}", + f"{CONFIG_DIR}channel_defaults/{chl.name}", ] for i in chl_topic_parts: - setting_paths = setting_paths + [{CONFIG_DIR} + i.strip()] + chl_topic_part = i.strip() + setting_paths = setting_paths + [f"{CONFIG_DIR}defaults/{chl_topic_part}"] - setting_paths = setting_paths + [f"{CONFIG_DIR}{chl.category.name}/{chl.name}"] + for r in roles: + setting_paths = setting_paths + [f"{CONFIG_DIR}role_defaults/{r.name}"] - for i in chl_topic_parts: - setting_paths = setting_paths + [f"{CONFIG_DIR}{chl.category.name}/" + i.strip()] - - + setting_paths = setting_paths + [ + f"{CONFIG_DIR}user_defaults/{user.id}", + f"{CONFIG_DIR}user_defaults/{user.name}", + ] for path in setting_paths: - try_path = f"{path}_settings.json" + try_path = f"{path}.json" + log.write(f"Seeking {try_path}") if os.path.isfile(try_path): settings = merge_dicts(settings, read_json(try_path, {})) log.write(f"Merging {log.colors.fg.lightcyan}{try_path}")