Skip to content

Commit

Permalink
add return validated value (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
emphasize authored Jan 17, 2023
1 parent 175e1ed commit 75c712c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ovos_workshop/skills/ovos.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,14 +426,16 @@ def _real_wait_response(self, is_cancel, validator, on_fail, num_retries):
self._response = None
return
else:
if validator(response):
self._response = response
return

# catch user saying 'cancel'
if is_cancel(response):
self._response = None
return
validated = validator(response)
# returns the validated value or the response
# (backwards compat)
if validated is not False and validated is not None:
self._response = response if validated is True else validated
return

num_fails += 1
if 0 < num_retries < num_fails or self._response is not False:
Expand Down

0 comments on commit 75c712c

Please sign in to comment.