Add telegram disable_web_page_preview (#75898)

* Add telegram disable_web_page_preview

Adds ability to specify disable_web_page_preview to telegram.notify:
```
- service: notify.telegram
  data:
    message: >-
      <a href="https://www.home-assistant.io/">HA site</a>
    data:
      parse_mode: html
      disable_web_page_preview: true
```

* Update homeassistant/components/telegram/notify.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update notify.py

* Update notify.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
ildar170975 2022-07-30 15:06:55 +03:00 committed by GitHub
parent ace359b1bd
commit faf25b2235
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,7 @@ from homeassistant.components.notify import (
) )
from homeassistant.components.telegram_bot import ( from homeassistant.components.telegram_bot import (
ATTR_DISABLE_NOTIF, ATTR_DISABLE_NOTIF,
ATTR_DISABLE_WEB_PREV,
ATTR_MESSAGE_TAG, ATTR_MESSAGE_TAG,
ATTR_PARSER, ATTR_PARSER,
) )
@ -76,6 +77,11 @@ class TelegramNotificationService(BaseNotificationService):
parse_mode = data.get(ATTR_PARSER) parse_mode = data.get(ATTR_PARSER)
service_data.update({ATTR_PARSER: parse_mode}) service_data.update({ATTR_PARSER: parse_mode})
# Set disable_web_page_preview
if data is not None and ATTR_DISABLE_WEB_PREV in data:
disable_web_page_preview = data[ATTR_DISABLE_WEB_PREV]
service_data.update({ATTR_DISABLE_WEB_PREV: disable_web_page_preview})
# Get keyboard info # Get keyboard info
if data is not None and ATTR_KEYBOARD in data: if data is not None and ATTR_KEYBOARD in data:
keys = data.get(ATTR_KEYBOARD) keys = data.get(ATTR_KEYBOARD)