From 5fd87879ca995fd18b113a879dbfb8c66e82b1b5 Mon Sep 17 00:00:00 2001 From: nikita Date: Wed, 9 Sep 2026 00:53:33 +0300 Subject: [PATCH] Fixed `MatrixBotConfig.allow_ainput_password` `MatrixBotConfig.allow_ainput_password` was ignored before this commit because it was forgotten about during refactoring --- src/mab/bot/_client_auth.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mab/bot/_client_auth.py b/src/mab/bot/_client_auth.py index 448a6b9..d424531 100644 --- a/src/mab/bot/_client_auth.py +++ b/src/mab/bot/_client_auth.py @@ -17,11 +17,14 @@ class ClientAuth: # # PRIVATE # - @staticmethod - async def _default_password_callback() -> str: + async def _default_password_callback(self) -> str: + if self._config is None: + raise RuntimeError("No config") if "MATRIX_PASSWORD" in os.environ: return os.environ["MATRIX_PASSWORD"] - return await aioconsole.ainput("Matrix password: ") + if self._config.allow_ainput_password: + return await aioconsole.ainput("Matrix password: ") + raise RuntimeError("Can't get password") async def _login_using_session_data(self, client: AsyncClient) -> None: """ @@ -98,11 +101,13 @@ class ClientAuth: self._logger = logging.getLogger("ClientAuth") self._storage = storage self._full_matrix_username: str | None = None + self._config: MatrixBotConfig | None = None async def setup(self, config: MatrixBotConfig) -> None: """ Setup `ClientAuth` object using `config`. """ + self._config = config self._full_matrix_username = Utils.build_full_matrix_username(config) async def login(self, client: AsyncClient) -> None: