本文介绍了在python telethon中加入频道的最简单方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Telethon文档阅读到获取用户名,然后加入频道.经过一番尝试,我编写了这段代码:

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?

推荐答案

第一次升级电视节目

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

这篇关于在python telethon中加入频道的最简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 07:44