def PossessedBoardgames(self, hermes: Hermes, intent_message: IntentMessage): hermes.publish_end_session(intent_message.session_id, "") numberOfOwnedBoardgames = self.apiHandler.getNumberOfBoardgames() hermes.publish_start_session_notification( intent_message.site_id, "Vous possédez {} jeux".format(numberOfOwnedBoardgames), "")
def RepeatThrowCallback(self, hermes: Hermes, intent_message: IntentMessage): hermes.publish_end_session(intent_message.session_id, "") answer = self.GenerateAnswer(self.last_number, self.last_type) hermes.publish_start_session_notification(intent_message.site_id, answer, "")
def FavouriteBoardgame(self, hermes: Hermes, intent_message: IntentMessage): hermes.publish_end_session(intent_message.session_id, "") favouriteBoardgame = self.apiHandler.getMostPlayedBoardgame() hermes.publish_start_session_notification( intent_message.site_id, "Votre jeu préféré est {}".format(favouriteBoardgame), "")
def GiveLastThrowParamsCallback(self, hermes: Hermes, intent_message: IntentMessage): hermes.publish_end_session(intent_message.session_id, "") hermes.publish_start_session_notification( intent_message.site_id, "J'ai lancé {} dés {}".format(self.last_number, self.last_type), "")
def HeadsOrTailsCallback(self, hermes: Hermes, intent_message: IntentMessage): hermes.publish_end_session(intent_message.session_id, "") heads = random.randint(0, 1) answer = "Face" if heads == 1 else "Pile" hermes.publish_start_session_notification(intent_message.site_id, answer, "")
def ElicitNumPlayersCallback(self, hermes: Hermes, intent_message: IntentMessage): hermes.publish_end_session(intent_message.session_id, "") num_players = extractSlot(intent_message.slots, "numberOfPlayers") boardgames = self.apiHandler.getRandomBoardgames( num_players, int(intent_message.custom_data)) hermes.publish_start_session_notification( intent_message.site_id, self.GenerateBoardgamesAnswer(boardgames, num_players), "")
def test_start_session_notification_2(): h = Hermes(HOST) h.ffi = mock.MagicMock() with h: h.publish_start_session_notification(None, None, "custom_data", "yup!") start_session_notification_message = StartSessionMessage( SessionInitNotification("yup!"), "custom_data", None) h.ffi.dialogue.publish_start_session.assert_called_once_with( start_session_notification_message)
def intent_2_callback(hermes: Hermes, intent_message: IntentMessage): # terminate the session first if not continue hermes.publish_end_session(intent_message.session_id, "") # action code goes here... print('[Received] intent: {}'.format( intent_message.intent.intent_name)) # if need to speak the execution result by tts hermes.publish_start_session_notification(intent_message.site_id, "Action 2", "")
def test_start_session_notification_text_parameter_takes_precedence_over_session_initiation_text( ): h = Hermes(HOST) h.ffi = mock.MagicMock() with h: h.publish_start_session_notification(None, "test", "custom_data", "yup!") start_session_notification_message = StartSessionMessage( SessionInitNotification("yup!"), "custom_data", None) h.ffi.dialogue.publish_start_session.assert_called_once_with( start_session_notification_message)
def tell_joke(self, hermes: Hermes, intent_message: IntentMessage): # terminate the session first if not continue hermes.publish_end_session(intent_message.session_id, "") # action code goes here... print("[Received] intent: {}".format( intent_message.intent.intent_name)) # if need to speak the execution result by tts hermes.publish_start_session_notification(intent_message.site_id, self.joke_service.get_joke(), "")
def ThrowDiceCallback(self, hermes: Hermes, intent_message: IntentMessage): hermes.publish_end_session(intent_message.session_id, "") numberOfDicesSlot = extractSlot(intent_message.slots, "numberOfDices") numberOfDices = numberOfDicesSlot if numberOfDicesSlot != None else 1 self.last_number = numberOfDices diceTypeSlot = extractSlot(intent_message.slots, "diceType") diceType = diceTypeSlot if diceTypeSlot != None else 6 self.last_type = diceType answer = self.GenerateAnswer(numberOfDices, diceType) hermes.publish_start_session_notification(intent_message.site_id, answer, "")
def addition_callback(hermes: Hermes, intent_message: IntentMessage): # terminate the session first if not continue hermes.publish_end_session(intent_message.session_id, "") # action code goes here... print('[Received] intent: {}'.format( intent_message.intent.intent_name)) # if need to speak the execution result by tts hermes.publish_start_session_notification( intent_message.site_id, "Enfin, qulqu'un me donne du travail. Merci beaucoup!!!", "Calculatrice_APP")
def play_track(hermes: Hermes, intent_message: IntentMessage): # terminate the session first if not continue hermes.publish_end_session(intent_message.session_id, "") # action code goes here... logger.info("[Received] intent: {}".format( intent_message.intent.intent_name)) logger.info("[Received] slots: {} / {}".format( intent_message.slots.keys(), intent_message.slots.values())) searched_track = "obladi oblada" if len(intent_message.slots.musicTrack) > 0: searched_track = intent_message.slots.musicTrack.first().value track_id = DeezerApp.get_deezer_id(searched_track) # if need to speak the execution result by tts hermes.publish_start_session_notification(intent_message.site_id, str(track_id), "")
def PickRandomBoardgameCallback(self, hermes: Hermes, intent_message: IntentMessage): num_players_slot = extractSlot(intent_message.slots, "numberOfPlayers") num_boardgames_slot = extractSlot(intent_message.slots, "numberOfPropositions") numberOfBoardgames = num_boardgames_slot if num_boardgames_slot else self.numberOfBoardgames if not num_players_slot: return hermes.publish_continue_session( intent_message.session_id, required_slots_questions["num_players"], ["hjwk:ElicitNumPlayers"], custom_data=str(numberOfBoardgames)) hermes.publish_end_session(intent_message.session_id, "") boardgames = self.apiHandler.getRandomBoardgames( num_players_slot, numberOfBoardgames) hermes.publish_start_session_notification( intent_message.site_id, self.GenerateBoardgamesAnswer(boardgames, num_players_slot), "")