Search code examples
telegramtelethon

A telegram private channel requires admin's approval. Private chat linked to doesn't and gives access to channel without approval. Join with Telethon?


I have a link to a channel - t.me/+blablabla

I have a link to a group, linked to a channel - t.me/+blablabla2

To join a channel by first link I need to be approved by admin.

To join a group by second I need just to click "join"

Joining a group gives a access to the channel, for example by the link of some post - t.me/c/some_numbers/post_id - when I click this link then I can tap "join" button to join channel without additional approval.

The question is how to join channel in this way using Telethon? I've managed to join the group by the private link with Telethon, but I can't deal with joining the channel without admin's approval.

Seems I am missing some knowledge how to use functions.messages.ImportChatInviteRequest or functions.channels.JoinChannelRequest correctly in my case


Solution

  • See GetFullChannel.

    Run it against the group first:

    info = await client(
      functions.channels.GetFullChannelRequest(...)
    )
    

    linked channel will get cached, join it with its id now.

    await client(
      functions.channels.JoinChannelRequest(
        info.full_chat.linked_chat_id
      )
    )