Optimize join_chat code

This commit is contained in:
Dan 2019-09-09 15:28:27 +02:00
parent 80c7a6e988
commit aaf0e82cdf

View File

@ -58,20 +58,9 @@ class JoinChat(BaseClient):
elif isinstance(chat.chats[0], types.Channel):
return pyrogram.Chat._parse_channel_chat(self, chat.chats[0])
else:
resolved_peer = self.send(
functions.contacts.ResolveUsername(
username=chat_id.lower().strip("@")
)
)
channel = types.InputPeerChannel(
channel_id=resolved_peer.chats[0].id,
access_hash=resolved_peer.chats[0].access_hash
)
chat = self.send(
functions.channels.JoinChannel(
channel=channel
channel=self.resolve_peer(chat_id)
)
)