pyrofork: Add support for requested channel/chat/user in utils.get_raw_peer_id

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2024-07-14 21:01:46 +07:00
parent b0f449a0d6
commit d46e8f1da4
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5

View file

@ -281,15 +281,20 @@ MAX_USER_ID_OLD = 2147483647
MAX_USER_ID = 999999999999
def get_raw_peer_id(peer: raw.base.Peer) -> Optional[int]:
def get_raw_peer_id(
peer: Union[
raw.base.Peer,
raw.base.RequestedPeer
]
) -> Optional[int]:
"""Get the raw peer id from a Peer object"""
if isinstance(peer, raw.types.PeerUser):
if isinstance(peer, raw.types.PeerUser) or isinstance(peer, raw.types.RequestedPeerUser):
return peer.user_id
if isinstance(peer, raw.types.PeerChat):
if isinstance(peer, raw.types.PeerChat) or isinstance(peer, raw.types.RequestedPeerChat):
return peer.chat_id
if isinstance(peer, raw.types.PeerChannel):
if isinstance(peer, raw.types.PeerChannel) or isinstance(peer, raw.types.RequestedPeerChannel):
return peer.channel_id
return None