Skip to content

Commit

Permalink
Fixed blocking authorization flow
Browse files Browse the repository at this point in the history
Version bumped to 0.23.3
  • Loading branch information
pylakey committed Jun 18, 2024
1 parent 14cc40c commit d6d10fb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 32 deletions.
2 changes: 1 addition & 1 deletion aiotdlib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.23.2"
__version__ = "0.23.3"

from .client import Client
from .client_settings import ClientOptions
Expand Down
76 changes: 46 additions & 30 deletions aiotdlib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit d6d10fb

Please sign in to comment.