From ee47c21eedc69ee6d6f92484bd6373b16e2887a1 Mon Sep 17 00:00:00 2001 From: Alexandr Date: Fri, 19 Oct 2018 23:39:29 +0700 Subject: [PATCH 1/8] Add file size limit error --- pyrogram/client/client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index b19bb486..d4afd9be 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -1123,6 +1123,7 @@ class Client(Methods, BaseClient): progress_args: tuple = ()): part_size = 512 * 1024 file_size = os.path.getsize(path) + assert file_size < 1500 * 1024 * 1024, "Couldn't upload file bigger 1500MiB" file_total_parts = int(math.ceil(file_size / part_size)) is_big = True if file_size > 10 * 1024 * 1024 else False is_missing_part = True if file_id is not None else False From fa5759b07b0cb54fe912ff7d5195ef3efa675c56 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 21 Oct 2018 14:41:30 +0700 Subject: [PATCH 2/8] Thanks, that really looks better Co-Authored-By: TolichP --- 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 d4afd9be..9deecd3d 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -1123,7 +1123,8 @@ class Client(Methods, BaseClient): progress_args: tuple = ()): part_size = 512 * 1024 file_size = os.path.getsize(path) - assert file_size < 1500 * 1024 * 1024, "Couldn't upload file bigger 1500MiB" + if file_size > 1500 * 1024 * 1024: + raise ValueError("Telegram doesn't support uploading files bigger than 1500 MiB") file_total_parts = int(math.ceil(file_size / part_size)) is_big = True if file_size > 10 * 1024 * 1024 else False is_missing_part = True if file_id is not None else False From a0780d793da04ebbe51a6e426dc31fb9ed65d0ab Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 21 Oct 2018 14:41:30 +0700 Subject: [PATCH 3/8] Apply code review suggestions --- 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 d4afd9be..9deecd3d 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -1123,7 +1123,8 @@ class Client(Methods, BaseClient): progress_args: tuple = ()): part_size = 512 * 1024 file_size = os.path.getsize(path) - assert file_size < 1500 * 1024 * 1024, "Couldn't upload file bigger 1500MiB" + if file_size > 1500 * 1024 * 1024: + raise ValueError("Telegram doesn't support uploading files bigger than 1500 MiB") file_total_parts = int(math.ceil(file_size / part_size)) is_big = True if file_size > 10 * 1024 * 1024 else False is_missing_part = True if file_id is not None else False From 09563067c77404326233ae5fbc49711c025b483d Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 3 Nov 2018 11:10:43 +0100 Subject: [PATCH 4/8] Add a check for 0 B file sizes --- pyrogram/client/client.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 9deecd3d..33f11bad 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -1123,8 +1123,13 @@ class Client(Methods, BaseClient): progress_args: tuple = ()): part_size = 512 * 1024 file_size = os.path.getsize(path) + + if file_size == 0: + raise ValueError("File size equals to 0 B") + if file_size > 1500 * 1024 * 1024: raise ValueError("Telegram doesn't support uploading files bigger than 1500 MiB") + file_total_parts = int(math.ceil(file_size / part_size)) is_big = True if file_size > 10 * 1024 * 1024 else False is_missing_part = True if file_id is not None else False From bc703ae6d733631220986c4984494a27afdc699e Mon Sep 17 00:00:00 2001 From: Furoin Date: Sat, 3 Nov 2018 14:57:57 +0300 Subject: [PATCH 5/8] added Filters.dan --- pyrogram/client/filters/filters.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyrogram/client/filters/filters.py b/pyrogram/client/filters/filters.py index 173b211c..aeb730a7 100644 --- a/pyrogram/client/filters/filters.py +++ b/pyrogram/client/filters/filters.py @@ -166,6 +166,8 @@ class Filters: inline_keyboard = create("InlineKeyboard", lambda _, m: isinstance(m.reply_markup, InlineKeyboardMarkup)) """Filter messages containing inline keyboard markups""" + dan = create("Dan", lambda _, m: bool(m.from_user and m.from_user.id == 23122162)) + @staticmethod def command(command: str or list, prefix: str or list = "/", From caea507f058f412806da34c74364b974dac4513c Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 3 Nov 2018 14:23:48 +0100 Subject: [PATCH 6/8] Remove undoc-members for Filters doc page --- docs/source/pyrogram/Filters.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/source/pyrogram/Filters.rst b/docs/source/pyrogram/Filters.rst index 083bd64a..091031ae 100644 --- a/docs/source/pyrogram/Filters.rst +++ b/docs/source/pyrogram/Filters.rst @@ -3,4 +3,3 @@ Filters .. autoclass:: pyrogram.Filters :members: - :undoc-members: From a48e0ce33ad948809258342368d148699a755bec Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 3 Nov 2018 14:24:02 +0100 Subject: [PATCH 7/8] Update Installation page --- docs/source/start/Installation.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/source/start/Installation.rst b/docs/source/start/Installation.rst index 2a738b57..e7b2eb3d 100644 --- a/docs/source/start/Installation.rst +++ b/docs/source/start/Installation.rst @@ -50,14 +50,18 @@ Use this command to install: $ pip3 install --upgrade git+https://github.com/pyrogram/pyrogram.git@asyncio -Pyrogram API remains the same and features are kept up to date from the non-async, default develop branch. +Pyrogram API remains the same and features are kept up to date from the non-async, default develop branch, but you +are obviously required Python asyncio knowledge in order to take full advantage of it. -.. note:: +.. tip:: The idea to turn Pyrogram fully asynchronous is still under consideration, but is wise to expect that in future this would be the one and only way to work with Pyrogram. + You can start using Pyrogram Async variant right now as an excuse to learn more about asynchronous programming and + do experiments with it! + .. raw:: html