Exemple #1
0
    def handle(self, handler_input):
        room = utils.get_slot_value(handler_input, 'room', False)
        device_id = handler_input.request_envelope.context.system.device.device_id

        if not room:
            room = utils.get_persistent_session_attribute(handler_input, 'DEVICE_'+device_id, False)
            if not room:
                speak_output = 'I need to set the room of the Chromecast that this Alexa device will control. Please say something like: set room to media room.'
                return (
                    handler_input.response_builder
                        .speak(speak_output)
                        .ask('Please set the Chromecasts room, by saying something like: set room to media room.')
                        .set_card(ui.SimpleCard(CARD_TITLE, speak_output))
                        .response
                )

        try:
            data = self.get_data(handler_input)
            self.publish_command_to_sns(room, self.get_action(), data)
            speak_output = self.get_response(data)
            return (
                handler_input.response_builder
                    .speak(speak_output)
                    .set_card(ui.SimpleCard(CARD_TITLE, speak_output))
                    .response
            )
        except SNSPublishError as error:
            logger.error('Sending command to the Chromecast failed', exc_info=error)
            speak_output = 'There was an error sending the command to the Chromecast'
            return (
                handler_input.response_builder
                    .speak(speak_output)
                    .set_card(ui.SimpleCard(CARD_TITLE, speak_output))
                    .response
            )
Exemple #2
0
def get_lesson_card(slide):
    card = None
    card_image = slide['card_image']
    title = slide['title']
    content = slide['voice']
    if card_image == "":
        card = ui.SimpleCard(title=title, content=content)
    elif 'https' not in card_image:
        card = ui.SimpleCard(title=title, content=card_image)
    else:
        card = ui.StandardCard(title=title, text=" ", image=ui.Image(
            small_image_url=card_image, large_image_url=card_image))
    return card
Exemple #3
0
def farm_intent_handler(handler_input):
    # type: (HandlerInput) -> Response
    attr = handler_input.attributes_manager.persistent_attributes
    cur_char = Character(attr['character'])

    duration = get_slot_value(handler_input, 'duration')
    if not duration.startswith('PT'):
        duration = 'PT24H'
    duration = YTDurationToSeconds(duration)
    _, loot_exp = cur_char.claim_loot(duration)

    speech_text = 'You got {} experience points. '.format(loot_exp)

    card_text = 'Farm time: ' + str(datetime.timedelta(
        seconds=duration)) + '\nExp obtained:{} \n'.format(loot_exp)

    if cur_char.messages:
        speech_text += 'You have unread messages. '
        card_text += 'You have unread messages. \n'

    attr['character'] = cur_char.to_dict()

    card = ui.SimpleCard(title='Farm Result (Debug Only)', content=card_text)

    handler_input.attributes_manager.save_persistent_attributes()
    handler_input.response_builder.speak(speech_text).set_card(
        card).set_should_end_session(False)
    return handler_input.response_builder.response
Exemple #4
0
def add_card(handler_input, response):
    """Add a card by translating ssml text to card content."""
    # type: (HandlerInput, Response) -> None
    if response.card:
        return
    response.card = ui.SimpleCard(title='Daily Dungeon',
                                  content=convert_speech_to_text(
                                      response.output_speech.ssml))
Exemple #5
0
 def handle(self, handler_input):
     speak_output = HELP_TEXT
     return (
         handler_input.response_builder
             .speak(speak_output)
             .card(ui.SimpleCard(CARD_TITLE, speak_output))
             .response
     )
 def handle(self, handler_input):
     speech_text = INQUIRY_TEXT
     
     handler_input.response_builder.speak(speech_text).set_card(
         ui.SimpleCard(
             INQUIRY_CARD_TITLE,
             INQUIRY_CARD_BODY
             )
         )
     return handler_input.response_builder.response
    def handle(self, handler_input):
        speech_title = SPEECH_TITLE
        speech_body = SPEECH_BODY

        handler_input.response_builder.speak(speech_title+speech_body).set_card(
            ui.SimpleCard(
                LAUNCH_CARD_TITLE,
                LAUNCH_CARD_BODY
                )
            )
        return handler_input.response_builder.response  
