From c7d640a1d25d64a5375795e7a324505445c53b09 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 1 Jun 2024 11:34:29 +0200 Subject: [PATCH] `IntentRecognizedEvent` should stop the current assistant conversation when matched by a hook. --- platypush/message/event/assistant/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/platypush/message/event/assistant/__init__.py b/platypush/message/event/assistant/__init__.py index 309cb910b7..9190a0745a 100644 --- a/platypush/message/event/assistant/__init__.py +++ b/platypush/message/event/assistant/__init__.py @@ -147,7 +147,7 @@ class SpeechRecognizedEvent(AssistantEvent): """ result = super().matches_condition(condition) - if result.is_match and self.assistant and 'phrase' in condition.args: + if result.is_match and self.assistant and condition.args.get('phrase'): self.assistant.stop_conversation() return result @@ -242,6 +242,17 @@ class IntentRecognizedEvent(AssistantEvent): """ super().__init__(*args, intent=intent, slots=slots or {}, **kwargs) + def matches_condition(self, condition): + """ + Overrides matches condition, and stops the conversation to prevent the + default assistant response if the event matched some event hook condition. + """ + result = super().matches_condition(condition) + if result.is_match and self.assistant: + self.assistant.stop_conversation() + + return result + def _matches_argument( self, argname, condition_value, event_args, result: EventMatchResult ):