2022-06-04 22:02:51 +03:00
|
|
|
import io
|
|
|
|
import typing as t
|
|
|
|
|
|
|
|
from load import bot, config
|
|
|
|
|
2022-06-05 15:02:41 +03:00
|
|
|
|
2022-06-04 22:02:51 +03:00
|
|
|
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)
|