diff --git a/platypush/event/hook.py b/platypush/event/hook.py index 2886041e..ca2bb680 100644 --- a/platypush/event/hook.py +++ b/platypush/event/hook.py @@ -28,7 +28,7 @@ def parse(msg): class EventCondition(object): """ Event hook condition class """ - def __init__(self, type=Event.__class__, **kwargs): + def __init__(self, type=Event.__class__, priority=None, **kwargs): """ Rule constructor. Params: @@ -40,6 +40,7 @@ class EventCondition(object): self.type = type self.args = {} self.parsed_args = {} + self.priority = priority for (key, value) in kwargs.items(): # TODO So far we only allow simple value match. If value is a dict @@ -127,6 +128,7 @@ class EventHook(object): self.condition = EventCondition.build(condition or {}) self.actions = actions self.priority = priority or 0 + self.condition.priority = self.priority @classmethod @@ -141,6 +143,7 @@ class EventHook(object): condition = EventCondition.build(hook['if']) if 'if' in hook else None actions = [] priority = hook['priority'] if 'priority' in hook else None + condition.priority = priority if 'then' in hook: if isinstance(hook['then'], list): diff --git a/platypush/message/event/assistant/__init__.py b/platypush/message/event/assistant/__init__.py index 44cf6114..528e6803 100644 --- a/platypush/message/event/assistant/__init__.py +++ b/platypush/message/event/assistant/__init__.py @@ -33,7 +33,7 @@ class SpeechRecognizedEvent(AssistantEvent): def matches_condition(self, condition): result = super().matches_condition(condition) - if result.is_match and self._assistant: + if result.is_match and self._assistant and not condition.priority: self._assistant.stop_conversation() return result