From 0e446579639cc9f439700e6015a960c99ef92a87 Mon Sep 17 00:00:00 2001 From: Belegnar Date: Fri, 10 Mar 2017 14:13:22 +0300 Subject: [PATCH 1/2] * doc improvement * relative imports not allowed when module is not loaded (https://www.python.org/dev/peps/pep-0366/) --- README.rst | 2 +- telethon_generator/tl_generator.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 63e4bbc3..14557bd7 100755 --- a/README.rst +++ b/README.rst @@ -56,7 +56,7 @@ Installing Telethon manually (`GitHub `_, `package index `_) 2. Clone Telethon's GitHub repository: ``git clone https://github.com/LonamiWebs/Telethon.git`` 3. Enter the cloned repository: ``cd Telethon`` -4. Run the code generator: ``python3 telethon_generator/tl_generator.py`` +4. Run the code generator: ``cd telethon_generator && python3 tl_generator.py`` 5. Done! Running Telethon diff --git a/telethon_generator/tl_generator.py b/telethon_generator/tl_generator.py index 44df11e2..66a9a663 100755 --- a/telethon_generator/tl_generator.py +++ b/telethon_generator/tl_generator.py @@ -2,7 +2,10 @@ import os import re import shutil -from .parser import SourceBuilder, TLParser +try: + from .parser import SourceBuilder, TLParser +except (ImportError, SystemError): + from parser import SourceBuilder, TLParser def get_output_path(normal_path): From 8753df27ed53ecf17ac9d634fcfe70daa2778a00 Mon Sep 17 00:00:00 2001 From: Belegnar Date: Fri, 10 Mar 2017 14:14:51 +0300 Subject: [PATCH 2/2] * reconnect in TelegramClient.connect() forces reconnect only if client was connected --- telethon/telegram_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index 68ca06d0..510c8a8c 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -90,7 +90,7 @@ class TelegramClient: Note that authenticating to the Telegram servers is not the same as authenticating the app, which requires to send a code first.""" try: - if not self.session.auth_key or reconnect: + if not self.session.auth_key or (reconnect and self.sender is not None): self.session.auth_key, self.session.time_offset = \ authenticator.do_authentication(self.transport) @@ -146,6 +146,7 @@ class TelegramClient: """Disconnects from the Telegram server **and pauses all the spawned threads**""" if self.sender: self.sender.disconnect() + self.sender = None # endregion