add formating

This commit is contained in:
kandrusyak
2026-07-27 17:14:07 +03:00
parent 7b7ff51d0f
commit 275eca8dc5
10 changed files with 628 additions and 157 deletions

View File

@@ -4,7 +4,7 @@ from telegram import Update
from telegram.constants import ChatType
from telegram.ext import ApplicationHandlerStop, ContextTypes
from .telegram_utils import get_storage, require_user_id
from .telegram_utils import get_storage, reply_markdown, require_user_id
def passwords_match(candidate: str, expected: str) -> bool:
@@ -30,8 +30,9 @@ async def authentication_guard(
chat = update.effective_chat
if chat is not None and chat.type != ChatType.PRIVATE:
if message:
await message.reply_text(
"Сначала авторизуйся в личном чате с ботом."
await reply_markdown(
message,
"🔐 **Сначала авторизуйся в личном чате с ботом.**",
)
raise ApplicationHandlerStop
@@ -39,18 +40,23 @@ async def authentication_guard(
password = str(context.application.bot_data["assistant_password"])
if candidate and passwords_match(candidate, password):
storage.authorize_user(user_id)
await message.reply_text(
"Пароль принят. Доступ открыт — повторно вводить его не нужно."
await reply_markdown(
message,
"✅ **Пароль принят.** Доступ открыт — повторно вводить его не нужно.",
)
raise ApplicationHandlerStop
if candidate and not candidate.startswith("/"):
await message.reply_text("Неверный пароль. Попробуй еще раз.")
await reply_markdown(
message,
"🔐 **Неверный пароль.** Попробуй ещё раз.",
)
raise ApplicationHandlerStop
if message:
await message.reply_text(
"Для доступа к боту введи пароль одним текстовым сообщением."
await reply_markdown(
message,
"🔐 **Для доступа к боту введи пароль** одним текстовым сообщением.",
)
elif update.inline_query:
await update.inline_query.answer([], cache_time=0)