Skip to content

Commit

Permalink
compat
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Sep 23, 2023
1 parent fb15069 commit 738324f
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions ovos_workshop/skills/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,10 @@ def __get_response_v1(self):
Returns:
str: user's response or None on a timeout
"""
srcm = dig_for_message() or Message("", context={"source": "skills",
"skill_id": self.skill_id})
self.bus.emit(srcm.forward("skill.converse.get_response.enable",
{"skill_id": self.skill_id}))

# TODO: Support `message` signature like default?
def converse(utterances, lang=None):
Expand Down Expand Up @@ -1041,9 +1045,12 @@ def converse(utterances, lang=None):
converse.finished = True
converse.response = self.__response # external override
self.converse = self.__original_converse
self.bus.emit(srcm.forward("skill.converse.get_response.disable",
{"skill_id": self.skill_id}))
return converse.response

# get response V2
@backwards_compat(classic_core=__get_response_v1, pre_008=__get_response_v1)
def __get_response(self):
"""Helper to get a response from the user
Expand All @@ -1056,30 +1063,8 @@ def __get_response(self):
srcm = dig_for_message() or Message("", context={"source": "skills",
"skill_id": self.skill_id})

# in ovos-core < 0.0.8 we reassign the converse method itself
is_old = False
try:
from mycroft.version import OVOS_VERSION_MAJOR, OVOS_VERSION_MINOR, OVOS_VERSION_BUILD, OVOS_VERSION_ALPHA
if OVOS_VERSION_MAJOR == 0 and OVOS_VERSION_MINOR == 0 and OVOS_VERSION_BUILD <= 8 and OVOS_VERSION_ALPHA < 5:
is_old = True
except ImportError:
try:
# classic mycroft-core / not ovos
from mycroft.version import CORE_VERSION_MAJOR
is_old = True
except ImportError:
# standalone usage without core
pass

self.bus.emit(srcm.forward("skill.converse.get_response.enable",
{"skill_id": self.skill_id}))

if is_old: # NOT SAFE for multiple users at same time
res = self.__get_response_v1()
self.bus.emit(srcm.forward("skill.converse.get_response.disable",
{"skill_id": self.skill_id}))
return res

self._activate()
utterances = []

Expand Down

0 comments on commit 738324f

Please sign in to comment.