Exemplo n.º 1
0
def get_new_question(bot, update):
    """Новый вопрос."""
    question = get_question(read_quiz_file(QUESTIONS_FILE))
    chat_id = get_chat_id(update.message.chat.id, POSTFIX_TELEGRAM)
    message_text = switch_to_next_question(chat_id, question, r)
    update.message.reply_text(message_text)
    return SOLUTION_ATTEMPT
Exemplo n.º 2
0
def answer_the_question(bot, update):
    """Попытка ответить."""
    chat_id = get_chat_id(update.message.chat.id, POSTFIX_TELEGRAM)
    answer_of_user = update.message.text
    result = get_result(chat_id, answer_of_user, r)

    update.message.reply_text(result['message_text'])
    return NEW_QUESTION if result['fields']['is_correct'] else SOLUTION_ATTEMPT
Exemplo n.º 3
0
def get_the_correct_answer(event, vk_api):
    """Сдаться."""
    chat_id = get_chat_id(event.user_id, POSTFIX_VK)
    message_text = get_message_for_surrender(chat_id, r)
    return vk_api.messages.send(
        user_id=event.user_id,
        random_id=random.randint(1, 1000),
        keyboard=get_keyboard(),
        message=message_text,
    )
Exemplo n.º 4
0
def get_new_question(event, vk_api):
    """Новый вопрос."""
    question = get_question(read_quiz_file(QUESTIONS_FILE))
    chat_id = get_chat_id(event.user_id, POSTFIX_VK)
    message_text = switch_to_next_question(chat_id, question, r)
    return vk_api.messages.send(
        user_id=event.user_id,
        random_id=random.randint(1, 1000),
        keyboard=get_keyboard(),
        message=message_text,
    )
Exemplo n.º 5
0
def answer_the_question(event, vk_api):
    """Попытка ответа."""
    chat_id = get_chat_id(event.user_id, POSTFIX_VK)
    answer_of_user = event.text
    result = get_result(chat_id, answer_of_user, r)

    return vk_api.messages.send(
        user_id=event.user_id,
        random_id=random.randint(1, 1000),
        keyboard=get_keyboard(),
        message=result['message_text'],
    )
Exemplo n.º 6
0
def get_the_correct_answer(bot, update):
    """Сдаться."""
    chat_id = get_chat_id(update.message.chat.id, POSTFIX_TELEGRAM)
    message_text = get_message_for_surrender(chat_id, r)
    update.message.reply_text(message_text)
    return NEW_QUESTION