Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/activation+session #212

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading