From bf197803f80e2e07d4fe54766f7e615a39232244 Mon Sep 17 00:00:00 2001 From: miro Date: Thu, 11 Jul 2024 19:50:24 +0100 Subject: [PATCH] fix/skillmanager_api compat with skillmanager.activate/deactivate/keep api for standalone skills closes https://github.com/OpenVoiceOS/OVOS-workshop/issues/204 skillmanager.list needs to be solved in ovos-core side --- ovos_workshop/skill_launcher.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ovos_workshop/skill_launcher.py b/ovos_workshop/skill_launcher.py index 9cf45db5..e67277b6 100644 --- a/ovos_workshop/skill_launcher.py +++ b/ovos_workshop/skill_launcher.py @@ -568,6 +568,25 @@ def __init__(self, skill_id: str, skill_directory: Optional[str] = None, self.skill_directory = skill_directory self.skill_loader = None + def do_unload(self, message): + """compat with legacy api from skill manager in core""" + if message.msg_type == 'skillmanager.keep': + if message.data['skill'] == self.skill_id: + return + elif message.data['skill'] != self.skill_id: + return + if self.skill_loader: + LOG.info("unloading skill") + self.skill_loader._unload() + + def do_load(self, message): + """compat with legacy api from skill manager in core""" + if message.data['skill'] != self.skill_id: + return + if self.skill_loader: + LOG.info("reloading skill") + self.skill_loader._load() + def _connect_to_core(self): """ Initialize messagebus connection and register event to load skill once @@ -589,6 +608,9 @@ def _connect_to_core(self): LOG.warning("Skills service not ready yet. Load on ready event.") self.bus.on("mycroft.ready", self.load_skill) + self.bus.on("skillmanager.activate", self.do_load) + self.bus.on("skillmanager.deactivate", self.do_unload) + self.bus.on("skillmanager.keep", self.do_unload) def load_skill(self, message: Optional[Message] = None): """