Files
site_aegisone/max_bot/app/keyboards/inline.py
T

91 lines
3.5 KiB
Python

from app.settings_cache import SettingsCache
def build_main_menu_buttons() -> list:
buttons = []
row = [
{"type": "message", "text": "📋 Оставить заявку", "payload": "new_inquiry"},
{"type": "message", "text": "📞 Связаться с оператором", "payload": "handoff"},
]
buttons.append(row)
features = SettingsCache.get_enabled_features()
feature_buttons = []
feature_map = {
"risk_score": ("📊 Risk Score", "feature_risk_score"),
"sla_status": ("🔍 SLA статус", "feature_sla_status"),
"photo_report": ("📸 Фото-отчёт", "feature_photo_report"),
"appointment": ("📅 Запись на визит", "feature_appointment"),
"quality_rate": ("⭐ Оценка качества", "feature_quality_rate"),
"commercial_offer": ("📄 Коммерческое предложение", "feature_commercial"),
"my_objects": ("🏢 Мои объекты", "feature_my_objects"),
"reminders": ("🔔 Напоминания", "feature_reminders"),
"notifications": ("🔔 Уведомления", "feature_notifications"),
"broadcasts": ("📢 Рассылки", "feature_broadcast"),
}
for key, (label, payload) in feature_map.items():
if key in features:
feature_buttons.append({"type": "message", "text": label, "payload": payload})
while feature_buttons:
buttons.append(feature_buttons[:2])
feature_buttons = feature_buttons[2:]
row = [{"type": "message", "text": "❓ Задать вопрос", "payload": "kb_search"}]
buttons.append(row)
return buttons
def build_consent_buttons() -> list:
return [[
{"type": "message", "text": "✅ Даю согласие", "payload": "consent_given"},
], [
{"type": "message", "text": "❌ Не даю согласие", "payload": "consent_refused"},
]]
def build_contact_buttons() -> list:
return [[
{"type": "request_contact", "text": "📱 Поделиться контактом"},
]]
def build_category_buttons() -> list:
categories = SettingsCache.get_categories()
buttons = []
row = []
for cat in categories:
row.append({"type": "message", "text": f"{cat.icon_emoji} {cat.name}", "payload": f"cat_{cat.id}"})
if len(row) >= 2:
buttons.append(row)
row = []
if row:
buttons.append(row)
return buttons
def build_quality_buttons() -> list:
return [[
{"type": "callback", "text": "", "payload": "rate_1"},
{"type": "callback", "text": "⭐⭐", "payload": "rate_2"},
{"type": "callback", "text": "⭐⭐⭐", "payload": "rate_3"},
], [
{"type": "callback", "text": "⭐⭐⭐⭐", "payload": "rate_4"},
{"type": "callback", "text": "⭐⭐⭐⭐⭐", "payload": "rate_5"},
]]
def build_cancel_button() -> list:
return [[{"type": "message", "text": "↩️ Отмена", "payload": "cancel"}]]
def build_phone_email_buttons(phone_1: str, phone_2: str, email: str, subject: str) -> list:
from urllib.parse import quote
buttons = [
[{"type": "link", "text": f"📞 {phone_1}", "url": f"tel:{phone_1.replace(' ', '').replace('-', '').replace('(', '').replace(')', '')}"}],
[{"type": "link", "text": f"📞 {phone_2}", "url": f"tel:{phone_2.replace(' ', '').replace('-', '').replace('(', '').replace(')', '')}"}],
[{"type": "link", "text": f"✉️ {email}", "url": f"mailto:{email}?subject={quote(subject)}"}],
]
return buttons