From 16f929b8b65ff38f53183847c8e5a10441928b3b Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 5 Oct 2017 12:33:24 +0200 Subject: [PATCH] Fix .get_peer_id not working with full entities --- telethon/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/telethon/utils.py b/telethon/utils.py index f6e6373a..8f213054 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -321,7 +321,11 @@ def get_peer_id(peer, add_mark=False): i = peer.channel_id # IDs will be strictly positive -> log works return -(i + pow(10, math.floor(math.log10(i) + 3))) - _raise_cast_fail(peer, 'int') + # Maybe a full entity was given and we just need its ID + try: + return get_peer_id(get_input_peer(peer), add_mark=add_mark) + except ValueError: + _raise_cast_fail(peer, 'int') def resolve_id(marked_id):