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,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
] )
]
)
) )
) )