mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 12:57:52 +00:00
Add support for Bot API style basic group IDs (with minus sign)
Closes #32
This commit is contained in:
parent
859305b744
commit
f55062bc6d
@ -256,15 +256,16 @@ class Client:
|
||||
|
||||
if isinstance(entity, Chat):
|
||||
chat_id = entity.id
|
||||
peer_id = -chat_id
|
||||
|
||||
if chat_id in self.peers_by_id:
|
||||
if peer_id in self.peers_by_id:
|
||||
continue
|
||||
|
||||
input_peer = InputPeerChat(
|
||||
chat_id=chat_id
|
||||
)
|
||||
|
||||
self.peers_by_id[chat_id] = input_peer
|
||||
self.peers_by_id[peer_id] = input_peer
|
||||
|
||||
if isinstance(entity, Channel):
|
||||
channel_id = entity.id
|
||||
@ -886,16 +887,19 @@ class Client:
|
||||
if isinstance(peer_id, types.PeerUser):
|
||||
peer_id = peer_id.user_id
|
||||
elif isinstance(peer_id, types.PeerChat):
|
||||
peer_id = peer_id.chat_id
|
||||
peer_id = -peer_id.chat_id
|
||||
elif isinstance(peer_id, types.PeerChannel):
|
||||
peer_id = int("-100" + str(peer_id.channel_id))
|
||||
|
||||
try:
|
||||
try: # User
|
||||
return self.peers_by_id[peer_id]
|
||||
except KeyError:
|
||||
try:
|
||||
return self.peers_by_id[int("-100" + str(peer_id))]
|
||||
try: # Chat
|
||||
return self.peers_by_id[-peer_id]
|
||||
except KeyError:
|
||||
try: # Channel
|
||||
return self.peers_by_id[int("-100" + str(peer_id))]
|
||||
except (KeyError, ValueError):
|
||||
raise PeerIdInvalid
|
||||
|
||||
def get_me(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user