Spaces:
Running on Zero
Running on Zero
File size: 413 Bytes
663fdd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 | """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)
|