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:
Max 2019-05-02 21:14:40 +02:00 committed by Charles Garwood
parent f434e24252
commit 7331eb1f71
2 changed files with 8 additions and 4 deletions

View file

@ -446,11 +446,15 @@ class TelegramNotificationService:
params[ATTR_REPLY_TO_MSGID] = data[ATTR_REPLY_TO_MSGID]
# Keyboards:
if ATTR_KEYBOARD in data:
from telegram import ReplyKeyboardMarkup
from telegram import ReplyKeyboardMarkup, ReplyKeyboardRemove
keys = data.get(ATTR_KEYBOARD)
keys = keys if isinstance(keys, list) else [keys]
params[ATTR_REPLYMARKUP] = ReplyKeyboardMarkup(
[[key.strip() for key in row.split(",")] for row in keys])
if 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:
from telegram import InlineKeyboardMarkup
keys = data.get(ATTR_KEYBOARD_INLINE)

View file

@ -22,7 +22,7 @@ send_message:
description: Disables link previews for links in the message.
example: true
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"]'
inline_keyboard:
description: List of rows of commands, comma-separated, to make a custom inline keyboard with buttons with associated callback data.