telegram small cleanup/style (#5852)
This commit is contained in:
1 parent
1da6181491
commit
8785e5826e
1 file changed
+5
-8
@@ -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(' ')
|
||||
|
||||
Reference in new issue
Block a user