Easiest way to join a channel in python telethon

Viewed 5994

I read telethon documentation to retrieve an user-name and join a channel. After some tries i wrote this code:

result = client.invoke(ResolveUsernameRequest('XXXX'))
channel = InputChannel(result.peer.channel_id, result.chats[0].access_hash)
client.invoke(JoinChannelRequest(channel))

This code works fine but i want to know is there a better or simpler way?

1 Answers
Related