I
I
idin2018-08-13 11:24:00
Python
idin, 2018-08-13 11:24:00

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)))

I use these versions:
Telethon==1.1.1
Telethon-sync==1.0.4
writes an error:
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

1 answer(s)
A
Anatoly, 2018-08-13
@Izy

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 question

Ask a Question

731 491 924 answers to any question