예제 #1
0
def firstmeet_lunges(sessionStorage, req, res):
    try:
        my_num = [
            i for i in req['request']['nlu']["entities"]
            if i['type'] == "YANDEX.NUMBER"
        ]
        my_num = my_num[0]["value"]
        sessionStorage['user']['lunges'] = my_num

        sessionStorage['state'] = 'chooseType'
        sessionStorage['res'] = False
        sessionStorage, req, res = firstRequest.state(sessionStorage, req, res)

        print('firstmeet_lunges    ', 'MYNUM   ', my_num,
              sessionStorage['state'])
    except:
        if req['request']['original_utterance'].isalnum():
            sessionStorage['user']['lunges'] = 5

            sessionStorage['res'] = False
            sessionStorage['state'] = 'chooseType'
            sessionStorage, req, res = firstRequest.state(
                sessionStorage, req, res)
            # sessionStorage['res'] = False
        else:
            sessionStorage['repeat'] = True
            sessionStorage, req, res = buildRepeat.state(
                sessionStorage, req, res)
    return sessionStorage, req, res
예제 #2
0
def chooseType(sessionStorage, req, res):
    print('chooseType from HANDLERESPONCE')
    tokens = getNormal_tokens(req)
    print('tokens from getNormal_tokens: ', tokens)
    if 'тестирование' in tokens:
        pass
    elif 'статистика' in tokens:
        pass
    elif 'тренировка' in tokens:
        sessionStorage['state'] = 'get_training'
        sessionStorage['res'] = False
        sessionStorage, req, res = firstRequest.state(sessionStorage, req, res)
    else:
        sessionStorage['repeat'] = True
        sessionStorage, req, res = buildRepeat.state(sessionStorage, req, res)
    return sessionStorage, req, res
예제 #3
0
def buildRequest(req, res):
    global sessionStorage
    print('Im build your request' + '\n' + 'current STATE: ' +
          sessionStorage['state'] + '\n' + 'repeat: ' +
          str(sessionStorage['repeat']) + '\n' + 'res: ' +
          str(sessionStorage['res']))
    print('REQUEST: ' + req['request']['original_utterance'])
    if sessionStorage[
            'repeat']:  # если юзер сказал фигню и алиса не поняла, она повторяет
        sessionStorage, req, res = buildRepeat.state(sessionStorage, req, res)
    elif sessionStorage['res']:  # если юзер хоть как-то ответил
        sessionStorage, req, res = handleResponce.state(
            sessionStorage, req, res)
    else:  # если ответ еще не отправлен
        sessionStorage, req, res = firstRequest.state(sessionStorage, req, res)
    print(sessionStorage['res'], sessionStorage['state'])
    print()
    print()
예제 #4
0
def firstmeet_pushups(sessionStorage, req, res):
    try:
        my_num = getYaNUM(req)
        sessionStorage['user']['pushups'] = my_num
        sessionStorage['state'] = 'firstmeet_lunges'
        sessionStorage['res'] = False
        print(my_num, ' MYNUM')
    except:
        if req['request']['original_utterance'].isalnum():
            sessionStorage['user']['pushups'] = 5
            sessionStorage['state'] = 'firstmeet_lunges'
            sessionStorage['res'] = False
            print("sessionStorage['user']['pushups'] = ", 5)
        else:
            print("sessionStorage['repeat']  ", sessionStorage['repeat'])
            sessionStorage['repeat'] = True
            sessionStorage, req, res = buildRepeat.state(
                sessionStorage, req, res)
            return sessionStorage, req, res
    print('firstRequest.state(sessionStorage, req, res)  ',
          sessionStorage['state'])
    sessionStorage['res'] = False
    return firstRequest.state(sessionStorage, req, res)
예제 #5
0
def repeat(sessionStorage, req, res):
    print("sessionStorage['repeat']  ", sessionStorage['repeat'])
    sessionStorage['repeat'] = True
    sessionStorage, req, res = buildRepeat.state(sessionStorage, req, res)
    return sessionStorage, req, res