diff --git a/jarvis/skills/__init__.py b/jarvis/skills/__init__.py index f738540..9e3800b 100644 --- a/jarvis/skills/__init__.py +++ b/jarvis/skills/__init__.py @@ -4,17 +4,23 @@ import types from jarvis import get_path_file from jarvis.skills import intent_manager -from jarvis.utils import languages_utils +from jarvis.utils import languages_utils, client_utils class Skill: - def __init__(self, name): + def __init__(self, name, data): self.name = name + self.client_ip = data['client_ip'] + self.client_port = data['client_port'] + path = self.__module__.split(".") self.category = path[2] self.skill_folder = path[3] + def speak(self, sentence): + client_utils.speak(sentence, self.client_ip, self.client_port) + def register(self): self.register_entities() self.register_regex() diff --git a/jarvis/skills/entertainement/jokes/__init__.py b/jarvis/skills/entertainement/jokes/__init__.py index 52df590..425b6e8 100644 --- a/jarvis/skills/entertainement/jokes/__init__.py +++ b/jarvis/skills/entertainement/jokes/__init__.py @@ -33,13 +33,13 @@ def speak_joke(): class JokesSkill(Skill, metaclass=SkillRegistering): - def __init__(self): - super().__init__("JokesSkill") + def __init__(self, data=dict): + super().__init__("JokesSkill", data) @intent_handler(IntentBuilder("JokingIntent").require("Joke")) def handle_joke(self, data): print(speak_joke()) -def create_skill(): - return JokesSkill() +def create_skill(data): + return JokesSkill(data) diff --git a/jarvis/skills/entertainement/spotify/__init__.py b/jarvis/skills/entertainement/spotify/__init__.py index 46ce159..8482883 100644 --- a/jarvis/skills/entertainement/spotify/__init__.py +++ b/jarvis/skills/entertainement/spotify/__init__.py @@ -4,8 +4,8 @@ from jarvis.skills.entertainement.spotify import spotify class SpotifySkill(Skill, metaclass=SkillRegistering): - def __init__(self): - super().__init__("SpotifySkill") + def __init__(self, data=dict): + super().__init__("SpotifySkill", data) @intent_file_handler("play_a_song.intent", "PlaySongWithSpotifyIntent") def handle_play_a_song(self, data): @@ -31,6 +31,7 @@ class SpotifySkill(Skill, metaclass=SkillRegistering): spotify.get_spotify().pause_playback() print("[INFO INTENT] - Paused music for Spotify") else: + self.speak("Rien n'est en cours de lecture sur Spotify...") # TODO: speak : nothing is playing on spotify pass @@ -55,5 +56,5 @@ class SpotifySkill(Skill, metaclass=SkillRegistering): print("Nothing is playing") -def create_skill(): - return SpotifySkill() +def create_skill(data): + return SpotifySkill(data) diff --git a/jarvis/skills/research/wikipedia/__init__.py b/jarvis/skills/research/wikipedia/__init__.py index fd1832c..ebc3b1c 100644 --- a/jarvis/skills/research/wikipedia/__init__.py +++ b/jarvis/skills/research/wikipedia/__init__.py @@ -4,8 +4,8 @@ from jarvis.skills.research.wikipedia import wikipedia class WikipediaSkill(Skill, metaclass=SkillRegistering): - def __init__(self): - super().__init__("WikipediaSkill") + def __init__(self, data=dict): + super().__init__("WikipediaSkill", data) @intent_file_handler("search.wikipedia.intent", "WikipediaQueryIntent") def handle_wikipedia_query_intent(self, data): @@ -17,5 +17,5 @@ class WikipediaSkill(Skill, metaclass=SkillRegistering): pass -def create_skill(): - return WikipediaSkill() +def create_skill(data): + return WikipediaSkill(data)