add password authentication for bot users

This commit is contained in:
kandrusyak
2026-07-25 15:57:30 +03:00
parent c04fb9480b
commit 053b124a9a
8 changed files with 210 additions and 0 deletions

View File

@@ -6,12 +6,15 @@ from telegram.ext import (
CommandHandler,
InlineQueryHandler,
MessageHandler,
TypeHandler,
filters,
)
from .ai import AIClient
from .auth import authentication_guard
from .config import (
get_assistant_mode,
get_assistant_password,
get_bot_token,
get_db_path,
get_local_timezone,
@@ -53,6 +56,7 @@ def configure_logging() -> None:
def create_application() -> Application:
assistant_password = get_assistant_password()
storage = AssistantStorage(get_db_path())
mode = get_assistant_mode()
application = (
@@ -63,6 +67,7 @@ def create_application() -> Application:
.build()
)
application.bot_data["storage"] = storage
application.bot_data["assistant_password"] = assistant_password
ai_client: AIClient
speech_recognizer: SpeechTranscriber
if mode == "local":
@@ -88,6 +93,7 @@ def create_application() -> Application:
application.bot_data["speech_recognizer"] = speech_recognizer
application.bot_data["voice_max_duration"] = get_voice_max_duration_seconds()
application.add_handler(TypeHandler(Update, authentication_guard), group=-1)
application.add_handler(CommandHandler("start", start))
application.add_handler(CommandHandler("help", help_command))
application.add_handler(CommandHandler("ask", ask_command))