fix
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-03-28 22:38:51 +05:00
parent d98021f79a
commit 701d940790

View File

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