In 1.5 version I did so:
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
But it doesn't work now:
ImportError: cannot import name 'ExportInviteRequest'
How to do it now?
Raw API is subject to change between minor versions of the library, so the function you're trying to access no longer exists where it used to be.
Whenever this happens, you can search for the method again to find out where the new one is:
from telethon.tl.functions.messages import ExportChatInviteRequest
Usage is still the same:
from telethon.sync import TelegramClient
with TelegramClient(name, api_id, api_hash) as client:
client(functions.messages.ExportChatInviteRequest(
ChannelID
))
You also don't need to construct the InputPeer yourself, it's done automatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With