Add telegram bot
This commit is contained in:
1
bot/keyboards/__init__.py
Normal file
1
bot/keyboards/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# Bot keyboards
|
||||
42
bot/keyboards/inline.py
Normal file
42
bot/keyboards/inline.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
||||
|
||||
|
||||
def get_marathons_keyboard(marathons: list) -> InlineKeyboardMarkup:
|
||||
"""Create keyboard with marathon buttons."""
|
||||
buttons = []
|
||||
|
||||
for marathon in marathons:
|
||||
status_emoji = {
|
||||
"preparing": "⏳",
|
||||
"active": "🎮",
|
||||
"finished": "🏁"
|
||||
}.get(marathon.get("status"), "❓")
|
||||
|
||||
buttons.append([
|
||||
InlineKeyboardButton(
|
||||
text=f"{status_emoji} {marathon.get('title', 'Marathon')}",
|
||||
callback_data=f"marathon:{marathon.get('id')}"
|
||||
)
|
||||
])
|
||||
|
||||
return InlineKeyboardMarkup(inline_keyboard=buttons)
|
||||
|
||||
|
||||
def get_marathon_details_keyboard(marathon_id: int) -> InlineKeyboardMarkup:
|
||||
"""Create keyboard for marathon details view."""
|
||||
buttons = [
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text="🔄 Обновить",
|
||||
callback_data=f"marathon:{marathon_id}"
|
||||
)
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text="◀️ Назад к списку",
|
||||
callback_data="back_to_marathons"
|
||||
)
|
||||
]
|
||||
]
|
||||
|
||||
return InlineKeyboardMarkup(inline_keyboard=buttons)
|
||||
21
bot/keyboards/main_menu.py
Normal file
21
bot/keyboards/main_menu.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from aiogram.types import ReplyKeyboardMarkup, KeyboardButton
|
||||
|
||||
|
||||
def get_main_menu() -> ReplyKeyboardMarkup:
|
||||
"""Create main menu keyboard."""
|
||||
keyboard = [
|
||||
[
|
||||
KeyboardButton(text="📊 Мои марафоны"),
|
||||
KeyboardButton(text="📈 Статистика")
|
||||
],
|
||||
[
|
||||
KeyboardButton(text="⚙️ Настройки"),
|
||||
KeyboardButton(text="❓ Помощь")
|
||||
]
|
||||
]
|
||||
|
||||
return ReplyKeyboardMarkup(
|
||||
keyboard=keyboard,
|
||||
resize_keyboard=True,
|
||||
input_field_placeholder="Выбери действие..."
|
||||
)
|
||||
Reference in New Issue
Block a user