Esempio n. 1
0
def handle_response_digits(request):
 
    twilio_request = decompose(request)
    digits = twilio_request.digits

    twilio_response = Response()
 
    if digits == '2':
        # twilio_response.play('http://bit.ly/phaltsw')
        number = request.POST.get('From', '')
        twilio_response.say('A text message is on its way. Daaaaaaaaaaaaaaamn Daniel! Peace out yo')
        twilio_response.sms('Daaaaaaaaaaaaaaamn Daniel!', to=number)
 
    elif digits == '1':
        # twilio_response.play('http://bit.ly/phaltsw')
        # twilio_response.play('https://p.scdn.co/mp3-preview/934da7155ec15deb326635d69d050543ecbee2b4')
        # twilio_response.play('https://p.scdn.co/mp3-preview/934da7155ec15deb326635d69d050543ecbee2b4')
        twilio_response.play('https://demo.twilio.com/hellomonkey/monkey.mp3')
        
        # number = request.POST.get('From', '')
        # twilio_response.say('I got you bruh, sending you a text in a bit. PEACE!')
        # twilio_response.sms('You looking lovely today!', to=number)

    elif digits == "3":
        twilio_response.say("Record your monkey howl after the tone.")
        twilio_response.record(maxLength="5", action="/handle_recording")

    # If the caller pressed invalid input
    else:
        # twilio_response.say('Incorrect Number Pressed')
        return redirect("/gather")
 
    return twilio_response
Esempio n. 2
0
def handle_connect(request):
    recipient_number = request.POST.get('Digits', '')
    r = Response()
    if 'visitor' in request.session:
        try:
            recipient = Visitor.objects.get(access_code=recipient_number)
            request.session['recipient'] = {
                'id': recipient.id,
                'name': recipient.user.first_name,
                'number': recipient.access_code
            }
            # record a message
            r.say(
                'The person you tried to call is unavailable. Please leave a message')
            r.record(maxLength=30, action=reverse(
                'twiliorouter:handle_record')
            )
        except Visitor.DoesNotExist:
            request.session['welcome_message'] = 'Number not recognised'
            r.redirect(reverse('twiliorouter:connect'))
    else:
        request.session[
            'welcome_message'] = 'You need to enter your phone number'
        r.redirect(reverse('twiliorouter:welcome'))
    return r
Esempio n. 3
0
def handle_selection(request, slug):

    voicemailbox = get_object_or_404(VoicemailBox, slug=slug)

    chunk = voicemailbox.work.chunk_set.filter(number=request.POST.get('Digits'))

    if chunk.chunksubmission:


    r = Response()
    r.say(
        "Thank you. "
        "Please start reading, "
        "when you are done, you can hang up. "
    )
    
    action = reverse('handle-recording', kwargs={'slug': slug})

    r.record(action=action, timeout=20, maxLength=360, playBeep=True)


@csrf_exempt
def handle_recording(request, slug=None):

    voicemailbox = get_object_or_404(VoicemailBox, slug=slug)

    voicemailbox.collection.add_voicemail(
        audio_url=request.POST.get('RecordingUrl'),
        title='recorded in %s for %s' % (location, voicemailbox.target_location),
        location=voicemailbox.target_location,
    )
    return HttpResponse()
Esempio n. 4
0
def record(request,
           action=None,
           method='POST',
           timeout=None,
           finish_on_key=None,
           max_length=None,
           transcribe=None,
           transcribe_callback=None,
           play_beep=None):
    """See: http://www.twilio.com/docs/api/twiml/record.

    Usage::

        # urls.py
        urlpatterns = patterns('',
            # ...
            url(r'^record/$', 'django_twilio.views.record'),
            # ...
        )
    """
    r = Response()
    r.record(action=action,
             method=method,
             timeout=timeout,
             finishOnKey=finish_on_key,
             maxLength=max_length,
             transcribe=transcribe,
             transcribeCallback=transcribe_callback,
             playBeep=play_beep)
    return r
Esempio n. 5
0
def gather(request):

    logger.debug("Calling gather")
    d = request.GET.get("Digits")
    logger.debug("Digit Pressed= %s" % d)
    try:
        r = Response()
        if d == "1":
            r.say("You pressed 1")
            try:
                api = twitter.Api()
                statuses = api.GetUserTimeline("diarmuid")

                r.say(statuses[0].text)
            except Exception, ex:
                logger.debug(ex)
                r.say("Error getting twitter results")
            r.redirect(reverse("calls_hello"))
            return r
        elif d == "2":
            r.say("You pressed 2")
            r.say("Record your message after the tone.")

            r.record(maxLength="10", action=reverse("calls_record"))
            return r
