From 01ed329e2d4eb419a0000ff9a490f200dc6d9afd Mon Sep 17 00:00:00 2001 From: Zakhar Izmaylov Date: Sat, 1 Feb 2025 11:28:02 +0300 Subject: [PATCH] Enhance error handling with start menu fallback - Add fallback mechanism to display start menu after error occurs - Attempt to show start command or start callback query in error handler - Log any additional errors during start menu display --- bot.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bot.py b/bot.py index 027d2604..9797ca6a 100644 --- a/bot.py +++ b/bot.py @@ -47,6 +47,15 @@ async def errors_handler( ), caption=f"{hbold(type(event.exception).__name__)}: {str(event.exception)[:1021]}...", ) + try: + from handlers.start import start_command, handle_start_callback_query + + if event.update.message: + await start_command(event.update.message, state=dp.storage, session=None, admin=False, captcha=False) + elif event.update.callback_query: + await handle_start_callback_query(event.update.callback_query, state=dp.storage, session=None, admin=False, captcha=False) + except Exception as e: + logger.error(f"Ошибка при показе стартового меню после ошибки: {e}") except TelegramBadRequest as exception: logger.warning(f"Failed to send error details: {exception}") except Exception as exception: