Try avatar exact match before lower()

This commit is contained in:
Trysdyn Black 2025-02-18 13:18:09 -08:00
parent cefadb2b91
commit a0b5b11e4a

View file

@ -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)