From c03dd6037f93c83310682d8bf797e8aeaccbb04f Mon Sep 17 00:00:00 2001 From: JEEPEO <47288442+Jeepeo@users.noreply.github.com> Date: Sun, 14 Apr 2019 14:06:17 +0530 Subject: [PATCH 01/13] Update client.py --- pyrogram/client/client.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index fc749033df..0a18509ea0 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -236,6 +236,8 @@ def __init__( self.plugins = plugins self.no_updates = no_updates self.takeout = takeout + self.load_session_hook = None + self.save_session_hook = None self.dispatcher = Dispatcher(self, workers) @@ -288,7 +290,10 @@ async def start(self): 'More info: https://docs.pyrogram.ml/start/Setup#bot-authorization\n') self.load_config() - await self.load_session() + if callable(self.load_session_hook): + await self.load_session_hook(self) + else: + await self.load_session(self.session_name) self.load_plugins() self.session = Session( @@ -309,7 +314,10 @@ async def start(self): self.is_bot = True await self.authorize_bot() - self.save_session() + if callable(self.save_session_hook): + self.save_session_hook(self) + else: + self.save_session() if not self.is_bot: if self.takeout: From 9dd736be977cadcd83dbbb9695d0a523da478a58 Mon Sep 17 00:00:00 2001 From: JEEPEO <47288442+Jeepeo@users.noreply.github.com> Date: Sun, 14 Apr 2019 14:27:02 +0530 Subject: [PATCH 02/13] Update client.py --- pyrogram/client/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 0a18509ea0..a484bff8e6 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -293,7 +293,7 @@ async def start(self): if callable(self.load_session_hook): await self.load_session_hook(self) else: - await self.load_session(self.session_name) + await self.load_session() self.load_plugins() self.session = Session( From 6c06ad78e7c29aa11bd491b4711d684fef60f52c Mon Sep 17 00:00:00 2001 From: JEEPEO <47288442+Jeepeo@users.noreply.github.com> Date: Sun, 14 Apr 2019 14:44:40 +0530 Subject: [PATCH 03/13] Update client.py --- pyrogram/client/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index a484bff8e6..7d81799b9c 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -291,9 +291,9 @@ async def start(self): self.load_config() if callable(self.load_session_hook): - await self.load_session_hook(self) + self.load_session_hook(self) else: - await self.load_session() + self.load_session() self.load_plugins() self.session = Session( From c23cd874fe088a5719ef72f7e674d11c591ae348 Mon Sep 17 00:00:00 2001 From: JEEPEO <47288442+Jeepeo@users.noreply.github.com> Date: Sun, 14 Apr 2019 14:49:03 +0530 Subject: [PATCH 04/13] Update __init__.py --- pyrogram/client/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrogram/client/__init__.py b/pyrogram/client/__init__.py index d43511d257..0a340db018 100644 --- a/pyrogram/client/__init__.py +++ b/pyrogram/client/__init__.py @@ -16,7 +16,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from .client import Client +from .client import Client, ApiKey from .ext import BaseClient, ChatAction, Emoji, ParseMode from .filters import Filters From c284e8355657dcd214931e5b77eca3b69dee1e03 Mon Sep 17 00:00:00 2001 From: JEEPEO <47288442+Jeepeo@users.noreply.github.com> Date: Sun, 14 Apr 2019 14:52:35 +0530 Subject: [PATCH 05/13] Update client.py --- pyrogram/client/client.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 7d81799b9c..5df10b0292 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -297,10 +297,13 @@ async def start(self): self.load_plugins() self.session = Session( - self, - self.dc_id, - self.auth_key - ) + self.dc_id, + self.test_mode, + self.proxy, + self.auth_key, + self.api_key.api_id, + client=self + ) await self.session.start() self.is_started = True From a1d24aa95ea5fd3c2c309d0bce523c71b907e285 Mon Sep 17 00:00:00 2001 From: JEEPEO <47288442+Jeepeo@users.noreply.github.com> Date: Sun, 14 Apr 2019 15:00:38 +0530 Subject: [PATCH 06/13] Update __init__.py --- pyrogram/client/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrogram/client/__init__.py b/pyrogram/client/__init__.py index 0a340db018..d43511d257 100644 --- a/pyrogram/client/__init__.py +++ b/pyrogram/client/__init__.py @@ -16,7 +16,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from .client import Client, ApiKey +from .client import Client from .ext import BaseClient, ChatAction, Emoji, ParseMode from .filters import Filters From bd3b8d0d108625f0bd1566affc5608aa50d50ec1 Mon Sep 17 00:00:00 2001 From: JEEPEO <47288442+Jeepeo@users.noreply.github.com> Date: Sun, 14 Apr 2019 15:07:43 +0530 Subject: [PATCH 07/13] Update client.py --- pyrogram/client/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 5df10b0292..6cdb951808 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -301,7 +301,7 @@ async def start(self): self.test_mode, self.proxy, self.auth_key, - self.api_key.api_id, + self.api_hash.api_id, client=self ) From c06389e25d667707834f7e28682723139431897a Mon Sep 17 00:00:00 2001 From: JEEPEO <47288442+Jeepeo@users.noreply.github.com> Date: Sun, 14 Apr 2019 15:14:52 +0530 Subject: [PATCH 08/13] Update client.py --- pyrogram/client/client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 6cdb951808..d54f96fd20 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -301,7 +301,8 @@ async def start(self): self.test_mode, self.proxy, self.auth_key, - self.api_hash.api_id, + self.api_hash, + self.api_id, client=self ) From c3dacdfe9d1fed338f35bb799aa2f6bc3bcef5d8 Mon Sep 17 00:00:00 2001 From: JEEPEO <47288442+Jeepeo@users.noreply.github.com> Date: Sun, 14 Apr 2019 15:19:12 +0530 Subject: [PATCH 09/13] Update client.py --- pyrogram/client/client.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index d54f96fd20..69b448fbaf 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -302,8 +302,7 @@ async def start(self): self.proxy, self.auth_key, self.api_hash, - self.api_id, - client=self + self.api_id ) await self.session.start() From 48c3d51bee099333358bcdac67d8247e2bf64ba7 Mon Sep 17 00:00:00 2001 From: JEEPEO <47288442+Jeepeo@users.noreply.github.com> Date: Sun, 14 Apr 2019 15:23:20 +0530 Subject: [PATCH 10/13] Update client.py --- pyrogram/client/client.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 69b448fbaf..8772b18b54 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -301,8 +301,7 @@ async def start(self): self.test_mode, self.proxy, self.auth_key, - self.api_hash, - self.api_id + self.api_hash ) await self.session.start() From 384d3975f3147cc576d4098a9eca8f852fbe2456 Mon Sep 17 00:00:00 2001 From: JEEPEO <47288442+Jeepeo@users.noreply.github.com> Date: Sun, 14 Apr 2019 15:28:15 +0530 Subject: [PATCH 11/13] Update client.py --- pyrogram/client/client.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 8772b18b54..f1f63089f3 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -298,10 +298,9 @@ async def start(self): self.session = Session( self.dc_id, - self.test_mode, - self.proxy, self.auth_key, - self.api_hash + self.api_hash, + self.api_id ) await self.session.start() From cb16bf732886e28615e4375fa596b2906d170dfe Mon Sep 17 00:00:00 2001 From: JEEPEO <47288442+Jeepeo@users.noreply.github.com> Date: Sun, 14 Apr 2019 15:35:21 +0530 Subject: [PATCH 12/13] Update client.py --- pyrogram/client/client.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index f1f63089f3..92784326b2 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -297,10 +297,9 @@ async def start(self): self.load_plugins() self.session = Session( + self, self.dc_id, - self.auth_key, - self.api_hash, - self.api_id + self.auth_key ) await self.session.start() From 76193b5c4096ca909800a633dec84a3f5247cb41 Mon Sep 17 00:00:00 2001 From: JEEPEO <47288442+Jeepeo@users.noreply.github.com> Date: Sun, 14 Apr 2019 15:40:57 +0530 Subject: [PATCH 13/13] Update client.py --- pyrogram/client/client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 92784326b2..0773504167 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -299,7 +299,8 @@ async def start(self): self.session = Session( self, self.dc_id, - self.auth_key + self.auth_key, + self.api_id.encode('utf-8') ) await self.session.start()