Using the MarkdownV2 parser with the Telegram bot (#101139)

This commit is contained in:
YuriiMaiboroda 2023-10-06 13:26:20 +03:00 committed by GitHub
parent 4553de5cbf
commit ca7355b2f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View file

@ -120,6 +120,7 @@ EVENT_TELEGRAM_SENT = "telegram_sent"
PARSER_HTML = "html"
PARSER_MD = "markdown"
PARSER_MD2 = "markdownv2"
DEFAULT_TRUSTED_NETWORKS = [ip_network("149.154.160.0/20"), ip_network("91.108.4.0/22")]
@ -474,7 +475,11 @@ class TelegramNotificationService:
self.allowed_chat_ids = allowed_chat_ids
self._default_user = self.allowed_chat_ids[0]
self._last_message_id = {user: None for user in self.allowed_chat_ids}
self._parsers = {PARSER_HTML: ParseMode.HTML, PARSER_MD: ParseMode.MARKDOWN}
self._parsers = {
PARSER_HTML: ParseMode.HTML,
PARSER_MD: ParseMode.MARKDOWN,
PARSER_MD2: ParseMode.MARKDOWN_V2,
}
self._parse_mode = self._parsers.get(parser)
self.bot = bot
self.hass = hass

View file

@ -21,7 +21,7 @@ send_message:
options:
- "html"
- "markdown"
- "markdown2"
- "markdownv2"
disable_notification:
selector:
boolean:
@ -90,7 +90,7 @@ send_photo:
options:
- "html"
- "markdown"
- "markdown2"
- "markdownv2"
disable_notification:
selector:
boolean:
@ -217,7 +217,7 @@ send_animation:
options:
- "html"
- "markdown"
- "markdown2"
- "markdownv2"
disable_notification:
selector:
boolean:
@ -280,7 +280,7 @@ send_video:
options:
- "html"
- "markdown"
- "markdown2"
- "markdownv2"
disable_notification:
selector:
boolean:
@ -407,7 +407,7 @@ send_document:
options:
- "html"
- "markdown"
- "markdown2"
- "markdownv2"
disable_notification:
selector:
boolean:
@ -543,7 +543,7 @@ edit_message:
options:
- "html"
- "markdown"
- "markdown2"
- "markdownv2"
disable_web_page_preview:
selector:
boolean: