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
|
Audio
|
||||||
AvailableEffect
|
AvailableEffect
|
||||||
Document
|
Document
|
||||||
|
ForumTopic
|
||||||
|
ForumTopicClosed
|
||||||
|
ForumTopicCreated
|
||||||
|
ForumTopicEdited
|
||||||
|
ForumTopicReopened
|
||||||
Animation
|
Animation
|
||||||
Video
|
Video
|
||||||
Voice
|
Voice
|
||||||
@ -583,7 +588,6 @@ def pyrogram_api():
|
|||||||
MenuButtonWebApp
|
MenuButtonWebApp
|
||||||
MenuButtonDefault
|
MenuButtonDefault
|
||||||
SentWebAppMessage
|
SentWebAppMessage
|
||||||
ForumTopic
|
|
||||||
RequestChannelInfo
|
RequestChannelInfo
|
||||||
RequestChatInfo
|
RequestChatInfo
|
||||||
RequestUserInfo
|
RequestUserInfo
|
||||||
|
@ -73,12 +73,17 @@ class ResolvePeer:
|
|||||||
try:
|
try:
|
||||||
return await self.storage.get_peer_by_username(peer_id)
|
return await self.storage.get_peer_by_username(peer_id)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
await self.invoke(
|
r = await self.invoke(
|
||||||
raw.functions.contacts.ResolveUsername(
|
raw.functions.contacts.ResolveUsername(
|
||||||
username=peer_id
|
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)
|
return await self.storage.get_peer_by_username(peer_id)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
@ -102,20 +107,24 @@ class ResolvePeer:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif peer_type == "chat":
|
elif peer_type == "chat":
|
||||||
await self.invoke(
|
await self.fetch_peers(
|
||||||
raw.functions.messages.GetChats(
|
await self.invoke(
|
||||||
id=[-peer_id]
|
raw.functions.messages.GetChats(
|
||||||
|
id=[-peer_id]
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
await self.invoke(
|
await self.fetch_peers(
|
||||||
raw.functions.channels.GetChannels(
|
await self.invoke(
|
||||||
id=[
|
raw.functions.channels.GetChannels(
|
||||||
raw.types.InputChannel(
|
id=[
|
||||||
channel_id=utils.get_channel_id(peer_id),
|
raw.types.InputChannel(
|
||||||
access_hash=0
|
channel_id=utils.get_channel_id(peer_id),
|
||||||
)
|
access_hash=0
|
||||||
]
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user