Refactor Telegram bot and web application for improved functionality
- Disabled the default menu button in the Telegram bot, allowing users to access the app via a direct link. - Updated the initData validation process to ensure URL-decoded values are used in the data-check string. - Enhanced error handling in the web application to provide more informative access denial messages. - Removed unnecessary debug information from the access denied section in the web app. - Cleaned up the web application code by removing unused functions and improving CSS styles for hidden elements.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
"""Command handlers: /start, /help; /start registers user and shows Calendar button."""
|
||||
"""Command handlers: /start, /help; /start registers user."""
|
||||
|
||||
import asyncio
|
||||
|
||||
import config
|
||||
from telegram import Update, WebAppInfo, InlineKeyboardButton, InlineKeyboardMarkup
|
||||
from telegram import Update
|
||||
from telegram.ext import CommandHandler, ContextTypes
|
||||
|
||||
from db.session import get_session
|
||||
@@ -42,27 +42,14 @@ async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
await asyncio.get_running_loop().run_in_executor(None, do_get_or_create)
|
||||
|
||||
text = "Привет! Я бот календаря дежурств. Используй /help для списка команд."
|
||||
if config.MINI_APP_BASE_URL:
|
||||
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)
|
||||
await update.message.reply_text(text)
|
||||
|
||||
|
||||
async def help_cmd(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
if update.message:
|
||||
await update.message.reply_text(
|
||||
"Доступные команды:\n"
|
||||
"/start — Начать и открыть календарь\n"
|
||||
"/start — Начать\n"
|
||||
"/help — Показать эту справку"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user