diff --git a/__init__.py b/__init__.py index 446ef9b..a751bc9 100644 --- a/__init__.py +++ b/__init__.py @@ -16,41 +16,37 @@ # along with Mycroft Core. If not, see . from adapt.intent import IntentBuilder - -from mycroft.skills.core import MycroftSkill -from mycroft.util.log import getLogger - -__author__ = 'eward' - -LOGGER = getLogger(__name__) - +from mycroft import MycroftSkill, intent_file_handler, intent_handler class HelloWorldSkill(MycroftSkill): def __init__(self): - super(HelloWorldSkill, self).__init__(name="HelloWorldSkill") + MycroftSkill.__init__(self) def initialize(self): - thank_you_intent = IntentBuilder("ThankYouIntent"). \ - require("ThankYouKeyword").build() - self.register_intent(thank_you_intent, self.handle_thank_you_intent) + # Perform any final setup needed for the skill here. + # This function is invoked after the skill is fully constructed and + # registered with the system. Intents will be registered and Skill + # settings will be available. + my_setting = self.settings.get('my_setting') - how_are_you_intent = IntentBuilder("HowAreYouIntent"). \ - require("HowAreYouKeyword").build() - self.register_intent(how_are_you_intent, - self.handle_how_are_you_intent) - - hello_world_intent = IntentBuilder("HelloWorldIntent"). \ - require("HelloWorldKeyword").build() - self.register_intent(hello_world_intent, - self.handle_hello_world_intent) - + @intent_handler(IntentBuilder('ThankYouIntent').require('ThankYouKeyword')) def handle_thank_you_intent(self, message): + # This is an Adapt intent handler, it is triggered by a keyword. self.speak_dialog("welcome") + @intent_file_handler('HowAreYou.intent') def handle_how_are_you_intent(self, message): + # This is a Padatious intent handler. + # It is triggered using a list of sample phrases. self.speak_dialog("how.are.you") + @intent_handler(IntentBuilder('HelloWorldIntent') + .require('HelloWorldKeyword')) def handle_hello_world_intent(self, message): + # Skills can log useful information. These will appear in the CLI and + # the skills.log file. + self.log.info("There are five types of log messages: " + "info, debug, warning, error, and exception.") self.speak_dialog("hello.world") def stop(self): diff --git a/vocab/en-us/HowAreYou.intent b/vocab/en-us/HowAreYou.intent new file mode 100644 index 0000000..143a400 --- /dev/null +++ b/vocab/en-us/HowAreYou.intent @@ -0,0 +1,3 @@ +how are you +how have you been +how has your day been diff --git a/vocab/en-us/HowAreYouKeyword.voc b/vocab/en-us/HowAreYouKeyword.voc deleted file mode 100644 index 143a400..0000000 --- a/vocab/en-us/HowAreYouKeyword.voc +++ /dev/null @@ -1,3 +0,0 @@ -how are you -how have you been -how has your day been