问题
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