The easiest way to join a channel in python telemaran

I read the telegram documentation for get username and join a channel . After some trying, 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 great, but I want to know if there is a better or easier way?

+3


source to share


1 answer


first telethon update



from telethon.tl.functions.messages import ImportChatInviteRequest
updates = client(ImportChatInviteRequest('hash_invite _channel'))

      

+2


source







All Articles