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

View File

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