Skip to content

Commit

Permalink
fix/activation+session
Browse files Browse the repository at this point in the history
do not activate/deactivate the skill if there was no change to Session (avoid bus spam)

update session data so the skill already sees the skill as active, otherwise since it was async the Session was outdated in the intent handler
  • Loading branch information
JarbasAl committed Jun 20, 2024
1 parent 824619d commit b42f126
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions ovos_workshop/skills/ovos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1548,17 +1548,29 @@ def _on_event_start(self, message: Message, handler_info: str,
"""
Indicate that the skill handler is starting.
activation (bool, optional): activate skill if True, deactivate if False, do nothing if None
activation (bool, optional): activate skill if True,
deactivate if False,
do nothing if None
"""
if handler_info:
# Indicate that the skill handler is starting if requested
msg_type = handler_info + '.start'
message.context["skill_id"] = self.skill_id
self.bus.emit(message.forward(msg_type, skill_data))
if activation is True:

# in latest versions of ovos-core the skill is
# activated by the intent service and this step is no longer needed
sess = SessionManager.get(message)
is_active = any([s[0] == self.skill_id
for s in sess.active_skills])
if not is_active and activation is True:
self.activate()
elif activation is False:
sess.activate_skill(self.skill_id)
message.context["session"] = sess.serialize()
elif is_active and activation is False:
self.deactivate()
sess.deactivate_skill(self.skill_id)
message.context["session"] = sess.serialize()

def _on_event_end(self, message: Message, handler_info: str,
skill_data: dict, is_intent: bool = False):
Expand Down

0 comments on commit b42f126

Please sign in to comment.