72b6879f4b
- Refactored max_bot from nested packages to flat module structure - Q2: Extended BotUser model (patronymic, email, org, address, vcf_raw, contact_hash, phone_verified, email_verified, last_interaction, total_conversations, total_tickets) - Q2: VCF parser (FN, N, TEL, EMAIL, ORG, ADR), upsert on re-contact, NLP history context (_get_user_history_context -> YandexGPT) - Q1: Broadcast preview modal with 10s confirmation timer - Q3: CSS var(--white)->var(--bg-card), var(--text)->var(--text-primary) - Q4: bot_settings showNotification(), editable max_bot_id - Q5: Webhook secret passthrough via X-Max-Bot-Api-Secret - Masking sensitive keys, dialog_cleared handler, migrate via _add_column_if_not_exists() - Rate limit (asyncio.sleep 0.5 per 10), dead code removed, conv.intent context in contact.py - Portal pages: bot_consent, bot_kb (edit), bot_settings, bot_test, bot_tickets, portal_settings - Tests: 21/21 passing, added test_yandex_gpt.py, test_email_sender.py - Deploy: deploy_full.sh, schema.sql, seed_knowledge_base.sql
78 lines
1.8 KiB
Python
78 lines
1.8 KiB
Python
from typing import Optional, List, Dict, Any
|
|
|
|
POLITICA_URL = "https://aegisone.ru/politica.php"
|
|
|
|
|
|
def _callback_button(text: str, payload: str, intent: str = "default") -> dict:
|
|
return {
|
|
"type": "callback",
|
|
"text": text,
|
|
"payload": payload,
|
|
"intent": intent,
|
|
}
|
|
|
|
|
|
def _link_button(text: str, url: str) -> dict:
|
|
return {
|
|
"type": "link",
|
|
"text": text,
|
|
"url": url,
|
|
}
|
|
|
|
|
|
def _request_contact_button(text: str) -> dict:
|
|
return {
|
|
"type": "request_contact",
|
|
"text": text,
|
|
}
|
|
|
|
|
|
def _message_button(text: str) -> dict:
|
|
return {
|
|
"type": "message",
|
|
"text": text,
|
|
}
|
|
|
|
|
|
def make_inline_keyboard(buttons: List[List[Dict[str, Any]]]) -> List[Dict[str, Any]]:
|
|
return [
|
|
{
|
|
"type": "inline_keyboard",
|
|
"payload": {"buttons": buttons},
|
|
}
|
|
]
|
|
|
|
|
|
def consent_keyboard() -> list:
|
|
return make_inline_keyboard([
|
|
[
|
|
_callback_button("✅ Даю согласие", "consent_yes", intent="positive"),
|
|
_link_button("📄 Подробнее", POLITICA_URL),
|
|
_callback_button("❌ Не даю согласие", "consent_no", intent="negative"),
|
|
],
|
|
])
|
|
|
|
|
|
def contact_keyboard() -> list:
|
|
return make_inline_keyboard([
|
|
[
|
|
_request_contact_button("📱 Поделиться контактом"),
|
|
],
|
|
])
|
|
|
|
|
|
def single_button_keyboard(text: str, payload: str, intent: str = "default") -> list:
|
|
return make_inline_keyboard([
|
|
[
|
|
_callback_button(text, payload, intent),
|
|
],
|
|
])
|
|
|
|
|
|
def return_to_consent_keyboard() -> list:
|
|
return make_inline_keyboard([
|
|
[
|
|
_callback_button("✅ Даю согласие", "consent_yes", intent="positive"),
|
|
],
|
|
])
|