Skip to content

Commit

Permalink
Deregister any entities when a skill is detached. Fixes #394 (#395)
Browse files Browse the repository at this point in the history
* Deregister any entities when a skill is detached. Fixes #394

Signed-off-by: David Greaves <[email protected]>

* Update requirements.txt

* Update requirements.txt

---------

Signed-off-by: David Greaves <[email protected]>
Co-authored-by: JarbasAI <[email protected]>
  • Loading branch information
lbt and JarbasAl authored Jan 8, 2024
1 parent 228835b commit d899113
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ovos_core/intent_services/padacioso_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ def handle_detach_intent(self, message):
"""
self.__detach_intent(message.data.get('intent_name'))

def __detach_entity(self, name, lang):
""" Remove an entity.
Args:
entity name
entity lang
"""
if lang in self.containers:
self.containers[lang].remove_entity(name)

def handle_detach_skill(self, message):
"""Messagebus handler for detaching all intents for skill.
Expand All @@ -150,6 +160,10 @@ def handle_detach_skill(self, message):
remove_list = [i for i in self.registered_intents if skill_id in i]
for i in remove_list:
self.__detach_intent(i)
skill_id_colon = skill_id + ":"
for en in self.registered_entities:
if en["name"].startswith(skill_id_colon):
self.__detach_entity(en["name"], en["lang"])

def _register_object(self, message, object_name, register_func):
"""Generic method for registering a padacioso object.
Expand Down

0 comments on commit d899113

Please sign in to comment.