Less confusing error for getting marked ID of PeerChannel(0)

Fixes #1282.
This commit is contained in:
Lonami 2019-09-24 19:01:46 +02:00 committed by GitHub
parent d1ddfd09b6
commit 6da8d1a0ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -903,8 +903,12 @@ def get_peer_id(peer, add_mark=True):
# Concat -100 through math tricks, .to_supergroup() on
# Madeline IDs will be strictly positive -> log works.
return -(peer.channel_id + pow(
10, math.floor(math.log10(peer.channel_id) + 3)))
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
def resolve_id(marked_id):