A
A
Alexey Mikhalev2020-07-25 15:23:16
Python
Alexey Mikhalev, 2020-07-25 15:23:16

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

2 answer(s)
M
Megum1n, 2020-07-25
@mikkhalev

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.

R
RainEnigma, 2021-01-09
@RainEnigma

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.
5ff8e9e7c4ea3550546105.jpeg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question