Fixed corner case on event match in case the named argument is the last token

This commit is contained in:
Fabio Manganiello 2018-01-02 01:37:30 +01:00
parent 44a64b8cac
commit f2e5ba1eef
2 changed files with 9 additions and 3 deletions

View File

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

View File

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