14 lines
404 B
Python
14 lines
404 B
Python
|
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)
|