def user_quits(hermes, intent_message):
    print("User wants to quit")
    session_id = intent_message.session_id

    tt.remove_session_state(SessionsStates, session_id)
    hermes.publish_end_session(session_id,
                               tt.terminate_early(SessionsStates, session_id))
def user_does_not_know(hermes, intent_message):
    print("User does not know the answer")
    session_id = intent_message.session_id

    sentence, continues = tt.user_does_not_know(session_id, SessionsStates)

    if not continues:
        hermes.publish_end_session(session_id, sentence)
        tt.remove_session_state(SessionsStates, session_id)
        return

    hermes.publish_continue_session(session_id, sentence,
                                    INTENT_FILTER_GET_ANSWER)
def user_gives_answer(hermes, intent_message):
    print("User is giving an answer")

    answer = None
    session_id = intent_message.session_id
    session_state = SessionsStates.get(session_id)

    if intent_message.slots.answer:
        answer = intent_message.slots.answer.first().value

    session_state, sentence, continues = tt.check_user_answer(
        session_state, answer)

    if not continues:
        hermes.publish_end_session(session_id, sentence)
        tt.remove_session_state(SessionsStates, session_id)
        return

    hermes.publish_continue_session(session_id, sentence,
                                    INTENT_FILTER_GET_ANSWER)