Files
duty-teller/handlers/errors.py
Nikolay Tatarinov dd960dc5cc Enhance Telegram bot functionality and improve error handling
- Introduced a new function to set the default menu button for the Telegram bot's Web App.
- Updated the initData validation process to provide detailed error messages for authorization failures.
- Refactored the validate_init_data function to return both username and reason for validation failure.
- Enhanced the web application to handle access denial more gracefully, providing users with hints on how to access the calendar.
- Improved the README with additional instructions for configuring the bot's menu button and Web App URL.
- Updated tests to reflect changes in the validation process and error handling.
2026-02-17 19:08:14 +03:00

15 lines
516 B
Python

"""Global error handler: log exception and notify user."""
import logging
from telegram import Update
from telegram.ext import ContextTypes
logger = logging.getLogger(__name__)
async def error_handler(update: Update | None, context: ContextTypes.DEFAULT_TYPE) -> None:
logger.exception("Exception while handling an update")
if isinstance(update, Update) and update.effective_message:
await update.effective_message.reply_text("Произошла ошибка. Попробуйте позже.")