Closed ghost closed 5 years ago
If I am not wrong, that is explained in the docs "Users, chat and channel, Important section": https://telethon.readthedocs.io/en/stable/extra/basic/entities.html
Once the library has “seen” the entity, you can use their integer ID. You can’t use entities from IDs the library hasn’t seen. You must make the library see them at least once and disconnect properly. You know where the entities are and you must tell the library. It won’t guess for you.
On a clean session,
with client:
try:
client.get_entity(1151511560)
except ValueError:
print('Error as expected')
client.get_entity("ekat01")
client.get_entity(1151511560)
print('Works as expected')
prints:
Error as expected
Works as expected
On a second run,
with client:
client.get_entity(1151511560)
print('Works as expected')
prints:
Works as expected
Thanks a lot!
what if a user has no username? how can i get the entitiy?
same problem
Hey everyone, About the doubt of @ShambikDavid:
what if a user has no username? how can i get the entitiy?
I was able to capture the user (Entity) in the following way:
user = client.get_entity( PeerUser( user_id ) )
Look at here:
https://docs.telethon.dev/en/stable/concepts/entities.html
Hugs,
Checklist check
Code that causes the issue
Video proof: https://youtu.be/mnDNZZir5PY
Traceback