Valueerror: Could Not Find The Input Entity For Peeruser
Solution 1:
I am not familiar with Telethon, but the docs referenced in the error state
To “encounter” an ID, you would have to “find it” like you would in the normal app. If the peer is in your dialogs, you would need to client.get_dialogs(). If the peer is someone in a group, you would similarly client.get_participants(group).
Once you have encountered an ID, the library will (by default) have saved their access_hash for you, which is needed to invoke most methods. This is why sometimes you might encounter this error when working with the library. You should except ValueError and run code that you know should work to find the entity.
And the summary hints that you might need to try finding the entity in different places. Though ideally you already know the right way to find the entity. In your code this might be something like.
@client.on(events.NewMessage)asyncdefhandle_new_message(event):
me = await client.get_me()
username = me.username
try:
from_ = await event.client.get_entity(event.from_id)
except ValueError:
passtry:
# Do you have a conversation open with them? Get dialogs.await client.get_dialogs()
except ValueError:
passtry:
# Are they participant of some group? Get them.await client.get_participants('username')
except ValueError:
passif from_ isNone:
raise ValueError("I could not find the user")
Post a Comment for "Valueerror: Could Not Find The Input Entity For Peeruser"