1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Update asyncio_helper.py

This commit is contained in:
_run 2022-09-07 20:44:39 +04:00 committed by GitHub
parent de344bd5e0
commit b4c28de104
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -159,14 +159,12 @@ async def get_file_url(token, file_id):
async def download_file(token, file_path): async def download_file(token, file_path):
if FILE_URL is None: if FILE_URL is None:
url = "https://api.telegram.org/file/bot{0}/{1}".format(token, file_path) url = "https://api.telegram.org/file/bot{0}/{1}".format(token, file_path)
else: else: url = FILE_URL.format(token, file_path)
# noinspection PyUnresolvedReferences session = await session_manager.get_session()
url = FILE_URL.format(token, file_path) async with session.get(url, proxy=proxy) as response:
async with await session_manager.get_session() as session: if response.status != 200:
async with session.get(url, proxy=proxy) as response: raise ApiHTTPException('Download file', result)
result = await response.read() result = await response.read()
if response.status != 200:
raise ApiHTTPException('Download file', result)
return result return result