telegram small cleanup/style (#5852)
This commit is contained in:
parent
1da6181491
commit
8785e5826e
1 changed files with 5 additions and 8 deletions
|
@ -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(' ')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue