IntentRecognizedEvent should stop the current assistant conversation when matched by a hook.

This commit is contained in:
Fabio Manganiello 2024-06-01 11:34:29 +02:00
parent 1cc2aaf5a4
commit c7d640a1d2

View file

@ -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
):