This commit is contained in:
@@ -13,10 +13,10 @@ dp = Dispatcher(bot)
|
||||
|
||||
menu_kb = InlineKeyboardMarkup(row_width=2)
|
||||
menu_kb.add(
|
||||
InlineKeyboardButton("▶️ Pomodoro", callback_data="pomodoro"),
|
||||
InlineKeyboardButton("☕ Short Break", callback_data="shortbreak"),
|
||||
InlineKeyboardButton("😌 Long Break", callback_data="longbreak"),
|
||||
InlineKeyboardButton("⏹ Stop", callback_data="stop")
|
||||
InlineKeyboardButton("▶️ Pomodoro", callback_data="action_pomodoro"),
|
||||
InlineKeyboardButton("☕ Short Break", callback_data="action_shortbreak"),
|
||||
InlineKeyboardButton("😌 Long Break", callback_data="action_longbreak"),
|
||||
InlineKeyboardButton("⏹ Stop", callback_data="action_stop")
|
||||
)
|
||||
|
||||
|
||||
@@ -31,20 +31,20 @@ async def on_startup(dispatcher):
|
||||
async def send_welcome(message: Message):
|
||||
await message.reply("Привет! Я твой личный Pomodoro-бот. Выбирай действие:", reply_markup=menu_kb)
|
||||
|
||||
@dispatcher.callback_query_handler(lambda call: call.data in ["pomodoro", "shortbreak", "longbreak", "stop"])
|
||||
@dispatcher.callback_query_handler(lambda call: call.data.startswith("action_"))
|
||||
async def handle_callback(call: types.CallbackQuery):
|
||||
timer_manager = dispatcher['timer_manager']
|
||||
|
||||
if call.data == "pomodoro":
|
||||
if call.data == "action_pomodoro":
|
||||
await timer_manager.start_timer(call.from_user.id, 25*60, call.message.chat.id, 'Pomodoro')
|
||||
await call.message.answer("Начался 25-минутный Pomodoro! 🔥")
|
||||
elif call.data == "shortbreak":
|
||||
elif call.data == "action_shortbreak":
|
||||
await timer_manager.start_timer(call.from_user.id, 5*60, call.message.chat.id, 'Short Break')
|
||||
await call.message.answer("Начался 5-минутный перерыв ☕")
|
||||
elif call.data == "longbreak":
|
||||
elif call.data == "action_longbreak":
|
||||
await timer_manager.start_timer(call.from_user.id, 15*60, call.message.chat.id, 'Long Break')
|
||||
await call.message.answer("Начался длинный перерыв 😌")
|
||||
elif call.data == "stop":
|
||||
elif call.data == "action_stop":
|
||||
await timer_manager.stop_timer(call.from_user.id)
|
||||
await call.message.answer("Таймер остановлен ⏹")
|
||||
await call.answer()
|
||||
|
||||
Reference in New Issue
Block a user