Fix .get_entity('me') not working from c31635c (#1024)

This commit is contained in:
Lonami Exo 2018-10-19 16:57:46 +02:00
parent 0686ec4440
commit a2bae8374e

View File

@ -362,6 +362,8 @@ class UserMethods(TelegramBaseClient):
except errors.BotMethodInvalidError: except errors.BotMethodInvalidError:
raise ValueError('Cannot get entity by phone number as a ' raise ValueError('Cannot get entity by phone number as a '
'bot (try using integer IDs, not strings)') 'bot (try using integer IDs, not strings)')
elif string.lower() in ('me', 'self'):
return await self.get_me()
else: else:
username, is_join_chat = utils.parse_username(string) username, is_join_chat = utils.parse_username(string)
if is_join_chat: if is_join_chat:
@ -376,9 +378,6 @@ class UserMethods(TelegramBaseClient):
elif isinstance(invite, types.ChatInviteAlready): elif isinstance(invite, types.ChatInviteAlready):
return invite.chat return invite.chat
elif username: elif username:
if username in ('me', 'self'):
return await self.get_me()
try: try:
result = await self( result = await self(
functions.contacts.ResolveUsernameRequest(username)) functions.contacts.ResolveUsernameRequest(username))