From 16227704d7cfe196d9ef8f3a1b9147368d7773da Mon Sep 17 00:00:00 2001 From: Nils Uliczka Date: Mon, 24 Apr 2017 22:08:06 +0200 Subject: [PATCH] Fix telegram_polling no first_name or last_name (#7281) * Default to 'N/A' if sender has no first_name or last_name * Fixed as requested --- homeassistant/components/telegram_bot/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/telegram_bot/__init__.py b/homeassistant/components/telegram_bot/__init__.py index 1cd77491c51..e0adff19731 100644 --- a/homeassistant/components/telegram_bot/__init__.py +++ b/homeassistant/components/telegram_bot/__init__.py @@ -112,8 +112,8 @@ class BaseTelegramBotEntity: event = EVENT_TELEGRAM_COMMAND event_data = { ATTR_USER_ID: data['from']['id'], - ATTR_FROM_FIRST: data['from']['first_name'], - ATTR_FROM_LAST: data['from']['last_name']} + ATTR_FROM_FIRST: data['from'].get('first_name', 'N/A'), + ATTR_FROM_LAST: data['from'].get('last_name', 'N/A')} if data['text'][0] == '/': pieces = data['text'].split(' ')