Added data in create_skill and skill init (for client ip, port and more)
This commit is contained in:
parent
59029f8398
commit
7dc92de383
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user