2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 05:18:10 +00:00

Remove imports, use namespaces

This commit is contained in:
Dan 2018-03-26 13:41:00 +02:00
parent e397c4d181
commit beaf88adee

View File

@ -45,11 +45,6 @@ from pyrogram.api.errors import (
PasswordHashInvalid, FloodWait, PeerIdInvalid, FilePartMissing,
ChatAdminRequired, FirstnameInvalid, PhoneNumberBanned,
VolumeLocNotFound, UserMigrate)
from pyrogram.api.types import (
User, Chat, Channel,
InputPeerEmpty, InputPeerSelf,
InputPeerUser, InputPeerChat, InputPeerChannel
)
from pyrogram.crypto import AES
from pyrogram.session import Auth, Session
from pyrogram.session.internals import MsgId
@ -447,7 +442,7 @@ class Client:
def fetch_peers(self, entities: list):
for entity in entities:
if isinstance(entity, User):
if isinstance(entity, types.User):
user_id = entity.id
if user_id in self.peers_by_id:
@ -461,7 +456,7 @@ class Client:
username = entity.username
phone = entity.phone
input_peer = InputPeerUser(
input_peer = types.InputPeerUser(
user_id=user_id,
access_hash=access_hash
)
@ -474,20 +469,20 @@ class Client:
if phone is not None:
self.peers_by_phone[phone] = input_peer
if isinstance(entity, Chat):
if isinstance(entity, types.Chat):
chat_id = entity.id
peer_id = -chat_id
if peer_id in self.peers_by_id:
continue
input_peer = InputPeerChat(
input_peer = types.InputPeerChat(
chat_id=chat_id
)
self.peers_by_id[peer_id] = input_peer
if isinstance(entity, Channel):
if isinstance(entity, types.Channel):
channel_id = entity.id
peer_id = int("-100" + str(channel_id))
@ -501,7 +496,7 @@ class Client:
username = entity.username
input_peer = InputPeerChannel(
input_peer = types.InputPeerChannel(
channel_id=channel_id,
access_hash=access_hash
)
@ -880,7 +875,7 @@ class Client:
dialogs = self.send(
functions.messages.GetDialogs(
0, 0, InputPeerEmpty(),
0, 0, types.InputPeerEmpty(),
self.DIALOGS_AT_ONCE, True
)
)
@ -926,7 +921,7 @@ class Client:
"""
if type(peer_id) is str:
if peer_id in ("self", "me"):
return InputPeerSelf()
return types.InputPeerSelf()
match = self.INVITE_LINK_RE.match(peer_id)
@ -982,7 +977,7 @@ class Client:
"""
return self.send(
functions.users.GetFullUser(
InputPeerSelf()
types.InputPeerSelf()
)
)
@ -2439,7 +2434,7 @@ class Client:
)
)
channel = InputPeerChannel(
channel = types.InputPeerChannel(
channel_id=resolved_peer.chats[0].id,
access_hash=resolved_peer.chats[0].access_hash
)