From f2e5ba1eefc5e9ab432d9ae1f8ebcf181e2913e0 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 2 Jan 2018 01:37:30 +0100 Subject: [PATCH] Fixed corner case on event match in case the named argument is the last token --- platypush/message/event/__init__.py | 5 +++-- platypush/message/event/assistant/__init__.py | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/platypush/message/event/__init__.py b/platypush/message/event/__init__.py index a1547989..29d7606c 100644 --- a/platypush/message/event/__init__.py +++ b/platypush/message/event/__init__.py @@ -135,8 +135,9 @@ class Event(Message): result.parsed_args[argname] += ' ' + event_token - if len(event_tokens) > 1 and len(condition_tokens) > 1 \ - and event_tokens[1] == condition_tokens[1]: + if len(condition_tokens) == 1 \ + or (len(event_tokens) > 1 and len(condition_tokens) > 1 \ + and event_tokens[1] == condition_tokens[1]): # Stop appending tokens to this argument, as the next # condition will be satisfied as well condition_tokens.pop(0) diff --git a/platypush/message/event/assistant/__init__.py b/platypush/message/event/assistant/__init__.py index 59d5367c..44cf6114 100644 --- a/platypush/message/event/assistant/__init__.py +++ b/platypush/message/event/assistant/__init__.py @@ -1,3 +1,4 @@ +import logging import re from platypush.context import get_backend @@ -8,7 +9,11 @@ class AssistantEvent(Event): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self._assistant = get_backend('assistant.google') + try: + self._assistant = get_backend('assistant.google') + except KeyError as e: + logging.warning('google.assistant backend not configured/initialized') + self._assistant = None class ConversationStartEvent(AssistantEvent):