LonamiWebs / Telethon

Pure Python 3 MTProto API Telegram client library, for bots too!
https://docs.telethon.dev
MIT License
10.01k stars 1.41k forks source link

PeerChannel cannot find some Channels by channel_id #848

Closed mircoianese closed 6 years ago

mircoianese commented 6 years ago

Hi! First of all thanks for this amazing library. I'm using these lines to get channel_info by channel_id:

entity = client.get_entity(PeerChannel(channelName))
fullchn = client.invoke(GetFullChannelRequest(entity))

It works for the majority of channels (even if they are private, if user is member of the channel), but today I found a channel where this does not work and returns:

Could not find the input entity for "PeerChannel(channel_id=1198432346)". Please read ... for more details.

The ID is correct. Thanks

Lonami commented 6 years ago

Please read ...

Did you read that link?

Lonami commented 6 years ago

Also, thanks! Glad you like the library. I hope you like the documentation just as much, I put a lot of time into writing it :)

mircoianese commented 6 years ago

Solved by adding dialogs = client.get_dialogs(), didn't paid attention to it as it worked well đź‘Ť Thanks

MohammadJouza commented 2 years ago

@Lonami Can you help us, please

@arthurclouds

Traceback (most recent call last): File "H:\ackup_will_be_inside_m\backup_script.py", line 15, in group = client.get_entity(PeerChannel(-1001625426205)) File "C:\Users\Arthu\AppData\Local\Programs\Python\Python310\lib\site-packages\telethon\sync.py", line 39, in syncified return loop.run_until_complete(coro) File "C:\Users\Arthu\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete return future.result() File "C:\Users\Arthu\AppData\Local\Programs\Python\Python310\lib\site-packages\telethon\client\users.py", line 292, in get_entity inputs.append(await self.get_input_entity(x)) File "C:\Users\Arthu\AppData\Local\Programs\Python\Python310\lib\site-packages\telethon\client\users.py", line 466, in get_input_entity raise ValueError( ValueError: Could not find the input entity for PeerChannel(channel_id=1625426205) (PeerChannel). Please read https://docs.telethon.dev/en/latest/concepts/entities.html to find out more details. Segmentation fault

1nikitas commented 2 years ago

in addtion to answers, check ur bot in channell participants. i had the same error)

OlegBEZb commented 1 year ago

Solved by adding dialogs = client.get_dialogs(), didn't paid attention to it as it worked well đź‘Ť Thanks

But this can't be executed by the bot's client. Any idea about how to solve Could not find the input entity for "PeerChannel(channel_id=1198432346)". Please read ... for more details. for bot?

speauty commented 1 year ago

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