- Added support for CORS origins and a new environment variable for miniapp access control. - Implemented date validation for API requests to ensure correct date formats. - Updated FastAPI app to allow access without Telegram initData for local development. - Enhanced error handling and logging for better debugging. - Added tests for API functionality and Telegram initData validation. - Updated README with new environment variable details and testing instructions. - Modified Docker and Git ignore files to include additional directories and files.
14 lines
508 B
Python
14 lines
508 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: object, 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("Произошла ошибка. Попробуйте позже.")
|