diff --git a/ovos_core/intent_services/converse_service.py b/ovos_core/intent_services/converse_service.py index 915ddaa58a57..2872c78c0756 100644 --- a/ovos_core/intent_services/converse_service.py +++ b/ovos_core/intent_services/converse_service.py @@ -5,7 +5,7 @@ import ovos_core.intent_services from ovos_bus_client.message import Message -from ovos_bus_client.session import SessionManager +from ovos_bus_client.session import SessionManager, UtteranceState from ovos_utils import flatten_list from ovos_utils.log import LOG from ovos_utils.messagebus import get_message_lang @@ -23,6 +23,8 @@ def __init__(self, bus): self.bus.on('intent.service.skills.activate', self.handle_activate_skill_request) self.bus.on('active_skill_request', self.handle_activate_skill_request) # TODO backwards compat, deprecate self.bus.on('intent.service.active_skills.get', self.handle_get_active_skills) + self.bus.on("skill.converse.get_response.enable", self.handle_get_response_enable) + self.bus.on("skill.converse.get_response.disable", self.handle_get_response_disable) @property def config(self): @@ -256,6 +258,17 @@ def converse(self, utterances, skill_id, lang, message): """ session = SessionManager.get(message) session.lang = lang + + state = session.utterance_states.get(skill_id, UtteranceState.INTENT) + if state == UtteranceState.RESPONSE: + session.update_history(message) + converse_msg = message.reply("skill.converse.get_response", + {"skill_id": skill_id, + "utterances": utterances, + "lang": lang}) + self.bus.emit(converse_msg) + return True + if self._converse_allowed(skill_id): session.update_history(message) converse_msg = message.reply("skill.converse.request", @@ -293,6 +306,16 @@ def converse_with_skills(self, utterances, lang, message): return ovos_core.intent_services.IntentMatch('Converse', None, None, skill_id, utterances[0]) return None + def handle_get_response_enable(self, message): + skill_id = message.data["skill_id"] + session = SessionManager.get(message) + session.enable_response_mode(skill_id) + + def handle_get_response_disable(self, message): + skill_id = message.data["skill_id"] + session = SessionManager.get(message) + session.disable_response_mode(skill_id) + def handle_activate_skill_request(self, message): # TODO imperfect solution - only a skill can activate itself # someone can forge this message and emit it raw, but in OpenVoiceOS all