Pasar a siguiente pregunta si acertamos

This commit is contained in:
2022-04-23 10:25:09 +02:00
parent a8a86603f8
commit 2b706f511e

10
bot.py
View File

@ -123,6 +123,16 @@ def select_option_callback_handler(call):
question = find_question(test, q)
answer_reply = check_answer(question, answer)
bot.answer_callback_query(call.id, answer_reply)
if answer_reply:
question = find_question(test, eval(q+'+1'))
keyboard = generate_test_keyboard(question, test)
txt = "Test: {}\nPregunta: {}\n\n{}"
try:
bot.edit_message_media(types.InputMediaPhoto(question.get('img'), caption=txt.format(test, question['pregunta'], question['encabezado'])), cid, mid, reply_markup=keyboard)
bot.answer_callback_query(call.id)
except:
bot.answer_callback_query(call.id, "No se pudo cargar la pregunta")
@bot.callback_query_handler(func=lambda call: call.data.startswith('pregunta') and (call.data.endswith('+') or call.data.endswith('-')))
def question_pager_callback_handler(call):