Add support for unnamed intents
This allows skill writers to ignore naming intents. Combined with a forthcoming change to Adapt that creates a default of None for IntentBuilder() This allows the current: @intent_handler(IntentBuilder("CurrentWeatherIntent").require( "Weather").optionally("Location").build()) def handle_current_weather(self, message): ... To become: @intent_handler(IntentBuilder().require("Weather").optionally("Location")) def handle_current_weather(self, message): ... Which will automatically name the Intent "handle_current_weather". Also dropped the log message in the default initialize() method since it is common to not override it now.pull/1280/head
parent
8a2595e85c
commit
553b95643e
|
@ -295,11 +295,11 @@ class MycroftSkill(object):
|
|||
|
||||
def initialize(self):
|
||||
"""
|
||||
Initialization function to be implemented by all Skills.
|
||||
Initialization function, run after fully constructed
|
||||
|
||||
Usually used to create intents rules and register them.
|
||||
"""
|
||||
LOG.debug("No initialize function implemented")
|
||||
pass
|
||||
|
||||
def get_intro_message(self):
|
||||
"""
|
||||
|
@ -459,6 +459,10 @@ class MycroftSkill(object):
|
|||
elif type(intent_parser) != Intent:
|
||||
raise ValueError('intent_parser is not an Intent')
|
||||
|
||||
if not intent_parser.name:
|
||||
# Default to the handler's function name if None or ""
|
||||
intent_parser.name = handler.__name__
|
||||
|
||||
name = intent_parser.name
|
||||
intent_parser.name = str(self.skill_id) + ':' + intent_parser.name
|
||||
self.emitter.emit(Message("register_intent", intent_parser.__dict__))
|
||||
|
|
Loading…
Reference in New Issue