From f88efa7f493aa17cb72941b1468d2e1934fba84d Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Tue, 4 Jul 2017 21:18:35 +0200 Subject: [PATCH] Let PeerChat be casted to InputPeerChat automatically --- telethon/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/telethon/utils.py b/telethon/utils.py index d94734a2..485e9034 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -6,8 +6,8 @@ from mimetypes import add_type, guess_extension from .tl.types import ( Channel, ChannelForbidden, Chat, ChatEmpty, ChatForbidden, ChatFull, - ChatPhoto, InputPeerChannel, InputPeerChat, InputPeerUser, InputPeerEmpty, - InputPeerSelf, MessageMediaDocument, MessageMediaPhoto, PeerChannel, + ChatPhoto, InputPeerChannel, InputPeerChat, InputPeerUser, + MessageMediaDocument, MessageMediaPhoto, PeerChannel, PeerChat, PeerUser, User, UserFull, UserProfilePhoto) @@ -73,6 +73,9 @@ def get_input_peer(entity): if isinstance(entity, ChatFull): return InputPeerChat(entity.id) + if isinstance(entity, PeerChat): + return InputPeerChat(entity.chat_id) + raise ValueError('Cannot cast {} to any kind of InputPeer.' .format(type(entity).__name__))