Skip to content

Commit

Permalink
only activate converse if it returns True
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed May 3, 2024
1 parent ed7930a commit 7003048
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions ovos_workshop/skills/ovos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ def _register_system_event_handlers(self):
self.add_event("skill.converse.request", self._handle_converse_request,
speak_errors=False)
self.add_event(f"{self.skill_id}.converse.request", self._handle_converse_request,
speak_errors=False, activation=True)
speak_errors=False)
self.add_event(f"{self.skill_id}.activate", self.handle_activate,
speak_errors=False)
self.add_event(f"{self.skill_id}.deactivate", self.handle_deactivate,
Expand All @@ -1104,7 +1104,7 @@ def _register_system_event_handlers(self):
# TODO: deprecate 0.0.9
self.add_event("skill.converse.get_response", self.__handle_get_response, speak_errors=False)
self.add_event(f"{self.skill_id}.converse.get_response", self.__handle_get_response,
speak_errors=False, activation=True)
speak_errors=False)

def _send_public_api(self, message: Message):
"""
Expand Down Expand Up @@ -1225,6 +1225,9 @@ def _handle_converse_request(self, message: Message):
"lang": message.data['lang']}
kwargs = {k: v for k, v in kwargs.items() if k in params}
result = self.converse(**kwargs)
if result:
self.activate() # renew activation

self.bus.emit(message.reply('skill.converse.response',
{"skill_id": self.skill_id,
"result": result}))
Expand Down Expand Up @@ -1811,12 +1814,6 @@ def __get_response(self, session: Session):
Returns:
str: user's response or None on a timeout
"""
# during alpha 0.0.8 this check is here to handle the edge case missed by the decorator
# TODO - remove before 0.0.8 stable
from ovos_core.version import OVOS_VERSION_ALPHA
if OVOS_VERSION_ALPHA < 40: # introduced in 0.0.8a40
return self.__get_response_v1()

srcm = dig_for_message() or Message("", context={"source": "skills",
"skill_id": self.skill_id})
srcm.context["session"] = session.serialize()
Expand Down

0 comments on commit 7003048

Please sign in to comment.