Enhance API and configuration for Telegram miniapp
- 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.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import asyncio
|
||||
|
||||
import config
|
||||
from telegram import Update, WebAppInfo, KeyboardButton, ReplyKeyboardMarkup
|
||||
from telegram import Update, WebAppInfo, InlineKeyboardButton, InlineKeyboardMarkup
|
||||
from telegram.ext import CommandHandler, ContextTypes
|
||||
|
||||
from db.session import get_session
|
||||
@@ -39,10 +39,9 @@ async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
|
||||
text = "Привет! Я бот календаря дежурств. Используй /help для списка команд."
|
||||
if config.MINI_APP_BASE_URL:
|
||||
keyboard = ReplyKeyboardMarkup(
|
||||
[[KeyboardButton("📅 Календарь", web_app=WebAppInfo(url=config.MINI_APP_BASE_URL + "/app/"))]],
|
||||
resize_keyboard=True,
|
||||
)
|
||||
keyboard = InlineKeyboardMarkup([
|
||||
[InlineKeyboardButton("📅 Календарь", web_app=WebAppInfo(url=config.MINI_APP_BASE_URL + "/app/"))],
|
||||
])
|
||||
await update.message.reply_text(text, reply_markup=keyboard)
|
||||
else:
|
||||
await update.message.reply_text(text)
|
||||
|
||||
Reference in New Issue
Block a user