Watch
1
0
Fork
You've already forked arc
0
forked from hesabix/arc
arc/hesabixAPI/app/services/messenger_operator/crm_callback_map.py
2026-05-07 22:21:45 +03:30

28 lines
792 B
Python
Executable file

# noqa: D100
from __future__ import annotations
def crm_callback_data_to_command(parts: list[str]) -> str | None:
"""تبدیل callback دکمه‌های crm:* به دستور متنی فلو اپراتور."""
if not parts:
return None
head = parts[0]
aliases = {
"start": "/crmchat",
"help": "/crmhelp",
"list": "/list",
"more": "/more",
"hist": "/history",
"cancel": "/cancel",
"exit": "/exit",
"stat": "/status",
}
if head in aliases:
return aliases[head]
if head == "biz" and len(parts) >= 2 and str(parts[1]).isdigit():
return f"/biz {parts[1]}"
if head == "open" and len(parts) >= 2 and str(parts[1]).isdigit():
return f"/open {parts[1]}"
if head == "pb" and len(parts) >= 2 and str(parts[1]).isdigit():
return f"/bizpick {parts[1]}"
return None