Fix export_chat_invite_link not working for bots on channels/supergroups

Telegram still hasn't enabled this for bots...
Closes
This commit is contained in:
Dan 2019-07-04 21:00:22 +02:00
parent 18b581fb45
commit bdd554575a
2 changed files with 10 additions and 1 deletions

View File

@ -1364,4 +1364,7 @@ langpack.getLanguage#6a596502 lang_pack:string lang_code:string = LangPackLangua
folders.editPeerFolders#6847d0ab folder_peers:Vector<InputFolderPeer> = Updates; folders.editPeerFolders#6847d0ab folder_peers:Vector<InputFolderPeer> = Updates;
folders.deleteFolder#1c295881 folder_id:int = Updates; folders.deleteFolder#1c295881 folder_id:int = Updates;
// Ports
channels.exportInvite#c7560885 channel:InputChannel = ExportedChatInvite;
// LAYER 102 // LAYER 102

View File

@ -52,11 +52,17 @@ class ExportChatInviteLink(BaseClient):
""" """
peer = self.resolve_peer(chat_id) peer = self.resolve_peer(chat_id)
if isinstance(peer, (types.InputPeerChannel, types.InputPeerChat)): if isinstance(peer, types.InputPeerChat):
return self.send( return self.send(
functions.messages.ExportChatInvite( functions.messages.ExportChatInvite(
peer=peer peer=peer
) )
).link ).link
elif isinstance(peer, types.InputPeerChannel):
return self.send(
functions.channels.ExportInvite(
channel=peer
)
).link
else: else:
raise ValueError('The chat_id "{}" belongs to a user'.format(chat_id)) raise ValueError('The chat_id "{}" belongs to a user'.format(chat_id))