I’m aware I can use this
client.send_file(receiver, '/path/to/photo.jpg')
to send an image, but how can I attach a caption to the image?
I’m aware I can use this
client.send_file(receiver, '/path/to/photo.jpg')
to send an image, but how can I attach a caption to the image?
2
Answers
According to the documentation just pass the value of the caption with a keyword argument like so
client.send_file(chat, '/my/photos/me.jpg', caption="It's me!")
. You can read the documentation hereWhile this question on how to send an image with caption to Telegram using Telethon was already answered concisely by @matthew-barlowe, (which I used to come to my own solution, thank you), I felt that it would be helpful to include a more comprehensive example using Telethon v3’s new async API.
The code is documented and type hinted so it should provide it’s own explanation. In the interest of keeping the example brief, capturing of exceptions is excluded.