Answer the question
In order to leave comments, you need to log in
How to put a picture in bot.edit_message_text?
I am writing a telegram bot in python, with the PyTelegramBotApi library. When you click on the button, the message is edited and new buttons are added, but it is necessary that, in addition to the buttons, a picture is added. What are the ways to do this? Thanks for the help)
if call.data == 'info':
markup = types.InlineKeyboardMarkup(row_width=1)
item1 = types.InlineKeyboardButton("Назад", callback_data='back')
markup.add(item1)
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Какой-то текст", parse_mode='html', reply_markup=markup)
Answer the question
In order to leave comments, you need to log in
Changing the message type from text to photo will not work. In addition, in the Telegram API editMessageText and editMessageCaption are different methods https://core.telegram.org/bots/api#editmessagetext
Alternatively, you can send a new message with a picture.
You can also add the URL of the image to the text, and a preview of the image will be displayed, but how to get rid of the address is a mystery to me (I know that this is possible in aiogram). If anyone knows how please tell me.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question