A
A
Andrey Romashev2021-10-23 12:16:37
Python
Andrey Romashev, 2021-10-23 12:16:37

How to combine image and text in telegram bot mailing in python?

I am making my first bot)
When you enter a command and text separated by a space, a message and a picture are sent (advertising text with a poster)

bot.send_message(user[0], message.text[message.text.find(' '):], parse_mode='Markdown')
bot.send_photo(user[0], 'URL афиши')

Is there a way to merge these 2 posts?
And ideally, so that I can constantly not climb into the code and not change the URL, but add an image directly through the telegram itself?
Thanks in advance for your replies!!!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-10-23
@SoreMix

As an option - pass the caption to the sendphoto method

bot.send_photo(user[0], 'URL афиши', caption=message.text[message.text.find(' '):], parse_mode='Markdown')

https://core.telegram.org/bots/api#sendphoto

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question