Correct and simplify the way channel IDs are marked

Closes #1359.
This commit is contained in:
Lonami Exo 2020-11-07 12:18:55 +01:00
parent a6781c8e34
commit 0d8497bf3b

View File

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