Update button click handling in bot.py

sclero
Luca Lombardo 9 months ago
parent aa1bc6bd4a
commit f97307527b

@ -33,7 +33,7 @@ buttons = { # {name of the button: courses}
# Handle button click
@bot.callback_query_handler(func=lambda call: call.data == 'authenticate')
async def handle_authenticate(call):
await bot.answer_callback_query(call.id) # Answer the callback query
await bot.answer_callback_query(call.id, text="Autenticazione completata") # Avoids to leave the button pressed and sends a message on screen (not in chat)
if is_mathematician(call.from_user.id):
markup = types.InlineKeyboardMarkup()
@ -48,7 +48,7 @@ async def handle_authenticate(call):
# Handle button click
@bot.callback_query_handler(func=lambda call: call.data in buttons)
async def handle_buttons(call):
await bot.answer_callback_query(call.id)
await bot.answer_callback_query(call.id) # Avoids to leave the button pressed, no message is sent on screen
await bot.send_message(call.message.chat.id, buttons[call.data])
asyncio.run(bot.polling())
Loading…
Cancel
Save