Skip to content

Commit 149685f

Browse files
authored
Add placeholder in ForceReply & ReplyKeyboardMarkup (pyrogram#717)
* Added placeholder * Fix docs
1 parent 244606e commit 149685f

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

pyrogram/types/bots_and_keyboards/force_reply.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,31 @@ class ForceReply(Object):
3636
Use this parameter if you want to force reply from specific users only. Targets:
3737
1) users that are @mentioned in the text of the Message object;
3838
2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
39+
40+
placeholder (``str``, *optional*):
41+
The placeholder to be shown in the input field when the reply is active; 1-64 characters.
3942
"""
4043

4144
def __init__(
4245
self,
43-
selective: bool = None
46+
selective: bool = None,
47+
placeholder: str = None
4448
):
4549
super().__init__()
4650

4751
self.selective = selective
52+
self.placeholder = placeholder
4853

4954
@staticmethod
5055
def read(b):
5156
return ForceReply(
52-
selective=b.selective
57+
selective=b.selective,
58+
placeholder=b.placeholder
5359
)
5460

5561
async def write(self, _: "pyrogram.Client"):
5662
return raw.types.ReplyKeyboardForceReply(
5763
single_use=True,
58-
selective=self.selective or None
64+
selective=self.selective or None,
65+
placeholder=self.placeholder or None
5966
)

pyrogram/types/bots_and_keyboards/reply_keyboard_markup.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,26 @@ class ReplyKeyboardMarkup(Object):
4747
2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
4848
Example: A user requests to change the bot's language, bot replies to the request with a keyboard to
4949
select the new language. Other users in the group don't see the keyboard.
50+
51+
placeholder (``str``, *optional*):
52+
The placeholder to be shown in the input field when the keyboard is active; 1-64 characters.
5053
"""
5154

5255
def __init__(
5356
self,
5457
keyboard: List[List[Union["types.KeyboardButton", str]]],
5558
resize_keyboard: bool = None,
5659
one_time_keyboard: bool = None,
57-
selective: bool = None
60+
selective: bool = None,
61+
placeholder: str = None
5862
):
5963
super().__init__()
6064

6165
self.keyboard = keyboard
6266
self.resize_keyboard = resize_keyboard
6367
self.one_time_keyboard = one_time_keyboard
6468
self.selective = selective
69+
self.placeholder = placeholder
6570

6671
@staticmethod
6772
def read(kb):
@@ -79,7 +84,8 @@ def read(kb):
7984
keyboard=keyboard,
8085
resize_keyboard=kb.resize,
8186
one_time_keyboard=kb.single_use,
82-
selective=kb.selective
87+
selective=kb.selective,
88+
placeholder=kb.placeholder
8389
)
8490

8591
async def write(self, _: "pyrogram.Client"):
@@ -93,5 +99,6 @@ async def write(self, _: "pyrogram.Client"):
9399
) for i in self.keyboard],
94100
resize=self.resize_keyboard or None,
95101
single_use=self.one_time_keyboard or None,
96-
selective=self.selective or None
102+
selective=self.selective or None,
103+
placeholder=self.placeholder or None
97104
)

0 commit comments

Comments
 (0)