botapi-py 1.4.10__tar.gz → 1.4.11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {botapi_py-1.4.10 → botapi_py-1.4.11}/PKG-INFO +1 -1
- {botapi_py-1.4.10 → botapi_py-1.4.11}/pyproject.toml +1 -1
- {botapi_py-1.4.10 → botapi_py-1.4.11}/src/botapi/shortcuts.py +1 -49
- {botapi_py-1.4.10 → botapi_py-1.4.11}/src/botapi/__init__.py +0 -0
- {botapi_py-1.4.10 → botapi_py-1.4.11}/src/botapi/__init__.pyi +0 -0
- {botapi_py-1.4.10 → botapi_py-1.4.11}/src/botapi/core.py +0 -0
- {botapi_py-1.4.10 → botapi_py-1.4.11}/src/botapi/dispatchers/__init__.py +0 -0
- {botapi_py-1.4.10 → botapi_py-1.4.11}/src/botapi/dispatchers/__init__.pyi +0 -0
- {botapi_py-1.4.10 → botapi_py-1.4.11}/src/botapi/dispatchers/common.py +0 -0
- {botapi_py-1.4.10 → botapi_py-1.4.11}/src/botapi/dispatchers/get_updates_handler.py +0 -0
- {botapi_py-1.4.10 → botapi_py-1.4.11}/src/botapi/dispatchers/redis_pubsub_handler.py +0 -0
- {botapi_py-1.4.10 → botapi_py-1.4.11}/src/botapi/enums.py +0 -0
- {botapi_py-1.4.10 → botapi_py-1.4.11}/src/botapi/errors.py +0 -0
- {botapi_py-1.4.10 → botapi_py-1.4.11}/src/botapi/methods.py +0 -0
- {botapi_py-1.4.10 → botapi_py-1.4.11}/src/botapi/types.py +0 -0
- {botapi_py-1.4.10 → botapi_py-1.4.11}/src/botapi/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import Optional, Union, List, cast
|
|
3
|
+
from typing import Optional, Union, List, cast
|
|
4
4
|
|
|
5
5
|
from . import enums
|
|
6
6
|
from . import types
|
|
@@ -243,51 +243,3 @@ class BotShortcuts:
|
|
|
243
243
|
case _:
|
|
244
244
|
raise ValueError(f'Unknown media type: {file_type}')
|
|
245
245
|
|
|
246
|
-
@overload
|
|
247
|
-
async def download_file(
|
|
248
|
-
self,
|
|
249
|
-
file: types.File,
|
|
250
|
-
destination_path: str
|
|
251
|
-
) -> None: ...
|
|
252
|
-
|
|
253
|
-
@overload
|
|
254
|
-
async def download_file(
|
|
255
|
-
self,
|
|
256
|
-
file: types.File,
|
|
257
|
-
destination_path: None = None
|
|
258
|
-
) -> bytes: ...
|
|
259
|
-
|
|
260
|
-
async def download_file(
|
|
261
|
-
self,
|
|
262
|
-
file: types.File,
|
|
263
|
-
destination_path: Optional[str] = None
|
|
264
|
-
) -> bytes | None:
|
|
265
|
-
'''
|
|
266
|
-
Convenience method to download a file from Telegram servers.
|
|
267
|
-
|
|
268
|
-
Call this method with a `File` object obtained via `get_file`.
|
|
269
|
-
|
|
270
|
-
:param file: File object to download.
|
|
271
|
-
:param destination_path: Optional path to save the downloaded file. If not provided, the file content will be returned as bytes.
|
|
272
|
-
:return: The file content as bytes if destination_path is not provided, otherwise None.
|
|
273
|
-
'''
|
|
274
|
-
self = cast(methods.Bot, self)
|
|
275
|
-
|
|
276
|
-
file_path = file.file_path
|
|
277
|
-
if not file_path:
|
|
278
|
-
raise ValueError('The file does not have a valid file_path to download.')
|
|
279
|
-
|
|
280
|
-
# https://api.telegram.org/file/bot<token>/<file_path>
|
|
281
|
-
# https://api.telegram.org/file/bot<token>/test/<file_path>
|
|
282
|
-
url = self._compose_api_file_url(file_path=file_path) # pyright: ignore[reportPrivateUsage]
|
|
283
|
-
|
|
284
|
-
response = await self.session.get(url)
|
|
285
|
-
content = response.content
|
|
286
|
-
|
|
287
|
-
if destination_path:
|
|
288
|
-
with open(destination_path, 'wb') as f:
|
|
289
|
-
f.write(content)
|
|
290
|
-
return None
|
|
291
|
-
|
|
292
|
-
return content
|
|
293
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|