Allow plain text messages in telegram_bot (#110051)

* Add new plain_text parser

Passing None in the parse_mode kwargs on the various bot methods actually means that no parser is used.

* Add new plain text parser option to services.yaml

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
Jim 2024-04-23 18:32:09 +01:00 committed by GitHub
parent d8aa1cd8b5
commit cc9eab4c78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View file

@ -122,6 +122,7 @@ EVENT_TELEGRAM_SENT = "telegram_sent"
PARSER_HTML = "html" PARSER_HTML = "html"
PARSER_MD = "markdown" PARSER_MD = "markdown"
PARSER_MD2 = "markdownv2" PARSER_MD2 = "markdownv2"
PARSER_PLAIN_TEXT = "plain_text"
DEFAULT_TRUSTED_NETWORKS = [ip_network("149.154.160.0/20"), ip_network("91.108.4.0/22")] DEFAULT_TRUSTED_NETWORKS = [ip_network("149.154.160.0/20"), ip_network("91.108.4.0/22")]
@ -524,6 +525,7 @@ class TelegramNotificationService:
PARSER_HTML: ParseMode.HTML, PARSER_HTML: ParseMode.HTML,
PARSER_MD: ParseMode.MARKDOWN, PARSER_MD: ParseMode.MARKDOWN,
PARSER_MD2: ParseMode.MARKDOWN_V2, PARSER_MD2: ParseMode.MARKDOWN_V2,
PARSER_PLAIN_TEXT: None,
} }
self._parse_mode = self._parsers.get(parser) self._parse_mode = self._parsers.get(parser)
self.bot = bot self.bot = bot

View file

@ -22,6 +22,7 @@ send_message:
- "html" - "html"
- "markdown" - "markdown"
- "markdownv2" - "markdownv2"
- "plain_text"
disable_notification: disable_notification:
selector: selector:
boolean: boolean:
@ -94,6 +95,7 @@ send_photo:
- "html" - "html"
- "markdown" - "markdown"
- "markdownv2" - "markdownv2"
- "plain_text"
disable_notification: disable_notification:
selector: selector:
boolean: boolean:
@ -229,6 +231,7 @@ send_animation:
- "html" - "html"
- "markdown" - "markdown"
- "markdownv2" - "markdownv2"
- "plain_text"
disable_notification: disable_notification:
selector: selector:
boolean: boolean:
@ -300,6 +303,7 @@ send_video:
- "html" - "html"
- "markdown" - "markdown"
- "markdownv2" - "markdownv2"
- "plain_text"
disable_notification: disable_notification:
selector: selector:
boolean: boolean:
@ -435,6 +439,7 @@ send_document:
- "html" - "html"
- "markdown" - "markdown"
- "markdownv2" - "markdownv2"
- "plain_text"
disable_notification: disable_notification:
selector: selector:
boolean: boolean:
@ -587,6 +592,7 @@ edit_message:
- "html" - "html"
- "markdown" - "markdown"
- "markdownv2" - "markdownv2"
- "plain_text"
disable_web_page_preview: disable_web_page_preview:
selector: selector:
boolean: boolean: