From b667bb0c1a8cac480ca2ddc40be2d9ae6bc5d99f Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sun, 20 May 2018 12:28:57 +0200 Subject: [PATCH 01/16] Fix some chat IDs start with 1000 --- telethon/utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/telethon/utils.py b/telethon/utils.py index 0ba64177..ddf68cca 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -552,8 +552,13 @@ def resolve_id(marked_id): if marked_id >= 0: return marked_id, PeerUser - if str(marked_id).startswith('-100'): - return int(str(marked_id)[4:]), PeerChannel + # There have been report of chat IDs being 10000xyz, which means their + # marked version is -10000xyz, which in turn looks like a channel but + # it becomes 00xyz (= xyz). Hence, we must assert that there are only + # two zeroes. + m = re.match(r'-100([^0]\d*)', str(marked_id)) + if m: + return int(m.group(1)), PeerChannel return -marked_id, PeerChat From fac6b2348b88e269d76324d3ad27cc4a15ca2cdf Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Tue, 22 May 2018 10:39:40 +0200 Subject: [PATCH 02/16] Fix pts may be 0 with no workers set (#808) --- telethon/telegram_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index 4cc3de08..ffc18655 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -2436,7 +2436,7 @@ class TelegramClient(TelegramBareClient): def catch_up(self): state = self.session.get_update_state(0) - if not state: + if not state or not state.pts: return self.session.catching_up = True From bb0d29bdd52fb5bd6e0d4556676133a42f68c43c Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Tue, 22 May 2018 19:21:01 +0200 Subject: [PATCH 03/16] Fix unboxed serialization including constructor ID This only affected FutureSalts, but it's useful that it behaves the way it should. cc @JuanPotato for spotting the bug. --- telethon_generator/generators/tlobject.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/telethon_generator/generators/tlobject.py b/telethon_generator/generators/tlobject.py index 36d1f013..1058a1ae 100644 --- a/telethon_generator/generators/tlobject.py +++ b/telethon_generator/generators/tlobject.py @@ -466,6 +466,12 @@ def _write_arg_to_bytes(builder, arg, args, name=None): # Else it may be a custom type builder.write('bytes({})', name) + # If the type is not boxed (i.e. starts with lowercase) we should + # not serialize the constructor ID (so remove its first 4 bytes). + boxed = arg.type[arg.type.find('.') + 1].isupper() + if not boxed: + builder.write('[4:]') + if arg.is_flag: builder.write(')') if arg.is_vector: From c3e5d390ebdae92ca39202d79a810bd747bf8cf3 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Wed, 23 May 2018 18:50:28 +0200 Subject: [PATCH 04/16] Add optional dark theme for the docs --- telethon_generator/data/html/core.html | 25 ++- .../data/html/css/docs.dark.css | 185 ++++++++++++++++++ .../html/css/{docs.css => docs.light.css} | 13 -- telethon_generator/docs_writer.py | 17 +- telethon_generator/generators/docs.py | 19 +- 5 files changed, 235 insertions(+), 24 deletions(-) create mode 100644 telethon_generator/data/html/css/docs.dark.css rename telethon_generator/data/html/css/{docs.css => docs.light.css} (95%) diff --git a/telethon_generator/data/html/core.html b/telethon_generator/data/html/core.html index 25295494..91aefbb8 100644 --- a/telethon_generator/data/html/core.html +++ b/telethon_generator/data/html/core.html @@ -4,7 +4,16 @@ Telethon API - + +