Let PeerChat be casted to InputPeerChat automatically

This commit is contained in:
Lonami Exo 2017-07-04 21:18:35 +02:00
parent 8fd0d7eadd
commit f88efa7f49

View File

@ -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__))