-
Notifications
You must be signed in to change notification settings - Fork 25
/
simple_aiogram.py
36 lines (26 loc) · 1.14 KB
/
simple_aiogram.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
It absolutely the same for aiogram.
"""
from aiogram import Bot, Dispatcher, executor
from telegram_bot_calendar import DetailedTelegramCalendar, LSTEP
bot = Bot(token="token")
dp = Dispatcher(bot)
@dp.message_handler(commands='start')
async def start(message):
calendar, step = DetailedTelegramCalendar().build()
await bot.send_message(message.chat.id,
f"Select {LSTEP[step]}",
reply_markup=calendar)
@dp.callback_query_handler(DetailedTelegramCalendar.func())
async def inline_kb_answer_callback_handler(query):
result, key, step = DetailedTelegramCalendar().process(query.data)
if not result and key:
await bot.edit_message_text(f"Select {LSTEP[step]}",
query.message.chat.id,
query.message.message_id,
reply_markup=key)
elif result:
await bot.edit_message_text(f"You selected {result}",
query.message.chat.id,
query.message.message_id)
executor.start_polling(dp, skip_updates=True)