download_file behaves differently if a local bot API server is used. Wrong default API url was being used

This commit is contained in:
Davte 2024-02-17 15:44:04 +01:00
parent 748ba624a4
commit 3969794075
Signed by: Davte
GPG Key ID: 70336F92E6814706
3 changed files with 25 additions and 22 deletions

View File

@ -11,7 +11,7 @@ __author__ = "Davide Testa"
__email__ = "davide@davte.it" __email__ = "davide@davte.it"
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"] __credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
__license__ = "GNU General Public License v3.0" __license__ = "GNU General Public License v3.0"
__version__ = "2.9.10" __version__ = "2.9.11"
__maintainer__ = "Davide Testa" __maintainer__ = "Davide Testa"
__contact__ = "t.me/davte" __contact__ = "t.me/davte"

View File

@ -358,7 +358,7 @@ class TelegramBot:
All mirrored methods are camelCase. All mirrored methods are camelCase.
""" """
_loop = None _loop = None
_api_url = "https://api.telegram.org/bot" _api_url = "https://api.telegram.org"
app = aiohttp.web.Application() app = aiohttp.web.Application()
sessions_timeouts = { sessions_timeouts = {

View File

@ -2138,6 +2138,7 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
if file is None or isinstance(file, Exception): if file is None or isinstance(file, Exception):
logging.error(f"{file}") logging.error(f"{file}")
return file return file
if self.api_url == 'https://api.telegram.org':
file_bytes = await async_get( file_bytes = await async_get(
url=( url=(
f"{self.api_url}/file/" f"{self.api_url}/file/"
@ -2158,6 +2159,8 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
except Exception as e: except Exception as e:
logging.error(f"File download failed due to {e}") logging.error(f"File download failed due to {e}")
return e return e
else:
file_complete_path = file['file_path']
return dict(file_id=file_id, return dict(file_id=file_id,
file_name=file_name, file_name=file_name,
path=path, path=path,