From f3e2887452cae38234467a269a39c532c13a217f Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sun, 12 Nov 2017 18:15:32 +0100 Subject: [PATCH] Add missing ChannelFull case to .get_peer_id() --- telethon/utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/telethon/utils.py b/telethon/utils.py index 5d5bb953..3259c8e2 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -19,7 +19,7 @@ from .tl.types import ( DocumentEmpty, InputDocumentEmpty, Message, GeoPoint, InputGeoPoint, GeoPointEmpty, InputGeoPointEmpty, Photo, InputPhoto, PhotoEmpty, InputPhotoEmpty, FileLocation, ChatPhotoEmpty, UserProfilePhotoEmpty, - FileLocationUnavailable, InputMediaUploadedDocument, + FileLocationUnavailable, InputMediaUploadedDocument, ChannelFull, InputMediaUploadedPhoto, DocumentAttributeFilename, photos ) @@ -325,8 +325,13 @@ def get_peer_id(peer, add_mark=False): return peer.user_id elif isinstance(peer, (PeerChat, InputPeerChat)): return -peer.chat_id if add_mark else peer.chat_id - elif isinstance(peer, (PeerChannel, InputPeerChannel)): - i = peer.channel_id + elif isinstance(peer, (PeerChannel, InputPeerChannel, ChannelFull)): + if isinstance(peer, ChannelFull): + # Special case: .get_input_peer can't return InputChannel from + # ChannelFull since it doesn't have an .access_hash attribute. + i = peer.id + else: + i = peer.channel_id if add_mark: # Concat -100 through math tricks, .to_supergroup() on Madeline # IDs will be strictly positive -> log works