Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the MarkdownV2 parser with the Telegram bot #101139

Merged
merged 4 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion homeassistant/components/telegram_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@

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")]

Expand Down Expand Up @@ -474,7 +475,11 @@ def __init__(self, hass, bot, allowed_chat_ids, parser):
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
Expand Down
12 changes: 6 additions & 6 deletions homeassistant/components/telegram_bot/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ send_message:
options:
- "html"
- "markdown"
- "markdown2"
- "markdownv2"
disable_notification:
selector:
boolean:
Expand Down Expand Up @@ -90,7 +90,7 @@ send_photo:
options:
- "html"
- "markdown"
- "markdown2"
- "markdownv2"
disable_notification:
selector:
boolean:
Expand Down Expand Up @@ -217,7 +217,7 @@ send_animation:
options:
- "html"
- "markdown"
- "markdown2"
- "markdownv2"
disable_notification:
selector:
boolean:
Expand Down Expand Up @@ -280,7 +280,7 @@ send_video:
options:
- "html"
- "markdown"
- "markdown2"
- "markdownv2"
disable_notification:
selector:
boolean:
Expand Down Expand Up @@ -407,7 +407,7 @@ send_document:
options:
- "html"
- "markdown"
- "markdown2"
- "markdownv2"
disable_notification:
selector:
boolean:
Expand Down Expand Up @@ -543,7 +543,7 @@ edit_message:
options:
- "html"
- "markdown"
- "markdown2"
- "markdownv2"
disable_web_page_preview:
selector:
boolean:
Expand Down