diff --git a/ovos_workshop/skills/ovos.py b/ovos_workshop/skills/ovos.py index ada4ed94..57648066 100644 --- a/ovos_workshop/skills/ovos.py +++ b/ovos_workshop/skills/ovos.py @@ -1205,13 +1205,19 @@ def register_intent_layer(self, layer_name: str, @param intent_list: List of intents associated with the intent layer """ for intent_file in intent_list: - if IntentBuilder is not None and isinstance(intent_file, IntentBuilder): - intent = intent_file.build() - name = intent.name - elif Intent is not None and isinstance(intent_file, Intent): - name = intent_file.name - else: + if isinstance(intent_file, str): name = f'{self.skill_id}:{intent_file}' + else: + if hasattr(intent_file, "build"): + try: + intent_file = intent_file.build() + except: + pass + try: + name = intent_file.name + except: + name = f'{self.skill_id}:{intent_file}' + self.intent_layers.update_layer(layer_name, [name]) def register_intent(self, intent_parser: Union[IntentBuilder, Intent, str], @@ -1224,8 +1230,9 @@ def register_intent(self, intent_parser: Union[IntentBuilder, Intent, str], file to parse utterance for the handler. handler (func): function to register with intent """ - if (isinstance(intent_parser, str) and - intent_parser.endswith('.intent')): + if isinstance(intent_parser, str): + if not intent_parser.endswith('.intent'): + raise ValueError return self.register_intent_file(intent_parser, handler) return self._register_adapt_intent(intent_parser, handler) @@ -1413,10 +1420,11 @@ def _register_adapt_intent(self, intent_parser: Intent object to parse utterance for the handler. handler (func): function to register with intent """ - if isinstance(intent_parser, IntentBuilder): - intent_parser = intent_parser.build() - elif not isinstance(intent_parser, Intent): - raise ValueError('"' + str(intent_parser) + '" is not an Intent') + if hasattr(intent_parser, "build"): + try: + intent_parser = intent_parser.build() + except: + pass # Default to the handler's function name if none given is_anonymous = not intent_parser.name