From bdd554575a34fcd849e25442a1a8a4bd95015f75 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Thu, 4 Jul 2019 21:00:22 +0200 Subject: [PATCH] Fix export_chat_invite_link not working for bots on channels/supergroups Telegram still hasn't enabled this for bots... Closes --- compiler/api/source/main_api.tl | 3 +++ pyrogram/client/methods/chats/export_chat_invite_link.py | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/compiler/api/source/main_api.tl b/compiler/api/source/main_api.tl index ff295130..f465d865 100644 --- a/compiler/api/source/main_api.tl +++ b/compiler/api/source/main_api.tl @@ -1364,4 +1364,7 @@ langpack.getLanguage#6a596502 lang_pack:string lang_code:string = LangPackLangua folders.editPeerFolders#6847d0ab folder_peers:Vector = Updates; folders.deleteFolder#1c295881 folder_id:int = Updates; +// Ports +channels.exportInvite#c7560885 channel:InputChannel = ExportedChatInvite; + // LAYER 102 \ No newline at end of file diff --git a/pyrogram/client/methods/chats/export_chat_invite_link.py b/pyrogram/client/methods/chats/export_chat_invite_link.py index 6e39dd84..ca75cac6 100644 --- a/pyrogram/client/methods/chats/export_chat_invite_link.py +++ b/pyrogram/client/methods/chats/export_chat_invite_link.py @@ -52,11 +52,17 @@ class ExportChatInviteLink(BaseClient): """ peer = self.resolve_peer(chat_id) - if isinstance(peer, (types.InputPeerChannel, types.InputPeerChat)): + if isinstance(peer, types.InputPeerChat): return self.send( functions.messages.ExportChatInvite( peer=peer ) ).link + elif isinstance(peer, types.InputPeerChannel): + return self.send( + functions.channels.ExportInvite( + channel=peer + ) + ).link else: raise ValueError('The chat_id "{}" belongs to a user'.format(chat_id))