[英]Telethon: how to get invite link to private channel?
在 1.5 版本中,我这样做了:
from telethon.tl.functions.channels import ExportInviteRequest
from telethon.tl.types import InputChannel, InputPeerChannel
ChannelLink = Client(ExportInviteRequest(
InputPeerChannel(channel_id=ChannelID,
access_hash=ChannelHash))).link
但它现在不起作用:
ImportError: cannot import name 'ExportInviteRequest'
现在怎么办?
原始 API 可能会在库的次要版本之间发生变化,因此您尝试访问的函数不再存在于以前的位置。
每当发生这种情况时,您可以再次搜索该方法以找出新方法的位置:
from telethon.tl.functions.messages import ExportChatInviteRequest
用法还是一样的:
from telethon.sync import TelegramClient
with TelegramClient(name, api_id, api_hash) as client:
client(functions.messages.ExportChatInviteRequest(
ChannelID
))
您也不需要自己构建InputPeer
,它会自动完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.