Exemple #8
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response

        print("HelpIntent")
        speech = "Hallo! Ich helfe dir dabei dein Haus zu steuern. Sag zum Beispiel: Welche Temperatur hat der Pool?"
        handler_input.response_builder.speak(speech)\
            .set_card(ui.SimpleCard("Ragglach 17", speech)) \
            .speak(speech)\
            .set_should_end_session(False)\
            .ask("Wie kann ich dir helfen?")
        return handler_input.response_builder.response
Exemple #9
0
 def handle(self, handler_input):
     device_id = handler_input.request_envelope.context.system.device.device_id
     room = utils.get_slot_value(
         handler_input,
         'room')  # Must have a value enforced by Alexa dialog
     utils.set_persistent_session_attribute(handler_input,
                                            'DEVICE_' + device_id, room)
     handler_input.attributes_manager.save_persistent_attributes()
     speak_output = 'Ok, this Alexa device will control the Chromecast in the %s. To control another room you can say something like: Alexa, play in the media room.' % room
     return (handler_input.response_builder.speak(speak_output).set_card(
         ui.SimpleCard(CARD_TITLE, speak_output)).response)
Exemple #10
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response

        print("LaunchRequest")
        response_builder = handler_input.response_builder
        speech = 'Hallo. Wie kann ich dir helfen?'
        response_builder\
            .set_card(ui.SimpleCard("Hallo!", "Wie kann ich dir helfen?"))\
            .set_should_end_session(False)\
            .speak(speech)\
            .ask("Sag zum Beispiel: Welche Temperatur hat der Pool?")
        return response_builder.response
Exemple #11
0
def check_skill_intent_handler(handler_input):
    # type: (HandlerInput) -> Response
    attr = handler_input.attributes_manager.persistent_attributes
    cur_char = Character(attr['character'])
    speech_text = 'You have {} equipped. '.format(
        cur_char.cur_skill) + "Your current skill set includes {}. ".format(
            ','.join(cur_char.skills))

    card = ui.SimpleCard(title='Character Skills',
                         content='Equipped: {} '.format(cur_char.cur_skill) +
                         'List:\n {}\n'.format('\n'.join(cur_char.skills)))

    handler_input.response_builder.speak(speech_text).set_card(
        card).set_should_end_session(False)
    return handler_input.response_builder.response
Exemple #12
0
def get_pool_temperature_response_data(handler_input):
    pool_temperature_raw_value = dynamodb.query_pool_temperature(time)
    response_builder = handler_input.response_builder

    if pool_temperature_raw_value is not None:
        pool_temperature = round(pool_temperature_raw_value)
        speech = f'Die Pool Temperatur beträgt {pool_temperature} Grad'
        card = ui.SimpleCard("Pool Temperatur", f'{pool_temperature}° C')
    else:
        speech = 'Es sind leider keine Sensordaten verfügbar'
        card = None

    return response_builder \
        .set_card(card) \
        .set_should_end_session(True) \
        .speak(speech)
	def handle(self, handler_input):
		if 'recipe' in handler_input.attributes_manager.session_attributes:
			recipe = handler_input.attributes_manager.session_attributes['recipe']
		else:
			recipe = None
		
		if recipe is not None:
			paramsList = {'q': recipe, 'app_id' : 'c1afdbf8', 'app_key' : '7f60627b97806fb6216e832af1204ff6'}
			
			data = RecipeHelper.getJsonFromAPI(apiStart, paramsList)
			
			recipeNumber = handler_input.attributes_manager.session_attributes['recipeNumber'] + 1

			handler_input.attributes_manager.session_attributes['recipeNumber'] = recipeNumber
			
			recipeFromHelper = RecipeHelper.getRecipe(data,recipeNumber)
			
			label = recipeFromHelper['label']
			source = recipeFromHelper['source']
			
			speech = "Here's a recipe for " + label + " from " + source
			speechText = ("Recipe: " + label + "\nFrom: " + source + 
				"\n\nIngredients: " + str(RecipeHelper.getIngredients(data, recipeNumber))[1:-1] + 
				"\n\n URL: " + recipeFromHelper['url'])
				
			handler_input.response_builder.speak(speech).set_card(
			ui.StandardCard(
				title=SKILL_NAME,
				text = speechText,
				image = ui.Image(
					small_image_url= recipeFromHelper['image'],
					large_image_url= recipeFromHelper['image']
				)
			)
		).set_should_end_session(False)
			
		else:
			speech = "Sorry, you haven't requested a recipe yet. Please request a recipe to continue"
			
			handler_input.response_builder.speak(speech).set_card(
				ui.SimpleCard(SKILL_NAME, speech)
			).set_should_end_session(False)
		return handler_input.response_builder.response
    def handle(self, handler_input):
        # type: (HandlerInput) -> Union[None, Response]
        reorder_meds = handler_input.attributes_manager.session_attributes[
            'reorder_meds']

        if reorder_meds:
            speech = "Order for your medicines "
            for med in reorder_meds:
                speech = speech + ", " + med
            speech = speech + " have been placed and will be arriving in 2 days! "

            card = ui.SimpleCard(
                title="Remedy Helper\nYou order has been confirmed!",
                content=speech + "\nOrder ID: GCYS8GW8677")

            speech = speech + "All the details have been sent to the card in your mobile alexa app!"

        else:
            speech = "I will place an order for your medicines shortly when they will be running out!"

        return (handler_input.response_builder.speak(speech).set_card(
            card).response)
