Telethon: Is there a simple way to get entity of a private channel?

Created on 9 Nov 2017  路  7Comments  路  Source: LonamiWebs/Telethon

I know that to create a new entity of the channel there is two options
first option is to create the instance via constuctor
and second by get_entity() method, but as far as I know get_entity() method works with public channels only? Is there any helper method to get entity of the secret chat by chat link?

Most helpful comment

import telethon.utils
help(telethon.utils)

All 7 comments

I plan on adding support for private channels known their link soon. Currently you use the part after t.me/, which is the hash. Look for "hash" and "channel".

The problem is that I need to create InputChannel of the private channel and it requires two parameters channel_id and access_hash. And if access_hash is part of t.me/ link so where I can get channel_id?

PS Sorry for my Enlgish, it is not my native language

No, that's not the access hash, it's just a hash. You can get the channel with that "check invite" if I recall correctly (look for it). The library also converts normal channels to input channels for you.

Now to create an new secret InputChannel knowing only t.me/ link I do:

chatinvite = client(CheckChatInviteRequest('*************link**********'))
channel_id = chatinvite.chat.id
access_hash_channel = chatinvite.chat.access_hash
input_channel = InputChannel(channel_id, access_hash_channel)

I think that there is a better solution to get InputChannel. Or no?

There are functions on telethon.utils to do it yes but as I said the library will convert the channel to input channel when it needs.

Thanks for this quick reply. Where can I get docs for all available helper methods? As far as I understand https://lonamiwebs.github.io/Telethon wiki describe only methods that can be invoke() so is there any docs for helper methods?

import telethon.utils
help(telethon.utils)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

amir3code picture amir3code  路  6Comments

wdsjxh picture wdsjxh  路  3Comments

rbabaee2014 picture rbabaee2014  路  3Comments

chri1389 picture chri1389  路  6Comments

pazis picture pazis  路  5Comments