Add resize_keyboard and one_time_keyboard attributes to telegram bot service (#91613)
* Add new params for telegram bot Add resize_keyboard and one_time_keyboard attributes * Apply review changes * Update homeassistant/components/telegram_bot/__init__.py * Update __init__.py --------- Co-authored-by: Erik Montnemery <erik@montnemery.com>pull/93464/head
parent
16780bf4c2
commit
f8fdeeabc2
|
@ -62,6 +62,8 @@ ATTR_FILE = "file"
|
|||
ATTR_FROM_FIRST = "from_first"
|
||||
ATTR_FROM_LAST = "from_last"
|
||||
ATTR_KEYBOARD = "keyboard"
|
||||
ATTR_RESIZE_KEYBOARD = "resize_keyboard"
|
||||
ATTR_ONE_TIME_KEYBOARD = "one_time_keyboard"
|
||||
ATTR_KEYBOARD_INLINE = "inline_keyboard"
|
||||
ATTR_MESSAGEID = "message_id"
|
||||
ATTR_MSG = "message"
|
||||
|
@ -157,6 +159,8 @@ BASE_SERVICE_SCHEMA = vol.Schema(
|
|||
vol.Optional(ATTR_PARSER): cv.string,
|
||||
vol.Optional(ATTR_DISABLE_NOTIF): cv.boolean,
|
||||
vol.Optional(ATTR_DISABLE_WEB_PREV): cv.boolean,
|
||||
vol.Optional(ATTR_RESIZE_KEYBOARD): cv.boolean,
|
||||
vol.Optional(ATTR_ONE_TIME_KEYBOARD): cv.boolean,
|
||||
vol.Optional(ATTR_KEYBOARD): vol.All(cv.ensure_list, [cv.string]),
|
||||
vol.Optional(ATTR_KEYBOARD_INLINE): cv.ensure_list,
|
||||
vol.Optional(ATTR_TIMEOUT): cv.positive_int,
|
||||
|
@ -581,7 +585,13 @@ class TelegramNotificationService:
|
|||
keys = keys if isinstance(keys, list) else [keys]
|
||||
if keys:
|
||||
params[ATTR_REPLYMARKUP] = ReplyKeyboardMarkup(
|
||||
[[key.strip() for key in row.split(",")] for row in keys]
|
||||
[[key.strip() for key in row.split(",")] for row in keys],
|
||||
resize_keyboard=data[ATTR_RESIZE_KEYBOARD]
|
||||
if ATTR_RESIZE_KEYBOARD in data
|
||||
else False,
|
||||
one_time_keyboard=data[ATTR_ONE_TIME_KEYBOARD]
|
||||
if ATTR_ONE_TIME_KEYBOARD in data
|
||||
else False,
|
||||
)
|
||||
else:
|
||||
params[ATTR_REPLYMARKUP] = ReplyKeyboardRemove(True)
|
||||
|
|
Loading…
Reference in New Issue