Fix utils.resolve_id

…assuming get_peer_id is correct, as changed by 0d8497b.
This commit is contained in:
Lonami Exo 2021-01-28 20:01:46 +01:00
parent 055643bd01
commit 6f7640af18

View File

@ -996,7 +996,7 @@ def get_peer_id(peer, add_mark=True):
This "mark" comes from the "bot api" format, and with it the peer type This "mark" comes from the "bot api" format, and with it the peer type
can be identified back. User ID is left unmodified, chat ID is negated, can be identified back. User ID is left unmodified, chat ID is negated,
and channel ID is prefixed with -100: and channel ID is "prefixed" with -100:
* ``user_id`` * ``user_id``
* ``-chat_id`` * ``-chat_id``
@ -1043,15 +1043,12 @@ def resolve_id(marked_id):
if marked_id >= 0: if marked_id >= 0:
return marked_id, types.PeerUser return marked_id, types.PeerUser
# There have been report of chat IDs being 10000xyz, which means their marked_id = -marked_id
# marked version is -10000xyz, which in turn looks like a channel but if marked_id > 1000000000000:
# it becomes 00xyz (= xyz). Hence, we must assert that there are only marked_id -= 1000000000000
# two zeroes. return marked_id, types.PeerChannel
m = re.match(r'-100([^0]\d*)', str(marked_id)) else:
if m: return marked_id, types.PeerChat
return int(m.group(1)), types.PeerChannel
return -marked_id, types.PeerChat
def _rle_decode(data): def _rle_decode(data):