Exemple #1
0
def literal(alexa_request):
    text = get_text(alexa_request)
    logger.info('Typing \'{0}\''.format(text))
    try:
        g.roku.literal(text + ' ')
    except RokuError as e:
        logger.exception(e)
        return AlexaResponse('Sorry, trouble with the Roku.')
    else:
        return AlexaResponse('Ok.')
Exemple #2
0
def launch_channel(alexa_request):
    channel = alexa_request.slots['Channel'].get('value')
    logger.info('Launching {0}.'.format(channel))
    if g.roku.get_channel(channel) is None:
        response = AlexaResponse(
            'I couldn\'t find a channel named {0}.'.format(channel))
    else:
        g.roku.launch_channel(channel)
        response = AlexaResponse('Opening {0}.'.format(channel))
    return response
Exemple #3
0
def roku_search(alexa_request):
    text = get_text(alexa_request)
    logger.info('Launching Roku Search with keyword \'{0}\''.format(text))
    try:
        g.roku.search(text)
    except RokuError as e:
        logger.exception(e)
        return AlexaResponse('Sorry, trouble with the Roku.')
    else:
        return AlexaResponse('Ok.')
Exemple #4
0
def press_button_twice(alexa_request):
    button = alexa_request.slots['Button'].get('value')
    logger.info('Pressing {0} twice.'.format(button))
    try:
        g.roku.press_button(button, n=2)
    except RokuError as e:
        logger.exception(e)
        return AlexaResponse('Sorry, trouble with the Roku.')
    else:
        return AlexaResponse('Ok.')
Exemple #5
0
def press_button(alexa_request):
    button = alexa_request.slots['Button'].get('value')
    number = alexa_request.slots['NumberOfTimes'].get('value', '1')
    try:
        n_times = int(number)
    except ValueError:
        logger.warn('Got bad number, "{0}".'.format(number))
    logger.info('Pressing {0}, {1} times.'.format(button, n_times))
    try:
        g.roku.press_button(button, n=n_times)
    except RokuError as e:
        logger.exception(e)
        return AlexaResponse('Sorry, trouble with the Roku.')
    else:
        return AlexaResponse('Ok.')
Exemple #6
0
def points(alexa_request):
    points = alexa_request.slots['Points'].get('value') or 1
    action = alexa_request.slots['Action'].get('value').title().replace(
        " ", "")
    points = int(points)
    points = pointssystem.points(action, points)
    return AlexaResponse('Updating Sara\'s points to {0}'.format(points),
                         False)
Exemple #7
0
def intent_dispatcher(alexa_request):
    """Dispatch the incoming AlexaRequest to the appropriate intent handler."""
    intent_name = alexa_request.intent_name
    intent_handler = INTENT_HANDLERS.get(intent_name)
    if callable(intent_handler):
        return intent_handler(alexa_request)
    else:
        logger.error('Unhandled intent: {0}'.format(intent_name))
        return AlexaResponse('Sorry, I missed you there.', False)
Exemple #8
0
def ceccommand(alexa_request):
    command = alexa_request.slots['CECCommand'].get('value').title().replace(
        " ", "")
    command = command_lookup.get(command, command)
    number = alexa_request.slots['Number'].get(
        'value') or default_number_lookup.get(command, 1)
    number = min(int(number), 10)
    for i in range(int(number)):
        getattr(cecdevice, command)()
    return AlexaResponse('Done', True)
Exemple #9
0
def intent_dispatcher(alexa_request, intent_name=None):
    """Dispatch the incoming AlexaRequest to the appropriate intent handler."""
    if intent_name is None:
        intent_name = alexa_request.intent_name
    intent_handler = INTENT_HANDLERS.get(intent_name)
    if callable(intent_handler):
        logger.info('Dispatching to {0}...'.format(intent_name))
        return intent_handler(alexa_request)
    else:
        logger.error('Unhandled intent: {0}'.format(intent_name))
        return AlexaResponse('Sorry, that feature isn\'t ready yet.')
Exemple #10
0
def dispatch(alexa_request):
    """
    Dispatch the incoming, valid AlexaRequest to the appropriate request-type
    handler.
    """
    request_type = alexa_request.request_type
    request_type_handler = REQUEST_TYPE_HANDLERS.get(request_type)
    if callable(request_type_handler):
        return request_type_handler(alexa_request)
    else:
        logger.error('Unhandled request type: {0}'.format(request_type))
        return AlexaResponse('Sorry, that feature isn\'t ready yet.')
Exemple #11
0
def kodicommand(alexa_request):
    number = alexa_request.slots['Number'].get('value') or 1
    command = alexa_request.slots['Command'].get('value') or 'Info'
    command = command.title()
    number = min(int(number), 10)
    for i in range(int(number)):
        if command in dir(kodi):
            getattr(kodi, command)()
        mc = cast.media_controller
        if command.lower() in dir(mc):
            getattr(mc, command.lower())()
    return AlexaResponse('Next?', False)
Exemple #12
0
def press_ok(alexa_request):
    g.roku.press_ok()
    return AlexaResponse('Ok.')
Exemple #13
0
def play_or_pause(alexa_request):
    g.roku.play_pause()
    return AlexaResponse('Ok.')
Exemple #14
0
def stop(alexa_request):
    return AlexaResponse('Good Bye')
Exemple #15
0
def welcome(alexa_request):
    return AlexaResponse(
        'I am {0}?'.format(settings.SKILL_NAME,
                           settings.SKILL_INVOCATION_NAME), False)
Exemple #16
0
def getsarapoints(alexa_request):
    points = str(pointssystem.getpoints())
    return AlexaResponse('{0}\'s current points are {1}.'.format(
        settings.POINT_HOLDER_NAME, points))
Exemple #17
0
def switchdevice(alexa_request):
    device = alexa_request.slots['Device'].get('value').title().replace(
        " ", "")
    number = code_lookup[device]
    cecdevice.hdmi(number)
    return AlexaResponse('Done', False)
Exemple #18
0
def welcome(alexa_request):
    return AlexaResponse('Welcome to {0}. Try opening a Roku app by saying '
                         '"ask {1} to open Netflix."'.format(
                             settings.SKILL_NAME,
                             settings.SKILL_INVOCATION_NAME))
Exemple #19
0
def help(alexa_request):
    return AlexaResponse(
        '{0} can open Roku apps, play and pause, and send other button presses '
        'to your Roku.'.format(settings.SKILL_NAME))
Exemple #20
0
def session_ended(alexa_request):
    # No response is allowed for a SessionEndedRequest, but just in case Amazon
    # changes their mind about that...
    return AlexaResponse('Bye!')
Exemple #21
0
def help(alexa_request):
    return AlexaResponse('With {0}, you can control your media center '.format(
        settings.SKILL_NAME))