/cancel, /identify, sponsorships improvements and fixes #3

Merged
profitroll merged 19 commits from dev into master 2023-01-03 16:45:20 +02:00
Showing only changes of commit ea1dc542a3 - Show all commits

View File

@ -193,6 +193,15 @@ def find_location(query: str) -> dict:
raise PlaceNotFoundError(query) raise PlaceNotFoundError(query)
def create_tmp(bytedata: Union[bytes, bytearray], kind: Union[Literal["image", "video"], None]) -> str: def create_tmp(bytedata: Union[bytes, bytearray], kind: Union[Literal["image", "video"], None]) -> str:
"""Create temporary file to help uploading it
### Args:
* bytedata (`Union[bytes, bytearray]`): Some bytes to be written
* kind (`Union[Literal["image", "video"], None]`): Kind of upload. Will add `.jpg` or `.mp4` if needed
### Returns:
* `str`: Path to temporary file
"""
filename = str(uuid1()) filename = str(uuid1())
if kind == "image": if kind == "image":
filename += ".jpg" filename += ".jpg"
@ -204,6 +213,15 @@ def create_tmp(bytedata: Union[bytes, bytearray], kind: Union[Literal["image", "
return path.join("tmp", filename) return path.join("tmp", filename)
async def download_tmp(app: Client, file_id: str) -> bytes: async def download_tmp(app: Client, file_id: str) -> bytes:
"""Download file by its ID and return its bytes
### Args:
* app (`Client`): App that will download the file
* file_id (`str`): File's unique id
### Returns:
* `bytes`: Bytes of downloaded file
"""
filename = str(uuid1()) filename = str(uuid1())
makedirs("tmp", exist_ok=True) makedirs("tmp", exist_ok=True)
await app.download_media(file_id, path.join("tmp", filename)) await app.download_media(file_id, path.join("tmp", filename))