ShopBot/utils/helper.py

14 lines
404 B
Python
Raw Normal View History

2022-06-04 22:02:51 +03:00
import io
import typing as t
from load import bot, config
async def download_file(file_path, *args, **kw) -> t.Union[io.BytesIO, t.Any]:
if config.telegram_api_server == "https://api.telegram.org":
return await bot.download_file(file_path, *args, **kw)
else:
with open(file_path, 'rb') as f:
file = f.read()
f.close()
return io.BytesIO(file)