Answer the question
In order to leave comments, you need to log in
Why can't I get information about the user by id in the telethon library, but I can get information about the user through @name?
Sample code I use
from telethon import TelegramClient, sync
import myhelper
import socks
from telethon.tl.types import PeerUser, PeerChat, PeerChannel
config_f = myhelper.open_yaml('config.yaml')
client = TelegramClient("my_sessia", config_f["id"], config_f["hash"])
client.start()
client.connect()
print(client.get_entity((615435914)))
ValueError: Could not find the input entity for "615435914". Please read https://telethon.readthedocs.io/en/latest/extra/ba... to find out more details.
Answer the question
In order to leave comments, you need to log in
It is impossible (or possible, but this is not mentioned anywhere) to get information about a "foreign" user by id.
But, if we wrote to him at least once and we still have a dialogue with him, then first you need to call client.get_dialogs()
so that the client "remembers" the users.
After that it client.get_entity(id)
will work fine.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question