V
V
violpeople2021-06-27 17:22:42
Python
violpeople, 2021-06-27 17:22:42

How to make a message replace the past in the callback of an inline button?

async def ecuador(call:types.CallbackQuery):

    kb = InlineKeyboardMarkup(row_width=2)
    
    next = InlineKeyboardButton(text= 'Следующий',callback_data= 'next_1')
    previous = InlineKeyboardButton(text= 'Предыдущий',callback_data= 'previous_1')
    add = InlineKeyboardButton(text= 'Добавить в корзину',callback_data= 'add_1')

    kb.add(previous,next,add)

    back = InlineKeyboardButton(text= 'Назад',callback_data= 'back')
    kb.add(back)

    await bot.send_photo(
    chatId,
    photo = current_photo,
    caption='Название: '+ current_item +'\n\nЦена: '+ current_price + '\n\nId: '+ current_id,
    reply_markup=kb)

This code displays a picture with messages below it. So, I need that by clicking on the "Next" button, the message that is called by this button replaces the previous one

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2021-06-27
@violpeople

This is where you need to edit your previous post. For example:

bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.id, text='Новый текст')
bot.edit_message_media(chat_id=call.message.chat.id, message_id=call.message.id, media=types.InputMediaPhoto(open('file.jpg','r').read(), caption='Новая картинка'))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question