@bot.on.message()
async def handle_message(message: Message):
download(message.attachments[0].photo.sizes[-5].url)
import requests
def download(url):
response = requests.get(url)
if response.status_code == 200:
with open('...image.jpg', 'wb') as file:
file.write(response.content)
return "Фото скачено"
else:
print(response.status_code)