Ejemplo n.º 1
0
def select_from_payphones(payphones):
    res = Response()
    action = params_and_url_for(
        'select_payphone_suburb',
        {
            'phones': json.dumps([
                format_lat_lon(payphone['properties'])
                for payphone in payphones
            ])
        }
    )

    with res.gather(numDigits='1', action=action) as g:
        g.say(
            '{} payphones were found. Please select your current suburb'
            'from the following'
            .format(len(payphones))
        )

        for idx, payphone in enumerate(payphones, 1):
            g.say('Press {} for {}'.format(
                idx,
                payphone['properties']['SSC_NAME']
            ))

    return res
Ejemplo n.º 2
0
def location():
    res = Response()
    with res.gather(numDigits=ID_NUM_DIGITS,
                    action=url_for('id_recieved')) as g:
        g.say(
            'Please enter the {} digit payphone identification number'.format(
                humanize.apnumber(ID_NUM_DIGITS)))
    return res
Ejemplo n.º 3
0
def location():
    res = Response()
    with res.gather(numDigits=str(ID_NUM_DIGITS),
                    action=url_for('id_recieved')) as g:
        g.say(
            'Please enter the {} digit payphone identification number'
            .format(humanize.apnumber(ID_NUM_DIGITS)),
            language='en-AU'
        )
    return res
Ejemplo n.º 4
0
def select_from_payphones(payphones):
    res = Response()
    action = params_and_url_for('select_payphone_suburb', {
        'phones':
        json.dumps([format_lat_lon(payphone) for payphone in payphones])
    })

    with res.gather(numDigits=1, action=action) as g:
        g.say('{} payphones were found. Please select your current suburb'
              'from the following'.format(len(payphones)))

        for idx, payphone in enumerate(payphones, 1):
            g.say('Press {} for {}'.format(idx, payphone['SSC_NAME']))

    return res
Ejemplo n.º 5
0
def payphone_found_response(digits, from_):
    res = Response()
    if digits not in {'1', '2'}:
        return res.say('Invalid input').hangup()

    mode = {'1': 'walking', '2': 'transit'}[digits]

    to = ADDRESSTO
    departure_time = datetime.now()

    logging.info('Travelling from %s to "%s" at %s using %s', from_, to,
                 departure_time, mode)

    directions_result = gmaps.directions(from_,
                                         to,
                                         mode=mode,
                                         departure_time=departure_time)
    if not directions_result:
        return res.say('No routes could be found').hangup()

    directions_result = directions_result[0]

    for leg in directions_result['legs']:
        for step in leg['steps']:
            if step['travel_mode'] == 'TRANSIT':
                instruction = parse_transit_step(step)
            else:
                instruction = parse_instruction(step['html_instructions'])

            res.say(instruction)
            res.pause(length=1)

    res.say("End of instructions")

    action = params_and_url_for('possibly_repeat', {
        'latlon': from_,
        'Digits': digits
    })
    with res.gather(numDigits=1, action=action) as gat:
        gat.say('Enter 1 to repeat instructions, or hang up.', )

    return res