Skip to content

Commit

Permalink
add use the {skill} skill
Browse files Browse the repository at this point in the history
  • Loading branch information
gras64 committed Oct 6, 2019
1 parent a4e8fc7 commit 862e412
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
48 changes: 48 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
from mycroft.audio import wait_while_speaking
from mycroft.skills.core import FallbackSkill
from mycroft.util.log import LOG, getLogger
from mycroft.skills.msm_wrapper import build_msm_config, create_msm
from msm import (
MultipleSkillMatches,
SkillNotFound,
)
import random

_author__ = 'gras64'
Expand All @@ -14,6 +19,8 @@


class LearningSkill(FallbackSkill):
_msm = None #### From installer skill

def __init__(self):
super(LearningSkill, self).__init__("LearningSkill")
self.privacy = ""
Expand Down Expand Up @@ -175,6 +182,47 @@ def will_let_you_know_intent(self, message):
self.log.info("find Category: "+str(Category)+" and saved utt: "+str(saved_utt))
self.handle_interaction(message, Category, saved_utt)

@intent_file_handler('something_for_my_skill.intent')
def something_for_my_skill_intent(self, message):
skill = self.find_skill(message.data['skill'], False)
self.log.info("find Skill: "+str(skill))
if not self.saved_utt is None:
saved_utt = self.saved_utt


def find_skill(self, param, local): #### From installer skill
"""Find a skill, asking if multiple are found"""
try:
return self.msm.find_skill(param)
except MultipleSkillMatches as e:
skills = [i for i in e.skills if i.is_local == local]
or_word = self.translate('or')
if len(skills) >= 10:
self.speak_dialog('error.too.many.skills')
raise StopIteration
names = [self.clean_name(skill) for skill in skills]
if names:
response = self.get_response(
'choose.skill', num_retries=0,
data={'skills': ' '.join([
', '.join(names[:-1]), or_word, names[-1]
])},
)
if not response:
raise StopIteration
return self.msm.find_skill(response, skills=skills)
else:
raise SkillNotFound(param)

@property #### From installer skill
def msm(self):
if self._msm is None:
msm_config = build_msm_config(self.config_core)
self._msm = create_msm(msm_config)

return self._msm



def create_skill():
return LearningSkill()
3 changes: 3 additions & 0 deletions vocab/de-de/something_for_my_skill.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dafür solltest du das {skill} Skill verwenden
versuche es mal mit dem {skill} Skill
benutze dazu das {skill} Skill
3 changes: 3 additions & 0 deletions vocab/en-us/something_for_my_skill.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
for that you should use the {skill} skill
Try the {skill} skill
use the {skill} skill

0 comments on commit 862e412

Please sign in to comment.