From e397c4d1819e1fe05a73123f8e022c2d53211bec Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 26 Mar 2018 13:34:54 +0200 Subject: [PATCH 1/4] Don't process empty differences --- pyrogram/client/client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index f8bc4e4d..89bab694 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -651,8 +651,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: From beaf88adeedd4a2821304ff05d5a274a25924a29 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 26 Mar 2018 13:41:00 +0200 Subject: [PATCH 2/4] Remove imports, use namespaces --- pyrogram/client/client.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 89bab694..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 ) @@ -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 ) From f28992ce908f65cbd55d378d297db884e1a73317 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Tue, 27 Mar 2018 12:33:56 +0200 Subject: [PATCH 3/4] Yet another fix for the encoding problems --- pyrogram/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrogram/__init__.py b/pyrogram/__init__.py index 469dd399..f2075f8c 100644 --- a/pyrogram/__init__.py +++ b/pyrogram/__init__.py @@ -20,7 +20,7 @@ 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" From 6f9c12bfe958b5d2cf1b277f277d32f46ede2ed1 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Tue, 27 Mar 2018 12:56:28 +0200 Subject: [PATCH 4/4] Update to v0.6.5 --- pyrogram/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrogram/__init__.py b/pyrogram/__init__.py index f2075f8c..96ce0e30 100644 --- a/pyrogram/__init__.py +++ b/pyrogram/__init__.py @@ -23,7 +23,7 @@ __copyright__ = "Copyright (C) 2017-2018 Dan Tès