From 0d8497bf3b7b8fa207a349d791c40ae47a8f9a81 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 7 Nov 2020 12:18:55 +0100 Subject: [PATCH] Correct and simplify the way channel IDs are marked Closes #1359. --- telethon/utils.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/telethon/utils.py b/telethon/utils.py index e9c1468d..81ba9523 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -1009,14 +1009,8 @@ def get_peer_id(peer, add_mark=True): if not add_mark: return peer.channel_id - # Concat -100 through math tricks, .to_supergroup() on - # Madeline IDs will be strictly positive -> log works. - try: - return -(peer.channel_id + pow( - 10, math.floor(math.log10(peer.channel_id) + 3))) - except ValueError: - raise TypeError('Cannot get marked ID of a channel ' - 'unless its ID is strictly positive') from None + # Growing backwards from -100_0000_000_000 indicates it's a channel + return -(1000000000000 + peer.channel_id) def resolve_id(marked_id):