Reputation: 21
It is required to pass the variable "start" to the register_callback_query_handler function as the named parameter
Here's my code:
bot = telebot.TeleBot(BOT_TOKEN)
start = "start"
@bot.message_handler(commands=['start'])
def start(call):
menu = telebot.types.InlineKeyboardMarkup()
menu.add(telebot.types.InlineKeyboardButton(text="button", callback_data ='calculator'))
msg = bot.send_message(call.from_user.id, text="text", reply_markup=menu)
bot.register_callback_query_handler(calculator, func=lambda call: call.data == 'calculator', pass_bot=True, start=start)
def calculator(call, bot, **kwargs):
print(kwargs)
When I press the button, nothing happens. No errors are thrown. However, if I do not pass named parameters (start) to the register_callback_query_handler function, then the function "calculator" is called normally.
I have no idea whats the problem is.
Upvotes: 0
Views: 47
Reputation: 51
Passing the start
argument is NOT required for the register_callback_query_handler
function: see the documentation for async and regular versions.
The function probably treats the argument as a custom filter and filters out your button presses. If it works as you desire without the start
argument - don't pass it. If you wanted some other functionality please clarify the question.
Have a nice day!
Upvotes: 0