From d6d10fb31b94769e3449074a7588785c590ddacb Mon Sep 17 00:00:00 2001 From: pylakey Date: Tue, 18 Jun 2024 17:21:56 +0300 Subject: [PATCH] Fixed blocking authorization flow Version bumped to 0.23.3 --- aiotdlib/__init__.py | 2 +- aiotdlib/client.py | 76 +++++++++++++++++++++++++++----------------- pyproject.toml | 2 +- 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/aiotdlib/__init__.py b/aiotdlib/__init__.py index 3a2cfb3..5eb1e82 100644 --- a/aiotdlib/__init__.py +++ b/aiotdlib/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.23.2" +__version__ = "0.23.3" from .client import Client from .client_settings import ClientOptions diff --git a/aiotdlib/client.py b/aiotdlib/client.py index a2b53d3..d141760 100644 --- a/aiotdlib/client.py +++ b/aiotdlib/client.py @@ -24,6 +24,10 @@ from .api import ChatTypePrivate from .api import ChatTypeSecret from .api import ChatTypeSupergroup +from .api import CheckAuthenticationBotToken +from .api import CheckAuthenticationCode +from .api import CheckAuthenticationEmailCode +from .api import CheckAuthenticationPassword from .api import DisableProxy from .api import EmailAddressAuthenticationCode from .api import Error @@ -59,8 +63,11 @@ from .api import ProxyTypeHttp from .api import ProxyTypeMtproto from .api import ProxyTypeSocks5 +from .api import RegisterUser from .api import ReplyMarkup from .api import SecretChat +from .api import SetAuthenticationEmailAddress +from .api import SetAuthenticationPhoneNumber from .api import SetLogVerbosityLevel from .api import SetOption from .api import SetTdlibParameters @@ -399,64 +406,73 @@ async def _set_authentication_phone_number_or_check_bot_token(self): async def _set_authentication_phone_number(self): self.logger.info('Sending phone number') - return await self.api.set_authentication_phone_number( - phone_number=self.settings.phone_number, - settings=PhoneNumberAuthenticationSettings( - allow_flash_call=False, - allow_missed_call=False, - is_current_phone_number=True, - allow_sms_retriever_api=False, - authentication_tokens=[] - ), + await self.send( + SetAuthenticationPhoneNumber( + phone_number=self.settings.phone_number, + settings=PhoneNumberAuthenticationSettings( + allow_flash_call=False, + allow_missed_call=False, + is_current_phone_number=True, + allow_sms_retriever_api=False, + authentication_tokens=[] + ), + ) ) async def _check_authentication_bot_token(self): self.logger.info('Sending bot token') - return await self.api.check_authentication_bot_token( - self.settings.bot_token.get_secret_value(), + await self.send( + CheckAuthenticationBotToken( + token=self.settings.bot_token.get_secret_value(), + ) ) async def _check_authentication_code(self): code = await self._auth_get_code(code_type='SMS') self.logger.info(f'Sending code {code}') - - return await self.api.check_authentication_code( - code=code, + await self.send( + CheckAuthenticationCode( + code=code, + ) ) async def _set_authentication_email_address(self): - email = await self._auth_get_email() - - return await self.api.set_authentication_email_address( - email_address=email, + email_address = await self._auth_get_email() + await self.send( + SetAuthenticationEmailAddress( + email_address=email_address, + ) ) async def _check_authentication_email_code(self): code = await self._auth_get_code(code_type='EMail') self.logger.info(f'Sending email code {code}') - - return await self.api.check_authentication_email_code( - code=EmailAddressAuthenticationCode( - code=code - ), + return await self.send( + CheckAuthenticationEmailCode( + code=EmailAddressAuthenticationCode( + code=code + ), + ) ) async def _register_user(self): first_name = await self._auth_get_first_name() last_name = await self._auth_get_last_name() self.logger.info(f'Registering new user in telegram as {first_name} {last_name or ""}'.strip()) - - return await self.api.register_user( - first_name=first_name, - last_name=last_name, + await self.send( + RegisterUser( + first_name=first_name, + last_name=last_name, + ) ) async def _check_authentication_password(self): password = await self._auth_get_password() self.logger.info('Sending password') - - return await self.api.check_authentication_password( - password=password, + await self.send( + CheckAuthenticationPassword( + password=password, + ) ) # noinspection PyMethodMayBeStatic diff --git a/pyproject.toml b/pyproject.toml index ddf32e6..68a8dff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "aiotdlib" -version = "0.23.2" +version = "0.23.3" description = "Python asyncio Telegram client based on TDLib" authors = ["pylakey "] license = "MIT"