Exemple #15
0
def launch_request_handler(handler_input):
    # type: (HandlerInput) -> Response
    """Handler for Skill Launch.
    """
    attr = handler_input.attributes_manager.persistent_attributes
    speech_text = ''

    if not attr:
        # create a new one
        attr['character'] = Character().to_dict()
        handler_input.attributes_manager.persistent_attributes = attr

        speech_text += (
            "Welcome to Daily Dungeon. "
            "Seems you don't have a character here, so I just created one for you. "
        )

        card_text = 'Character created successfully.'

    else:
        # load the char and claim trophy

        attr = handler_input.attributes_manager.persistent_attributes
        cur_char = Character(attr['character'])
        passing_time, loot_exp = cur_char.claim_loot()
        speech_text = 'Welcome to Daily Dungeon. '
        day = passing_time // (24 * 3600)
        hour = (passing_time % (24 * 3600)) // 3600
        minute = (passing_time % 3600) // 60
        if day > 1:
            speech_time = '{} days and {} hours'.format(day, hour)
        elif day == 1:
            speech_time = 'one day and {} hours'.format(hour)
        elif hour > 1:
            speech_time = '{} hours and {} minutes'.format(hour, minute)
        elif hour == 1:
            speech_time = 'one hour and {} minutes'.format(minute)
        else:
            speech_time = '{} minutes'.format(minute)

        speech_text += 'It\'s been ' + speech_time + ' since your last login. '

        card_text = 'Offline time: ' + str(
            datetime.timedelta(seconds=passing_time)
        ) + '\nExp obtained:{} \n'.format(loot_exp)

        if cur_char.messages:
            speech_text += 'You have unread messages. '
            card_text += 'You have unread messages. \n'

        attr['character'] = cur_char.to_dict()

    if 'in_maze' in attr and (attr['in_maze'] == 'IN'
                              or attr['in_maze'] == 'WAIT'):
        speech_text += 'You didnt finish your maze. Say resume the maze to go back to where you were. '
        card_text += 'You did not finish your maze. '
        attr['in_maze'] = 'WAIT'

    card = ui.SimpleCard(title='Welcome to Daily Dungeon', content=card_text)

    handler_input.attributes_manager.save_persistent_attributes()

    handler_input.response_builder.speak(speech_text).ask(
        'what would you like to do').set_card(card)

    return handler_input.response_builder.response
	def handle(self, handler_input):
		speech = "You can ask me to tell you a food recipe!"
		
		handler_input.response_builder.speak(speech).set_card(
			ui.SimpleCard(SKILL_NAME, speech)).set_should_end_session(False)
		return handler_input.response_builder.response
	def handle(self, handler_input):
		speech = "Goodbye"
		
		handler_input.response_builder.speak(speech).set_card(
			ui.SimpleCard(SKILL_NAME, speech)).set_should_end_session(True)
		return handler_input.response_builder.response