mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-27 08:36:27 +00:00
Temporary fix for resolving some peers
This commit is contained in:
parent
7c294aa1f8
commit
9cbb707675
@ -521,6 +521,11 @@ def pyrogram_api():
|
||||
Audio
|
||||
AvailableEffect
|
||||
Document
|
||||
ForumTopic
|
||||
ForumTopicClosed
|
||||
ForumTopicCreated
|
||||
ForumTopicEdited
|
||||
ForumTopicReopened
|
||||
Animation
|
||||
Video
|
||||
Voice
|
||||
@ -583,7 +588,6 @@ def pyrogram_api():
|
||||
MenuButtonWebApp
|
||||
MenuButtonDefault
|
||||
SentWebAppMessage
|
||||
ForumTopic
|
||||
RequestChannelInfo
|
||||
RequestChatInfo
|
||||
RequestUserInfo
|
||||
|
@ -73,12 +73,17 @@ class ResolvePeer:
|
||||
try:
|
||||
return await self.storage.get_peer_by_username(peer_id)
|
||||
except KeyError:
|
||||
await self.invoke(
|
||||
r = await self.invoke(
|
||||
raw.functions.contacts.ResolveUsername(
|
||||
username=peer_id
|
||||
)
|
||||
)
|
||||
|
||||
if isinstance(r.peer, raw.types.PeerUser):
|
||||
return await self.storage.get_peer_by_id(r.peer.user_id)
|
||||
elif isinstance(r.peer, raw.types.PeerChannel):
|
||||
return await self.storage.get_peer_by_id(utils.get_channel_id(r.peer.channel_id))
|
||||
|
||||
return await self.storage.get_peer_by_username(peer_id)
|
||||
else:
|
||||
try:
|
||||
@ -102,20 +107,24 @@ class ResolvePeer:
|
||||
)
|
||||
)
|
||||
elif peer_type == "chat":
|
||||
await self.invoke(
|
||||
raw.functions.messages.GetChats(
|
||||
id=[-peer_id]
|
||||
await self.fetch_peers(
|
||||
await self.invoke(
|
||||
raw.functions.messages.GetChats(
|
||||
id=[-peer_id]
|
||||
)
|
||||
)
|
||||
)
|
||||
else:
|
||||
await self.invoke(
|
||||
raw.functions.channels.GetChannels(
|
||||
id=[
|
||||
raw.types.InputChannel(
|
||||
channel_id=utils.get_channel_id(peer_id),
|
||||
access_hash=0
|
||||
)
|
||||
]
|
||||
await self.fetch_peers(
|
||||
await self.invoke(
|
||||
raw.functions.channels.GetChannels(
|
||||
id=[
|
||||
raw.types.InputChannel(
|
||||
channel_id=utils.get_channel_id(peer_id),
|
||||
access_hash=0
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user