From b4c28de104d790c990f3945c4964e33748c431df Mon Sep 17 00:00:00 2001 From: _run Date: Wed, 7 Sep 2022 20:44:39 +0400 Subject: [PATCH] Update asyncio_helper.py --- telebot/asyncio_helper.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/telebot/asyncio_helper.py b/telebot/asyncio_helper.py index 06575db..00d4aa3 100644 --- a/telebot/asyncio_helper.py +++ b/telebot/asyncio_helper.py @@ -159,15 +159,13 @@ async def get_file_url(token, file_id): async def download_file(token, file_path): if FILE_URL is None: url = "https://api.telegram.org/file/bot{0}/{1}".format(token, file_path) - else: - # noinspection PyUnresolvedReferences - url = FILE_URL.format(token, file_path) - async with await session_manager.get_session() as session: - async with session.get(url, proxy=proxy) as response: - result = await response.read() - if response.status != 200: - raise ApiHTTPException('Download file', result) - + else: url = FILE_URL.format(token, file_path) + session = await session_manager.get_session() + async with session.get(url, proxy=proxy) as response: + if response.status != 200: + raise ApiHTTPException('Download file', result) + result = await response.read() + return result