From 5ad209c6fd8adb1cf4df640e361dcb7481753b25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio?= Date: Fri, 3 Jan 2020 15:22:14 +0200 Subject: [PATCH] Handle telegram event commands with args (#30254) * Handle telegram event commands with args * Parse message regargless of command * Lint * Use multiple assignment --- homeassistant/components/telegram_bot/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/telegram_bot/__init__.py b/homeassistant/components/telegram_bot/__init__.py index fc37121f3f9..9b56201f8c7 100644 --- a/homeassistant/components/telegram_bot/__init__.py +++ b/homeassistant/components/telegram_bot/__init__.py @@ -782,7 +782,13 @@ class BaseTelegramBotEntity: if event_data is None: return message_ok - event_data[ATTR_DATA] = data[ATTR_DATA] + query_data = event_data[ATTR_DATA] = data[ATTR_DATA] + + if query_data[0] == "/": + pieces = query_data.split(" ") + event_data[ATTR_COMMAND] = pieces[0] + event_data[ATTR_ARGS] = pieces[1:] + event_data[ATTR_MSG] = data[ATTR_MSG] event_data[ATTR_CHAT_INSTANCE] = data[ATTR_CHAT_INSTANCE] event_data[ATTR_MSGID] = data[ATTR_MSGID]