78 lines
1.8 KiB
Python
78 lines
1.8 KiB
Python
from typing import 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"),
|
|
],
|
|
])
|