danbooru-bot/extensions.py
mctaylors c70d7fe3be
refactor: completely rewrite humanize_tags_from_json
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2025-05-18 12:30:22 +03:00

24 lines
660 B
Python

import re
def humanize_tags_from_json(value: str, default: str) -> str:
if value != "":
return ", ".join([re.sub('_\\(.*', '', t) for t in value.split()])
return default
def format_rating(value: str) -> str | None:
match value:
case "g":
# Negative Squared Latin Capital Letter G
return "๐Ÿ…ถ"
case "s":
# Negative Squared Latin Capital Letter S
return "๐Ÿ†‚"
case "q":
# Negative Squared Latin Capital Letter Q
return "๐Ÿ†€"
case "e":
# Negative Squared Latin Capital Letter E
return "๐Ÿ…ด"
return None