From fb15069fdba06b19ab0342dd5a518f768dcc104a Mon Sep 17 00:00:00 2001 From: JarbasAi Date: Thu, 20 Apr 2023 22:40:32 +0100 Subject: [PATCH] message.forward --- ovos_workshop/skills/base.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/ovos_workshop/skills/base.py b/ovos_workshop/skills/base.py index 8dc269dd..a357aefb 100644 --- a/ovos_workshop/skills/base.py +++ b/ovos_workshop/skills/base.py @@ -1053,6 +1053,8 @@ def __get_response(self): Returns: str: user's response or None on a timeout """ + srcm = dig_for_message() or Message("", context={"source": "skills", + "skill_id": self.skill_id}) # in ovos-core < 0.0.8 we reassign the converse method itself is_old = False @@ -1069,24 +1071,22 @@ def __get_response(self): # standalone usage without core pass - self.bus.emit(Message("skill.converse.get_response.enable", - {"skill_id": self.skill_id})) + self.bus.emit(srcm.forward("skill.converse.get_response.enable", + {"skill_id": self.skill_id})) if is_old: # NOT SAFE for multiple users at same time res = self.__get_response_v1() - self.bus.emit(Message("skill.converse.get_response.disable", - {"skill_id": self.skill_id})) + self.bus.emit(srcm.forward("skill.converse.get_response.disable", + {"skill_id": self.skill_id})) return res self._activate() utterances = [] - lang = self.lang # unused, but we get this info together with utterance if needed - # user could switch lang midway, maybe ignore response in this case (?) sess = SessionManager.get() def _handle_get_response(message): - nonlocal utterances, lang + nonlocal utterances skill_id = message.data["skill_id"] if skill_id != self.skill_id: @@ -1099,7 +1099,6 @@ def _handle_get_response(message): return # not for us! utterances = message.data["utterances"] - lang = message.data["lang"] # received get_response self.bus.on("skill.converse.get_response", _handle_get_response) @@ -1118,8 +1117,8 @@ def _handle_get_response(message): utterances = [self.__response] # external override self.bus.remove("skill.converse.get_response", _handle_get_response) - self.bus.emit(Message("skill.converse.get_response.disable", - {"skill_id": self.skill_id})) + self.bus.emit(srcm.forward("skill.converse.get_response.disable", + {"skill_id": self.skill_id})) if utterances: return utterances[0]