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.
This commit is contained in:
2026-02-17 19:08:14 +03:00
parent 1948618394
commit dd960dc5cc
11 changed files with 171 additions and 59 deletions

View File

@@ -1,4 +1,10 @@
"""SQLAlchemy engine and session factory."""
"""SQLAlchemy engine and session factory.
Note: Engine and session factory are cached globally per process. Only one
DATABASE_URL is effectively used for the process lifetime. Using a different
URL later (e.g. in tests with in-memory SQLite) would still use the first
engine. To support multiple URLs, cache by database_url (e.g. a dict keyed by URL).
"""
from contextlib import contextmanager
from typing import Generator