From 9f9da6adda2bf3fb596d6f9b9c6603be1f0f7a80 Mon Sep 17 00:00:00 2001 From: Tanuj Date: Tue, 24 Oct 2017 21:08:44 +0100 Subject: [PATCH 1/5] Remove comma (#376) --- telethon_examples/print_updates.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telethon_examples/print_updates.py b/telethon_examples/print_updates.py index e315ff98..c90302e4 100755 --- a/telethon_examples/print_updates.py +++ b/telethon_examples/print_updates.py @@ -10,7 +10,7 @@ from os import environ def main(): session_name = environ.get('TG_SESSION','session') - user_phone = environ['TG_PHONE'], + user_phone = environ['TG_PHONE'] client = TelegramClient(session_name, int(environ['TG_API_ID']), environ['TG_API_HASH'], From e427559d4c8dd3a97f2772f90295dab450eca011 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Wed, 25 Oct 2017 12:22:03 +0200 Subject: [PATCH 2/5] Fix username invalid error having wrong username regex --- telethon_generator/error_descriptions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telethon_generator/error_descriptions b/telethon_generator/error_descriptions index f0a14e68..500504d7 100644 --- a/telethon_generator/error_descriptions +++ b/telethon_generator/error_descriptions @@ -45,7 +45,7 @@ PHONE_NUMBER_OCCUPIED=The phone number is already in use PHONE_NUMBER_UNOCCUPIED=The phone number is not yet being used PHOTO_INVALID_DIMENSIONS=The photo dimensions are invalid TYPE_CONSTRUCTOR_INVALID=The type constructor is invalid -USERNAME_INVALID=Unacceptable username. Must match r"[a-zA-Z][\w\d]{4,31}" +USERNAME_INVALID=Unacceptable username. Must match r"[a-zA-Z][\w\d]{3,30}[a-zA-Z\d]" USERNAME_NOT_MODIFIED=The username is not different from the current username USERNAME_NOT_OCCUPIED=The username is not in use by anyone else yet USERNAME_OCCUPIED=The username is already taken From 3db13ccdd299349601afde6da22507a97ac7895a Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Wed, 25 Oct 2017 12:43:57 +0200 Subject: [PATCH 3/5] Add a more descriptive error when serializing bytes --- telethon/tl/tlobject.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/telethon/tl/tlobject.py b/telethon/tl/tlobject.py index 67a86300..1bd57878 100644 --- a/telethon/tl/tlobject.py +++ b/telethon/tl/tlobject.py @@ -93,8 +93,11 @@ class TLObject: @staticmethod def serialize_bytes(data): """Write bytes by using Telegram guidelines""" - if isinstance(data, str): - data = data.encode('utf-8') + if not isinstance(data, bytes): + if isinstance(data, str): + data = data.encode('utf-8') + else: + raise ValueError('bytes or str expected, not', type(data)) r = [] if len(data) < 254: From c6d30ffceb679e71c9de208f42f86e66fba3c924 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Wed, 25 Oct 2017 13:04:12 +0200 Subject: [PATCH 4/5] Fix exception when logging exceptions --- telethon/update_state.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/telethon/update_state.py b/telethon/update_state.py index 8dd2ffad..9410125e 100644 --- a/telethon/update_state.py +++ b/telethon/update_state.py @@ -119,10 +119,10 @@ class UpdateState: handler(update) except StopIteration: break - except Exception as e: + except: # We don't want to crash a worker thread due to any reason - self._logger.debug( - '[ERROR] Unhandled exception on worker {}'.format(wid), e + self._logger.exception( + '[ERROR] Unhandled exception on worker {}'.format(wid) ) def process(self, update): From e6ac61c1b9db73e18b643f8f424727d2fd5aba1f Mon Sep 17 00:00:00 2001 From: Andrei Fokau Date: Wed, 25 Oct 2017 19:48:46 +0200 Subject: [PATCH 5/5] Add missing __init__.py to telethon_generator package (#382) --- telethon_generator/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 telethon_generator/__init__.py diff --git a/telethon_generator/__init__.py b/telethon_generator/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/telethon_generator/__init__.py @@ -0,0 +1 @@ +