Search code examples
pythontelegramtelethon

Telethon joining private channels


I tried using ImportChatInviteRequest like it says in the docs, but couldn't join public or private channels. With JoinChannelRequest I can only join public channels. Is there a way I'm missing?

CHANNEL = 'https://t.me/TEST_INVITE'
await client(JoinChannelRequest(CHANNEL))
print(f'Successfully joined channel {CHANNEL}')

Tried this code with different CHANNEL variable structures

await client(JoinChannelRequest(CHANNEL))
print(f'Successfully joined channel {CHANNEL}')

such as

CHANNEL = 'https://t.me/TEST_INVITE'
# and
CHANNEL = 'TEST_INVITE'

Solution

  • Telegram private chats use a hash starting with a "+". Remove the "+" and JoinChannelRequest() works.