From 4b76bd4f6e80a79665f964183bb4a7b9cfd3d505 Mon Sep 17 00:00:00 2001 From: Aza Maulana Date: Wed, 30 Sep 2020 13:48:31 +0700 Subject: [PATCH] issue #3: give option to change bar size --- bot/__init__.py | 3 ++- bot/handlers/leech_handler.py | 4 ++-- bot/handlers/upload_to_tg_handler.py | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bot/__init__.py b/bot/__init__.py index 4993c505..f0142502 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -16,7 +16,8 @@ 'CHAT_ID' : [], 'EDIT_SLEEP' : 3, 'UPLOAD_MAX_SIZE' : 2000 * 1024 * 1024, - 'ARIA2_DIR' : 'downloads' + 'ARIA2_DIR' : 'downloads', + 'BAR_SIZE' : 10 }) # GOAL: diff --git a/bot/handlers/leech_handler.py b/bot/handlers/leech_handler.py index 34afb7e6..5fb40dfa 100644 --- a/bot/handlers/leech_handler.py +++ b/bot/handlers/leech_handler.py @@ -92,8 +92,8 @@ async def progress_dl(message : Message, aria2_api : aria2.aria2, gid : int, pre if not download.is_complete: if not download.error_message: block = "" - for i in range(1, 11): - if i <= floor(download.progress/10): + for i in range(1, CONFIG.BAR_SIZE + 1): + if i <= floor(download.progress * CONFIG.BAR_SIZE/100): block += LOCAL.BLOCK_FILLED else: block += LOCAL.BLOCK_EMPTY diff --git a/bot/handlers/upload_to_tg_handler.py b/bot/handlers/upload_to_tg_handler.py index bd2cf606..ba865d88 100644 --- a/bot/handlers/upload_to_tg_handler.py +++ b/bot/handlers/upload_to_tg_handler.py @@ -117,8 +117,8 @@ async def upload_fn(chat_id, file, **kwargs): async def progress_upload_tg(current, total, message, info): percentage = round(current * 10000 / total) / 100 block = "" - for i in range(1, 11): - if i <= floor(percentage/10): + for i in range(1, CONFIG.BAR_SIZE + 1): + if i <= floor(percentage * CONFIG.BAR_SIZE/100): block += LOCAL.BLOCK_FILLED else: block += LOCAL.BLOCK_EMPTY