T
T
Timyr2894372020-11-24 19:14:12
Python
Timyr289437, 2020-11-24 19:14:12

How can I make it so that the user can only click on the button once?

I have a problem how to make Inline buttons disappear altogether after clicking on them so that there is no such thing that the user clicks on them endlessly, thereby filling our database with garbage. here is the code

@bot.message_handler(content_types=['text'])
def habdler_text(call):
        global markup

        url_button = types.InlineKeyboardButton(text="Да", callback_data="aple_11")
        url_button_1 = types.InlineKeyboardButton(text="Нет", callback_data="aple_12")

        markup.add(url_button, url_button_1)
        bot.send_photo(call.from_user.id, image_aple, reply_markup=markup)
        bot.send_message(call.from_user.id,
                         'Вы уверены что хотите преобреси товар?')

@bot.callback_query_handler(func=lambda call: True)
def callback_worker(call):
    global markup
    if call.data == 'aple_11':
        markup = types.InlineKeyboardMarkup()
        url_button = types.InlineKeyboardButton(text="Да", callback_data="aple_11")
        markup.add(url_button)
        bot.send_photo(call.from_user.id, image_aple, reply_markup=markup)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-11-24
@Timyr289437

Just remove it
bot.edit_message_reply_markup()

@bot.callback_query_handler(func=lambda call: True)
def callback_worker(call):
    global markup
    bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id)
    if call.data == 'aple_11':
        markup = types.InlineKeyboardMarkup()
        url_button = types.InlineKeyboardButton(text="Да", callback_data="aple_11")
        markup.add(url_button)
        bot.send_photo(call.from_user.id, image_aple, reply_markup=markup)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question