Easiest way to join a channel in python telethon

走远了吗. 提交于 2020-01-03 21:16:30

问题


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:


first upgrade telethon

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


来源:https://stackoverflow.com/questions/44996317/easiest-way-to-join-a-channel-in-python-telethon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!