A
A
Alexey Mikhalev2020-07-25 17:43:25
Python
Alexey Mikhalev, 2020-07-25 17:43:25

Is it possible to change photos in telegram bot?

I am writing a bot in python using the PyTelegramBotApi library. According to the user's idea, first the picture is met, then the text with the buttons is a separate message. When you click on the buttons, the text changes and the buttons too. Is it possible to somehow make it so that when you click on the button, in addition to the text, the picture itself of the previous message changes?

@bot.message_handler(commands=['start'])
def welcome(message):

    markup = types.InlineKeyboardMarkup(row_width=1)
    item1 = types.InlineKeyboardButton("1", callback_data='one')
    item2 = types.InlineKeyboardButton("2", callback_data='two')
    item3 = types.InlineKeyboardButton("3", callback_data='three')
 
    markup.add(item1, item2, item3)
    bot.send_photo(message.chat.id, open('welcome.png', 'rb'))
    bot.send_message(message.chat.id, hello , reply_markup=markup, parse_mode='HTML')

Answer the question

In order to leave comments, you need to log in

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

You can use the edit_message_media method introduced in Telegram API 4.0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question