Skip to content

Commit

Permalink
deprecate old message types
Browse files Browse the repository at this point in the history
  • Loading branch information
emphasize committed Oct 12, 2023
1 parent 37eacab commit a098812
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions ovos_workshop/skills/ovos.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,8 +915,14 @@ def _register_system_event_handlers(self):
if self.stop_is_implemented:
self.add_event('mycroft.stop', self.__handle_stop,
speak_errors=False)
# TODO: deprectate 0.0.9
self.add_event("skill.converse.ping", self._handle_converse_ack,
speak_errors=False)
self.add_event(f"{self.skill_id}.converse.ping", self._handle_converse_ack,
speak_errors=False)
# TODO: deprecate 0.0.9
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)
self.add_event(f"{self.skill_id}.activate", self.handle_activate,
Expand All @@ -938,6 +944,8 @@ def _register_system_event_handlers(self):
self.add_event('mycroft.skills.settings.changed',
self.handle_settings_change, speak_errors=False)

# 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)

def _send_public_api(self, message: Message):
Expand Down Expand Up @@ -1019,6 +1027,11 @@ def _handle_converse_ack(self, message: Message):
`active` status.
@param message: `{self.skill_id}.converse.ping` Message
"""
if message.msg_type == "skill.converse.ping":
log_deprecation("Support for message type `skill.converse.ping` is deprecated, use `{skill_id}.converse.ping`", "0.0.9")
if message.data.get("skill_id") != self.skill_id:
return # not for us!

self.bus.emit(message.reply(
"skill.converse.pong",
data={"skill_id": self.skill_id,
Expand All @@ -1031,6 +1044,11 @@ def _handle_converse_request(self, message: Message):
with `converse`.
@param message: `{self.skill_id}.converse.request` Message
"""
if message.msg_type == "skill.converse.request":
log_deprecation("Support for message type `skill.converse.request` is deprecated, use `{skill_id}.converse.request`", "0.0.9")
if message.data.get("skill_id") != self.skill_id:
return # not for us!

try:
# converse can have multiple signatures
params = signature(self.converse).parameters
Expand Down Expand Up @@ -1543,6 +1561,15 @@ def converse(utterances, lang=None):
return ans

def __handle_get_response(self, message):
"""
Handle the response message to a previous get_response / speak call
sent from the intent service
"""
if message.msg_type == "skill.converse.get_response":
log_deprecation("Support for message type `skill.converse.get_response` is deprecated, use `{skill_id}.converse.get_response`", "0.0.9")
if message.data.get("skill_id") != self.skill_id:
return # not for us!

# validate session_id to ensure this isnt another
# user querying the skill at same time
sess2 = SessionManager.get(message)
Expand Down

0 comments on commit a098812

Please sign in to comment.