Try avatar exact match before lower()
This commit is contained in:
parent
cefadb2b91
commit
a0b5b11e4a
1 changed files with 9 additions and 2 deletions
11
admission.py
11
admission.py
|
@ -26,8 +26,15 @@ def webhook_online(stream) -> None:
|
||||||
data = {"username": f"{config.WEBHOOK_NAME} Online", "content": config.WEBHOOK_ONLINE}
|
data = {"username": f"{config.WEBHOOK_NAME} Online", "content": config.WEBHOOK_ONLINE}
|
||||||
|
|
||||||
if config.is_avatar_ready():
|
if config.is_avatar_ready():
|
||||||
target_av = f"{stream[1]}/{stream[2]}.png".lower()
|
target_av = f"{stream[1]}/{stream[2]}.png"
|
||||||
avatar = target_av if Path(config.WEBHOOK_AVATAR_PATH, target_av).is_file() else "default.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}"
|
data["avatar_url"] = f"{config.WEBHOOK_AVATAR_URL}/{avatar}"
|
||||||
|
|
||||||
requests.post(config.WEBHOOK_URL, timeout=10, json=data, headers=config.WEBHOOK_HEADERS)
|
requests.post(config.WEBHOOK_URL, timeout=10, json=data, headers=config.WEBHOOK_HEADERS)
|
||||||
|
|
Loading…
Add table
Reference in a new issue