refactor: centralize settings and application services
This commit is contained in:
@@ -4,7 +4,12 @@ from telegram import Update
|
||||
from telegram.constants import ChatType
|
||||
from telegram.ext import ApplicationHandlerStop, ContextTypes
|
||||
|
||||
from .telegram_utils import get_storage, reply_markdown, require_user_id
|
||||
from .telegram_utils import (
|
||||
get_services,
|
||||
get_storage,
|
||||
reply_markdown,
|
||||
require_user_id,
|
||||
)
|
||||
|
||||
|
||||
def passwords_match(candidate: str, expected: str) -> bool:
|
||||
@@ -37,7 +42,7 @@ async def authentication_guard(
|
||||
raise ApplicationHandlerStop
|
||||
|
||||
candidate = message.text.strip() if message and message.text else ""
|
||||
password = str(context.application.bot_data["assistant_password"])
|
||||
password = get_services(context).assistant_password
|
||||
if candidate and passwords_match(candidate, password):
|
||||
storage.authorize_user(user_id)
|
||||
await reply_markdown(
|
||||
|
||||
Reference in New Issue
Block a user