Esempio n. 6
0
def echo(request):
    response = Response()
    if request.method == 'POST':
        response.play(request.POST['RecordingUrl'])
    else:
        response.say("Echo test", voice='woman')
        response.record()
    return response
Esempio n. 7
0
    def get(self, request):
        call, _ = ClientCall.objects.get_or_create(sid=request.GET['CallSid'])
        call.request_name()

        r = Response()

        r.say('''Please speak your name. This will help identify you when you arrive.''')
        r.record(action=reverse('phone:collect_name'), method='POST', maxLength=10, timeout=15)

        return r
Esempio n. 8
0
    def get(self, request):
        call, _ = ClientCall.objects.get_or_create(sid=request.GET['CallSid'])
        call.request_location()

        r = Response()
        
        r.say('''Where are you now? At the tone, please say an address or street intersection in the Saint Louis area. When you are finished, press Pound.''')
        r.record(action=reverse('phone:collect_location'), method='POST', maxLength=10, timeout=15)

        return r
Esempio n. 9
0
    def get(self, request):
        call, _ = ClientCall.objects.get_or_create(sid=request.GET["CallSid"])
        call.request_name()

        r = Response()

        r.say("""Please speak your name. This will help identify you when you arrive.""")
        r.record(action=reverse("phone:collect_name"), method="POST", maxLength=10, timeout=15)

        return r
Esempio n. 10
0
    def get(self, request):
        call, _ = ClientCall.objects.get_or_create(sid=request.GET["CallSid"])
        call.request_location()

        r = Response()

        r.say(
            """Where are you now? At the tone, please say an address or street intersection in the Saint Louis area. When you are finished, press Pound."""
        )
        r.record(action=reverse("phone:collect_location"), method="POST", maxLength=10, timeout=15)

        return r
Esempio n. 11
0
def handle_key():
    """Handle key press from a user."""
    digit_pressed = request.values.get('Digits', None)
    if digit_pressed == "1":
        resp = Response()
        resp.dial(phone_dave)
        resp.say("The call failed, or the party hung up. Goodbye.")
        return str(resp)
    elif digit_pressed == "2":
        resp = Response()
        resp.say("Record your monkey howl after the tone.")
        resp.record(maxLength="30", action="/hello-monkey/handle-recording/")
        return str(resp)
    elif digit_pressed == "3":
        return redirect("/hello-monkey/voice/")
    else:
        return redirect("/hello-monkey/")
Esempio n. 12
0
def record(request):
    response = Response()
    if request.method == 'POST':
        from_number = request.POST['From']
        try:
            user = User.objects.get(userprofile__phone_number=from_number)
        except User.DoesNotExist:
            user = User.objects.create(username=from_number)
            UserProfile.objects.create(user=user, phone_number=from_number)
        record = Recording.objects.create(
            url=request.POST['RecordingUrl'],
            duration=request.POST['RecordingDuration'],
            recorded_by=user,
        )
        response.say("Thankyou and goodbye", voice='female')
    else:
        response.record()
    return response
def record(request, action=None, method='POST', timeout=None,
           finish_on_key=None, max_length=None, transcribe=None,
           transcribe_callback=None, play_beep=None):
    """See: http://www.twilio.com/docs/api/twiml/record.

    Usage::

        # urls.py
        urlpatterns = patterns('',
            # ...
            url(r'^record/$', 'django_twilio.views.record'),
            # ...
        )
    """
    r = Response()
    r.record(action=action, method=method, timeout=timeout,
             finishOnKey=finish_on_key, maxLength=max_length,
             transcribe=transcribe, transcribeCallback=transcribe_callback,
             playBeep=play_beep)
    return r
Esempio n. 14
0
def answer(request, slug=None, location=None):

    r = Response()
    r.say(
        "Thanks for calling Fantastic Futures, "
        "You are about to record a wonderful sound, "
        "Once you are done, please hang up so your recording "
        "can start its journey to the website."
    )

    action = reverse(
        'handle-recording',
        kwargs={
            'slug': slug,
            'location': location
        }
    )

    r.record(action=action, timeout=240, maxLength=360, playBeep=True)

    return r