Esempio n. 1
0
def lookup():
    """
    Handle a voice mdb lookup
    """

    myMDB = getMDB()
    resp = twilio.twiml.Response()
    keypresses = request.values.get('Digits', None)
    if keypresses is not None:
        # turn the numberic keypresses into a set of possible strings they want to search for
        combos = list("".join(y) for y in product(*[keys[x] for x in keypresses])) or [""]
        matchSet = set()
        for c in combos:
            matches = myMDB.lookup(c)
            for match in matches:
                matchSet.add(match)
        matching = list(matchSet)
        matching.sort(reverse=True)
        
        resp.say("There are %s matching entries." % len(matching) or 0)
        if len(matching) == 1:
            sayMsg(resp, matching[0], "the only")
        elif len(matching) == 2:
            sayMsg(resp, matching[1], "the first")
            sayMsg(resp, matching[0], "the last")
        elif len(matching) > 2:
            sayMsg(resp, matching[0], "the last")
            sayMsg(resp, random.choice(matching[1:]), "a random")
            sayMsg(resp, random.choice(matching[1:]), "another random")
    resp.pause(length=1)
    with resp.gather(numDigits=5, finishOnKey="#", timeout=15, method="GET", action="/lookup") as g:
        g.say("To search the database please enter up to 5 letters using your digital keypad. Press pound when complete.")
    resp.redirect("/lookup?Digits=", method="GET")
    return str(resp)
Esempio n. 2
0
def welcome():
    request_check()
    resp = twilio.twiml.Response()

    with resp.gather(finishOnKey="#", action="/handle-number",
                     method="POST") as g:
        message = "Welcome to PhoneBuzz! Please enter any number, followed by the pound sign, to play!"
        g.say(message, voice="woman")

    return str(resp)
Esempio n. 3
0
def hello_monkey():
    # from_number = request.args.get('From', None)
    call_sid = request.args.get('CallSid', None)
    
    print "Service: " + str(call_sid)
 
    resp = twilio.twiml.Response()
    # Greet the caller by name
    resp.say("Hello shouter")
    # resp.play("http://demo.twilio.com/hellomonkey/monkey.mp3")
 
    # Gather digits.
    with resp.gather(numDigits=1, action="/twilio/handle-key", method="GET") as g:
        g.say(""" 
                 Press 1 to record your shout.
                 Press any other key to start over.""")
 
    return str(resp)
Esempio n. 4
0
def response():
    resp = VoiceResponse()

    signature = request.headers.get('X-Twilio-Signature', '')
    print(signature)
    if not signature:
        resp.say("This is not Twilio")
        return str(resp)

    id = request.args.get("id")
    if id:
        with resp.gather(finishOnKey="#",
                         action="/handle-number?id=" + str(id),
                         method="POST") as g:
            message = "Welcome to PhoneBuzz! Please enter any number, followed by the pound sign, to play!"
            g.say(message, voice="woman")
    else:
        with resp.gather(finishOnKey="#",
                         action="/handle-number",
                         method="POST") as g:
            message = "Welcome to PhoneBuzz! Please enter any number, followed by the pound sign, to play!"
            g.say(message, voice="woman")

    return str(resp)
Esempio n. 5
0
def generate_presets_selection_twiml(r):
	''' Menu to let user select a beat, or go back to main menu '''
	with r.gather(numDigits=1, finishOnKey ="", action=url_for('.twilio_preset_selection_handler')) as g:
		g.say('Enter the beat you would like to rap to, or enter star to return to main menu.')
	return r.toxml()
Esempio n. 6
0
def generate_presets_menu_twiml(r):
	''' Presets menu for playing presets '''
	with r.gather(numDigits=1, finishOnKey ="",action=url_for('.twilio_preset_handler')) as g:
		g.say('Use the digits 1-9 to preview a beat.  Use 0 to continue and select a beat')

	return r.toxml()
Esempio n. 7
0
def generate_intro_twiml(r):
	with r.gather(numDigits=1, action=url_for('.intro_redirect')) as g:
		g.say('To hear presets press 1.  To make your own beats press 2.')
	return r.toxml()
Esempio n. 8
0
def generate_beat_approval_twiml(r, digits):
	r.play(create_beat(digits), loop=4)
	print digits
	with r.gather(numDigits=1, finishOnKey='', action=url_for('.twilio_beat_approval_handler', digits = digits)) as g:
		g.say(" To hear the beat again press 1. To make a new beat press 2. To continue to rapping press 0. To return to the main menu press star")
	return r.toxml()
Esempio n. 9
0
def generate_beat_creation_twiml(r):
	with r.gather(numDigits=8, finishOnKey='*', action=url_for('.twilio_beat_creation_handler')) as g:
		g.say("Input 8 digits to make the beat. Press 1 for hihat. 2 for snare. 3 for bass. 4 for hihat and snare. 5 for hihat and bass. 6 for bass and snare. 7 for hihat, bass, and snare. 8 for rest. Press star to go back to the main menu")
	return r.toxml()
Esempio n. 10
0
def generate_beat_preview_twiml(r):
	with r.gather(numDigits=1, finishOnKey='', action=url_for('.twilio_beat_preview_handler')) as g:
		g.say("Press the 1-8 to try out the different beat sounds. Press 0 when you're done. Press 1 for hihat. 2 for snare. 3 for bass. 4 for hihat and snare. 5 for hihat and bass. 6 for bass and snare. 7 for hihat, bass, and snare. 8 for rest. Press star to go back to the main menu")
	return r.toxml()