Skip to content

Commit

Permalink
refactor: simplify cq messages
Browse files Browse the repository at this point in the history
avoid skills needing to check their skill_id, trigger the intended skill directly instead
  • Loading branch information
JarbasAl committed Jan 4, 2025
1 parent e0b933e commit 6787bc9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ovos_workshop/skills/ovos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ def __handle_common_query_ping(self, message):
if self._cq_handler:
# announce skill to common query pipeline
self.bus.emit(message.reply("ovos.common_query.pong",
{"skill_id": self.skill_id},
{"skill_id": self.skill_id, "is_classic_cq": False},
{"skill_id": self.skill_id}))

def __handle_query_action(self, message: Message):
Expand All @@ -1049,9 +1049,12 @@ def __handle_query_action(self, message: Message):
@param message: `question:action` message
"""
# backwards compat, for older common query pipeline versions
if not self._cq_callback or message.data["skill_id"] != self.skill_id:
# Not for this skill!
return

def __handle_skill_query_action(self, message: Message):
LOG.debug(f"common query callback for: {self.skill_id}")
lang = get_message_lang(message)
answer = message.data.get("answer") or message.data.get("callback_data", {}).get("answer")
Expand Down Expand Up @@ -1175,8 +1178,9 @@ def _register_system_event_handlers(self):

self.add_event('question:query', self.__handle_question_query, speak_errors=False)
self.add_event("ovos.common_query.ping", self.__handle_common_query_ping, speak_errors=False)
self.add_event('question:action', self.__handle_query_action,
handler_info='mycroft.skill.handler', is_intent=True, speak_errors=False)
self.add_event(f'question:action.{self.skill_id}', self.__handle_skill_query_action,
handler_info='mycroft.skill.handler', is_intent=True, speak_errors=False)
self.add_event('question:action', self.__handle_query_action, speak_errors=False)

# homescreen might load after this skill and miss the original events
self.add_event("homescreen.metadata.get", self.handle_homescreen_loaded, speak_errors=False)
Expand Down

0 comments on commit 6787bc9

Please sign in to comment.