mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-06-17 10:36:37 +00:00
Except BotMethodInvalidError on getContacts
This commit is contained in:
parent
99129daeee
commit
34cefed9ff
@ -354,10 +354,14 @@ class UserMethods(TelegramBaseClient):
|
|||||||
"""
|
"""
|
||||||
phone = utils.parse_phone(string)
|
phone = utils.parse_phone(string)
|
||||||
if phone:
|
if phone:
|
||||||
for user in (await self(
|
try:
|
||||||
functions.contacts.GetContactsRequest(0))).users:
|
for user in (await self(
|
||||||
if user.phone == phone:
|
functions.contacts.GetContactsRequest(0))).users:
|
||||||
return user
|
if user.phone == phone:
|
||||||
|
return user
|
||||||
|
except errors.BotMethodInvalidError:
|
||||||
|
raise ValueError('Cannot get entity by phone number as a '
|
||||||
|
'bot (try using integer IDs, not strings)')
|
||||||
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:
|
||||||
|
Loading…
Reference in New Issue
Block a user