diff --git a/pyrogram/__init__.py b/pyrogram/__init__.py index 469dd399..96ce0e30 100644 --- a/pyrogram/__init__.py +++ b/pyrogram/__init__.py @@ -20,10 +20,10 @@ import sys __copyright__ = "Copyright (C) 2017-2018 Dan Tès ".replace( "\xe8", - "e" if sys.getfilesystemencoding() == "ascii" else "\xe8" + "e" if sys.getfilesystemencoding() != "utf-8" else "\xe8" ) __license__ = "GNU Lesser General Public License v3 or later (LGPLv3+)" -__version__ = "0.6.4" +__version__ = "0.6.5" from .api.errors import Error from .client import ChatAction diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index f8bc4e4d..98cf5e65 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -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 ) @@ -651,8 +646,9 @@ class Client: ) ) - updates.users += diff.users - updates.chats += diff.chats + if not isinstance(diff, types.updates.ChannelDifferenceEmpty): + updates.users += diff.users + updates.chats += diff.chats if channel_id and pts: if channel_id not in self.channels_pts: @@ -879,7 +875,7 @@ class Client: dialogs = self.send( functions.messages.GetDialogs( - 0, 0, InputPeerEmpty(), + 0, 0, types.InputPeerEmpty(), self.DIALOGS_AT_ONCE, True ) ) @@ -925,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) @@ -981,7 +977,7 @@ class Client: """ return self.send( functions.users.GetFullUser( - InputPeerSelf() + types.InputPeerSelf() ) ) @@ -2438,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 )