From 2e980f45f471c36ff6e8addec7ee14e35d750d17 Mon Sep 17 00:00:00 2001 From: Viicos <65306057+Viicos@users.noreply.github.com> Date: Sun, 20 Nov 2022 13:37:15 +0100 Subject: [PATCH] Use snake case in 'Downloading a file' examples --- Code-snippets.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Code-snippets.md b/Code-snippets.md index 8887c2c..5512c3a 100644 --- a/Code-snippets.md +++ b/Code-snippets.md @@ -352,8 +352,8 @@ When you receive files from a user, you sometimes want to download and save them ```python file_id = message.document.file_id -newFile = await bot.get_file(file_id) -await newFile.download() +new_file = await bot.get_file(file_id) +await new_file.download() ``` For a received video/voice/... change `message.document` to `message.video/voice/...`. However, there is one exception: `message.photo` is a *list* of `PhotoSize` objects, which represent different sizes of the same photo. Use `message.photo[-1].file_id` to get the largest size. @@ -361,8 +361,8 @@ For a received video/voice/... change `message.document` to `message.video/voice Moreover, the above snippet can be shortened by using PTBs built-in utility shortcuts: ```python -newFile = await message.effective_attachment.get_file() -await newFile.download('file_name') +new_file = await message.effective_attachment.get_file() +await new_file.download('file_name') ``` `message.effective_attachment` automatically contains whichever media attachment the message has - in case of a photo, you'll again have to use e.g. `message.effective_attachment[-1].get_file()`