py-telegram-bot-apitelebot

Telegram bot is not registering for next step handler after clicking inline button in telebot


@bot.callback_query_handler(func=lambda call: call.data == "join_airdrop")
def handle_join_airdrop_callback(call):
    # Delete the button message
    bot.delete_message(call.message.chat.id, call.message.message_id)
    bot.register_next_step_handler(call.message, process_join)

def process_join(message):
    keyboard = InlineKeyboardMarkup()
    url_button = telebot.types.InlineKeyboardButton(text='Cancle', callback_data='cancle_airdrop')
    callback_button = telebot.types.InlineKeyboardButton(text='Joined', callback_data='joined_task')
    keyboard.add(url_button, callback_button)
    bot.send_message(message.chat.id,"To continue join the airdrop join the channel first.\nChannel", reply_markup=keyboard)
    bot.register_callback_query_handler(message, process_email)

Bot will ask for email after clicking on inline button. But bot is not work after handle_join_airdrop_callback(call). No error is throwing.


Solution

  • Instead of

    bot.register_callback_query_handler(message, process_email)
    

    at the end, try to use

    bot.register_callback_query_handler(call.message, process_email)