Temporary fix for resolving some peers

This commit is contained in:
KurimuzonAkuma 2024-11-02 20:04:14 +03:00
parent 7c294aa1f8
commit 9cbb707675
2 changed files with 26 additions and 13 deletions

View File

@ -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

View File

@ -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,12 +107,15 @@ class ResolvePeer:
)
)
elif peer_type == "chat":
await self.fetch_peers(
await self.invoke(
raw.functions.messages.GetChats(
id=[-peer_id]
)
)
)
else:
await self.fetch_peers(
await self.invoke(
raw.functions.channels.GetChannels(
id=[
@ -118,6 +126,7 @@ class ResolvePeer:
]
)
)
)
try:
return await self.storage.get_peer_by_id(peer_id)