Dbu-central-bot / app /core /labels.py
cipher-attacks's picture
natural amharic
663fdd6
Raw History Blame Contribute Delete
413 Bytes
"""Short labels for buttons (pure, so they can be tested without Telegram)."""
def clip(text: str, n: int = 48) -> str:
return text if len(text) <= n else text[: n - 1] + "…"
def course_label(code, name: str) -> str:
"""One button line: "code · name" when it fits, else just the name."""
if code and len(code) + 3 + len(name) <= 36:
return f"{code} · {name}"
return clip(name, 36)