From d9b5d5085d18ddb2b45888baab19bd224ef294c2 Mon Sep 17 00:00:00 2001 From: Daniel McKnight <34697904+NeonDaniel@users.noreply.github.com> Date: Tue, 25 Jun 2024 16:36:27 -0700 Subject: [PATCH 1/2] Fix bug in confirmation (#91) # Description Refactors `no.voc` to `cancel.voc` to properly override default vocab and match spoken instructions Add max retries to avoid infinite confirmation loop Display confirmation numbers on screen # Issues Closes #90 Closes #78 # Other Notes --------- Co-authored-by: Daniel McKnight --- __init__.py | 7 ++++++- locale/en-us/dialog/word_confirm.dialog | 1 + locale/en-us/vocab/{no.voc => cancel.voc} | 3 ++- locale/uk-ua/dialog/word_confirm.dialog | 1 + locale/uk-ua/vocab/{no.voc => cancel.voc} | 0 test/test_resources.yaml | 3 ++- test/test_skill.py | 10 +++++----- 7 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 locale/en-us/dialog/word_confirm.dialog rename locale/en-us/vocab/{no.voc => cancel.voc} (64%) create mode 100644 locale/uk-ua/dialog/word_confirm.dialog rename locale/uk-ua/vocab/{no.voc => cancel.voc} (100%) diff --git a/__init__.py b/__init__.py index 14fa3d0..cca7c3d 100644 --- a/__init__.py +++ b/__init__.py @@ -91,6 +91,8 @@ def handle_exit_shutdown_intent(self, message): :param message: message object associated with request """ confirm_number = str(randint(100, 999)) + self.gui.show_text(confirm_number, + self.resources.render_dialog("word_confirm")) validator = numeric_confirmation_validator(confirm_number) if message.data.get("exit"): action = SystemCommand.EXIT @@ -104,7 +106,10 @@ def handle_exit_shutdown_intent(self, message): response = self.get_response("ask_exit_shutdown", {"action": action.value, "number": confirm_number}, - validator, "action_not_confirmed") + validator, "action_not_confirmed", + num_retries=3) + LOG.debug(f"Got response: {response}") + self.gui.clear() if not response: self.speak_dialog("confirm_cancel", private=True) elif response: diff --git a/locale/en-us/dialog/word_confirm.dialog b/locale/en-us/dialog/word_confirm.dialog new file mode 100644 index 0000000..a0d892b --- /dev/null +++ b/locale/en-us/dialog/word_confirm.dialog @@ -0,0 +1 @@ +go ahead \ No newline at end of file diff --git a/locale/en-us/vocab/no.voc b/locale/en-us/vocab/cancel.voc similarity index 64% rename from locale/en-us/vocab/no.voc rename to locale/en-us/vocab/cancel.voc index 31f78c8..899a678 100644 --- a/locale/en-us/vocab/no.voc +++ b/locale/en-us/vocab/cancel.voc @@ -3,4 +3,5 @@ nope nah negative nevermind -never mind \ No newline at end of file +never mind +cancel \ No newline at end of file diff --git a/locale/uk-ua/dialog/word_confirm.dialog b/locale/uk-ua/dialog/word_confirm.dialog new file mode 100644 index 0000000..9fa69b6 --- /dev/null +++ b/locale/uk-ua/dialog/word_confirm.dialog @@ -0,0 +1 @@ +продовжуй \ No newline at end of file diff --git a/locale/uk-ua/vocab/no.voc b/locale/uk-ua/vocab/cancel.voc similarity index 100% rename from locale/uk-ua/vocab/no.voc rename to locale/uk-ua/vocab/cancel.voc diff --git a/test/test_resources.yaml b/test/test_resources.yaml index 7120b0f..9cb897a 100644 --- a/test/test_resources.yaml +++ b/test/test_resources.yaml @@ -13,7 +13,7 @@ vocab: - "enable" - "exit" - "listening" - - "no" + - "cancel" - "request" - "restart" - "shutdown" @@ -54,6 +54,7 @@ dialog: - confirm_ww_changing - ask_disable_ww - confirm_ww_disabled + - word_confirm # regex entities, not necessarily filenames regex: diff --git a/test/test_skill.py b/test/test_skill.py index eed6ab6..c442894 100644 --- a/test/test_skill.py +++ b/test/test_skill.py @@ -74,7 +74,7 @@ def test_handle_exit_shutdown_intent(self): # Exit Confirmed message = Message("valid_intent", {"exit": "exit"}) - def get_response(*args): + def get_response(*args, **kwargs): self.assertEqual(args[0], "ask_exit_shutdown") dialog = args[0] dialog_data = args[1] @@ -102,7 +102,7 @@ def get_response(*args): # Shutdown confirmed message = Message("valid_intent", {"shutdown": "shut down"}) - def get_response(*args): + def get_response(*args, **kwargs): self.assertEqual(args[0], "ask_exit_shutdown") dialog = args[0] dialog_data = args[1] @@ -130,7 +130,7 @@ def get_response(*args): # Restart Confirmed message = Message("valid_intent", {"restart": "reboot"}) - def get_response(*args): + def get_response(*args, **kwargs): self.assertEqual(args[0], "ask_exit_shutdown") dialog = args[0] dialog_data = args[1] @@ -159,7 +159,7 @@ def get_response(*args): self.skill._do_exit_shutdown.reset_mock() message = Message("valid_intent", {"exit": "exit"}) - def get_response(*args): + def get_response(*args, **kwargs): self.assertEqual(args[0], "ask_exit_shutdown") dialog = args[0] dialog_data = args[1] @@ -186,7 +186,7 @@ def get_response(*args): # Exit no response message = Message("valid_intent", {"exit": "exit"}) - def get_response(*args): + def get_response(*args, **kwargs): self.assertEqual(args[0], "ask_exit_shutdown") dialog = args[0] dialog_data = args[1] From 6820a0fea82779a1cd215574cd285557b6fa6306 Mon Sep 17 00:00:00 2001 From: NeonDaniel Date: Tue, 25 Jun 2024 23:36:41 +0000 Subject: [PATCH 2/2] Increment Version to 1.1.1a2 --- version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.py b/version.py index 0e8f56c..303d573 100644 --- a/version.py +++ b/version.py @@ -26,4 +26,4 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -__version__ = "1.1.1a1" +__version__ = "1.1.1a2"