From a0b5b11e4aaa87f190c7cc3904d0eb294544e180 Mon Sep 17 00:00:00 2001 From: Trysdyn Black Date: Tue, 18 Feb 2025 13:18:09 -0800 Subject: [PATCH] Try avatar exact match before `lower()` --- admission.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/admission.py b/admission.py index 250843b..1e4c5b3 100644 --- a/admission.py +++ b/admission.py @@ -26,8 +26,15 @@ def webhook_online(stream) -> None: data = {"username": f"{config.WEBHOOK_NAME} Online", "content": config.WEBHOOK_ONLINE} if config.is_avatar_ready(): - target_av = f"{stream[1]}/{stream[2]}.png".lower() - avatar = target_av if Path(config.WEBHOOK_AVATAR_PATH, target_av).is_file() else "default.png" + target_av = f"{stream[1]}/{stream[2]}.png" + + # Try an exact match first, then lower case, then use the default + if Path(config.WEBHOOK_AVATAR_PATH, target_av).is_file(): + avatar = target_av + elif Path(config.WEBHOOK_AVATAR_PATH, target_av.lower()).is_file(): + avatar = target_av.lower() + else: + avatar = "default.png" data["avatar_url"] = f"{config.WEBHOOK_AVATAR_URL}/{avatar}" requests.post(config.WEBHOOK_URL, timeout=10, json=data, headers=config.WEBHOOK_HEADERS)