P
P
Python Newbie2021-08-17 09:01:00
Python
Python Newbie, 2021-08-17 09:01:00

How to get a link to take a picture of a telegram bot sent by a user?

How to get a link to a photo sent by a user to a bot in a telegram?

I could only find how to download the photo, but I need a link.
I use aigram.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Altry, 2021-08-17
@Levman5

There is a very crutch method, but if you really need it:

file = await bot.get_file(message.photo[-1].file_id) # message - тип того что вам пришло.
url = f'https://api.telegram.org/file/bot{BOT_TOKEN}/{file.file_path}'

The link to the file on the telegram servers will always be the same, just don't give it to others, it contains your token.
And so, the file can be simply downloaded locally.

A
alekssamos, 2021-08-17
@alekssamos

Well, in theory, get the file_id, then getfile and from it the URL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question