mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
feat: custom placeholders
This commit is contained in:
parent
c2d3d4196e
commit
3e177648e2
2 changed files with 24 additions and 18 deletions
|
|
@ -6,31 +6,28 @@ from . import fields
|
|||
|
||||
class ForceReply(base.TelegramObject):
|
||||
"""
|
||||
Upon receiving a message with this object,
|
||||
Telegram clients will display a reply interface to the user
|
||||
(act as if the user has selected the bot‘s message and tapped ’Reply').
|
||||
This can be extremely useful if you want to create user-friendly step-by-step
|
||||
Upon receiving a message with this object, Telegram clients will
|
||||
display a reply interface to the user (act as if the user has
|
||||
selected the bot's message and tapped 'Reply'). This can be
|
||||
extremely useful if you want to create user-friendly step-by-step
|
||||
interfaces without having to sacrifice privacy mode.
|
||||
|
||||
Example: A poll bot for groups runs in privacy mode
|
||||
(only receives commands, replies to its messages and mentions).
|
||||
There could be two ways to create a new poll
|
||||
|
||||
The last option is definitely more attractive.
|
||||
And if you use ForceReply in your bot‘s questions, it will receive the user’s answers even
|
||||
if it only receives replies, commands and mentions — without any extra work for the user.
|
||||
|
||||
https://core.telegram.org/bots/api#forcereply
|
||||
"""
|
||||
force_reply: base.Boolean = fields.Field(default=True)
|
||||
input_field_placeholder: base.String = fields.Field()
|
||||
selective: base.Boolean = fields.Field()
|
||||
|
||||
@classmethod
|
||||
def create(cls, selective: typing.Optional[base.Boolean] = None):
|
||||
def create(cls,
|
||||
input_field_placeholder: typing.Optional[base.String] = None,
|
||||
selective: typing.Optional[base.Boolean] = None,
|
||||
) -> 'ForceReply':
|
||||
"""
|
||||
Create new force reply
|
||||
|
||||
:param selective:
|
||||
:param input_field_placeholder:
|
||||
:return:
|
||||
"""
|
||||
return cls(selective=selective)
|
||||
return cls(selective=selective, input_field_placeholder=input_field_placeholder)
|
||||
|
|
|
|||
|
|
@ -18,23 +18,32 @@ class KeyboardButtonPollType(base.TelegramObject):
|
|||
|
||||
class ReplyKeyboardMarkup(base.TelegramObject):
|
||||
"""
|
||||
This object represents a custom keyboard with reply options (see Introduction to bots for details and examples).
|
||||
This object represents a custom keyboard with reply options
|
||||
(see https://core.telegram.org/bots#keyboards to bots for details
|
||||
and examples).
|
||||
|
||||
https://core.telegram.org/bots/api#replykeyboardmarkup
|
||||
"""
|
||||
keyboard: 'typing.List[typing.List[KeyboardButton]]' = fields.ListOfLists(base='KeyboardButton', default=[])
|
||||
resize_keyboard: base.Boolean = fields.Field()
|
||||
one_time_keyboard: base.Boolean = fields.Field()
|
||||
input_field_placeholder: base.String = fields.Field()
|
||||
selective: base.Boolean = fields.Field()
|
||||
|
||||
def __init__(self, keyboard: 'typing.List[typing.List[KeyboardButton]]' = None,
|
||||
resize_keyboard: base.Boolean = None,
|
||||
one_time_keyboard: base.Boolean = None,
|
||||
input_field_placeholder: base.String = None,
|
||||
selective: base.Boolean = None,
|
||||
row_width: base.Integer = 3):
|
||||
super(ReplyKeyboardMarkup, self).__init__(keyboard=keyboard, resize_keyboard=resize_keyboard,
|
||||
one_time_keyboard=one_time_keyboard, selective=selective,
|
||||
conf={'row_width': row_width})
|
||||
super().__init__(
|
||||
keyboard=keyboard,
|
||||
resize_keyboard=resize_keyboard,
|
||||
one_time_keyboard=one_time_keyboard,
|
||||
input_field_placeholder=input_field_placeholder,
|
||||
selective=selective,
|
||||
conf={'row_width': row_width},
|
||||
)
|
||||
|
||||
@property
|
||||
def row_width(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue