예제 #1
0
def sms(resp):
    resp = resp
    userMessage = getUserMessage()
    global firstTextMessage
    if userMessage[0] == ';':
        code = userMessage[1:]
        response = str(eval(code))
        resp.message(response)
    else:
        """Respond to incoming calls with a simple text message."""
        from_number = request.values.get('From', None)
        if not from_number in callers:
            callers[from_number] = {"answers":[], "questions" : deque(happ.getQuestions()), "submitted" : False}
    
    
        if callers[from_number]["questions"]:
            resp.message(callers[from_number]["questions"][0])
            callers[from_number]["questions"].popleft()
            if not firstTextMessage:
                callers[from_number]["answers"].append(userMessage)
            firstTextMessage = False
        elif not callers[from_number]["submitted"]:
            happ.submitForm(callers[from_number]["answers"])
            callers[from_number]["submitted"] = True
            currentState["survey"] = False
        if callers[from_number]["submitted"]:
            resp.message("Thank you for filling out our form!")

    return str(resp)
예제 #2
0
def webSMS(userMessage):
    oldValue = "You have submitted!"
    if session.get('unique') == False:
        session['unique'] = int(time.time())
    if not session['unique'] in mySessions:
        mySessions[session['unique']] =  {"questions" : deque(happ.getQuestions()), "submitted" : False}
    if mySessions[session['unique']]["questions"]:
        oldValue = mySessions[session['unique']]["questions"][0]
        mySessions[session['unique']]["questions"].popleft()
    elif not mySessions[session['unique']]["submitted"]:
        happ.submitForm(answers[session['unique']])
        # here is where further expansions can be done for after a form has been completed
        userMessages[session['unique']] = []
        mySessions[session['unique']]["submitted"] = True
    
    return oldValue