telegram small cleanup/style (#5852)

This commit is contained in:
Pascal Vizeli 2017-02-10 16:39:02 +01:00 committed by GitHub
parent 1da6181491
commit 8785e5826e

View file

@ -106,19 +106,16 @@ class BotPushReceiver(HomeAssistantView):
data = yield from request.json()
data = data['message']
if data['from']['id'] not in self.users:
_LOGGER.warning("User not allowed")
return self.json_message('Invalid user', HTTP_BAD_REQUEST)
if data['text'][0] != '/':
_LOGGER.warning('no command')
return self.json({})
except (ValueError, IndexError):
except (KeyError, IndexError):
return self.json_message('Invalid JSON', HTTP_BAD_REQUEST)
try:
if data['from']['id'] not in self.users:
raise ValueError()
except (ValueError, IndexError):
_LOGGER.warning("User not allowed")
return self.json_message('Invalid user', HTTP_BAD_REQUEST)
_LOGGER.debug("Received telegram data: %s", data)
pieces = data['text'].split(' ')