Allow members of allowed groups to talk to telegram_bot (#43241)

pull/43866/head
Wictor 2020-12-02 19:25:35 +01:00 committed by GitHub
parent 519ec64522
commit 5fa00244da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -744,11 +744,12 @@ class BaseTelegramBotEntity:
_LOGGER.error("Incoming message does not have required data (%s)", msg_data)
return False, None
if msg_data["from"].get("id") not in self.allowed_chat_ids or (
"chat" in msg_data
if (
msg_data["from"].get("id") not in self.allowed_chat_ids
and msg_data["chat"].get("id") not in self.allowed_chat_ids
):
# Origin is not allowed.
# Neither from id nor chat id was in allowed_chat_ids,
# origin is not allowed.
_LOGGER.error("Incoming message is not allowed (%s)", msg_data)
return True, None