mirror of
https://github.com/home-assistant/core.git
synced 2025-05-03 21:49:17 +00:00
Allow removing Telegram reply keyboard (#23467)
* Allow removing telegram reply keyboard by setting `keyboard` to an empty list * Telegram keyboard: [] clearing in services.yaml
This commit is contained in:
parent
f434e24252
commit
7331eb1f71
@ -446,11 +446,15 @@ class TelegramNotificationService:
|
|||||||
params[ATTR_REPLY_TO_MSGID] = data[ATTR_REPLY_TO_MSGID]
|
params[ATTR_REPLY_TO_MSGID] = data[ATTR_REPLY_TO_MSGID]
|
||||||
# Keyboards:
|
# Keyboards:
|
||||||
if ATTR_KEYBOARD in data:
|
if ATTR_KEYBOARD in data:
|
||||||
from telegram import ReplyKeyboardMarkup
|
from telegram import ReplyKeyboardMarkup, ReplyKeyboardRemove
|
||||||
keys = data.get(ATTR_KEYBOARD)
|
keys = data.get(ATTR_KEYBOARD)
|
||||||
keys = keys if isinstance(keys, list) else [keys]
|
keys = keys if isinstance(keys, list) else [keys]
|
||||||
params[ATTR_REPLYMARKUP] = ReplyKeyboardMarkup(
|
if keys:
|
||||||
[[key.strip() for key in row.split(",")] for row in keys])
|
params[ATTR_REPLYMARKUP] = ReplyKeyboardMarkup(
|
||||||
|
[[key.strip() for key in row.split(",")]
|
||||||
|
for row in keys])
|
||||||
|
else:
|
||||||
|
params[ATTR_REPLYMARKUP] = ReplyKeyboardRemove(True)
|
||||||
elif ATTR_KEYBOARD_INLINE in data:
|
elif ATTR_KEYBOARD_INLINE in data:
|
||||||
from telegram import InlineKeyboardMarkup
|
from telegram import InlineKeyboardMarkup
|
||||||
keys = data.get(ATTR_KEYBOARD_INLINE)
|
keys = data.get(ATTR_KEYBOARD_INLINE)
|
||||||
|
@ -22,7 +22,7 @@ send_message:
|
|||||||
description: Disables link previews for links in the message.
|
description: Disables link previews for links in the message.
|
||||||
example: true
|
example: true
|
||||||
keyboard:
|
keyboard:
|
||||||
description: List of rows of commands, comma-separated, to make a custom keyboard.
|
description: List of rows of commands, comma-separated, to make a custom keyboard. Empty list clears a previously set keyboard.
|
||||||
example: '["/command1, /command2", "/command3"]'
|
example: '["/command1, /command2", "/command3"]'
|
||||||
inline_keyboard:
|
inline_keyboard:
|
||||||
description: List of rows of commands, comma-separated, to make a custom inline keyboard with buttons with associated callback data.
|
description: List of rows of commands, comma-separated, to make a custom inline keyboard with buttons with associated callback data.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user