Files
shveitechbot/misc/mapper.py
2026-03-11 20:26:38 +07:00

12 lines
299 B
Python

def parse_cat_id(value: str) -> int | None | bool:
if value == "root":
return None
if str(value).isdigit():
return int(value)
raise Exception("Invalid Category Id.")
def serialize_cat_id(cat_id: int | None) -> str:
return "root" if cat_id is None else str(cat_id)