mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Added the class KeyboardButtonRequestUser and the field request_user to the class KeyboardButton.
This commit is contained in:
parent
c39c050abf
commit
2e5fb10430
@ -2245,17 +2245,22 @@ class KeyboardButton(Dictionaryable, JsonSerializable):
|
|||||||
will be able to send a “web_app_data” service message. Available in private chats only.
|
will be able to send a “web_app_data” service message. Available in private chats only.
|
||||||
:type web_app: :class:`telebot.types.WebAppInfo`
|
:type web_app: :class:`telebot.types.WebAppInfo`
|
||||||
|
|
||||||
|
:param request_user: Optional. If specified, pressing the button will open a list of suitable users. Tapping on any user
|
||||||
|
will send their identifier to the bot in a “user_shared” service message. Available in private chats only.
|
||||||
|
:type request_user: :class:`telebot.types.KeyboardButtonRequestUser`
|
||||||
|
|
||||||
:return: Instance of the class
|
:return: Instance of the class
|
||||||
:rtype: :class:`telebot.types.KeyboardButton`
|
:rtype: :class:`telebot.types.KeyboardButton`
|
||||||
"""
|
"""
|
||||||
def __init__(self, text: str, request_contact: Optional[bool]=None,
|
def __init__(self, text: str, request_contact: Optional[bool]=None,
|
||||||
request_location: Optional[bool]=None, request_poll: Optional[KeyboardButtonPollType]=None,
|
request_location: Optional[bool]=None, request_poll: Optional[KeyboardButtonPollType]=None,
|
||||||
web_app: WebAppInfo=None):
|
web_app: Optional[WebAppInfo]=None, request_user: Optional[KeyboardButtonRequestUser]=None):
|
||||||
self.text: str = text
|
self.text: str = text
|
||||||
self.request_contact: bool = request_contact
|
self.request_contact: bool = request_contact
|
||||||
self.request_location: bool = request_location
|
self.request_location: bool = request_location
|
||||||
self.request_poll: KeyboardButtonPollType = request_poll
|
self.request_poll: KeyboardButtonPollType = request_poll
|
||||||
self.web_app: WebAppInfo = web_app
|
self.web_app: WebAppInfo = web_app
|
||||||
|
self.request_user: KeyboardButtonRequestUser = request_user
|
||||||
|
|
||||||
def to_json(self):
|
def to_json(self):
|
||||||
return json.dumps(self.to_dict())
|
return json.dumps(self.to_dict())
|
||||||
@ -2270,6 +2275,8 @@ class KeyboardButton(Dictionaryable, JsonSerializable):
|
|||||||
json_dict['request_poll'] = self.request_poll.to_dict()
|
json_dict['request_poll'] = self.request_poll.to_dict()
|
||||||
if self.web_app is not None:
|
if self.web_app is not None:
|
||||||
json_dict['web_app'] = self.web_app.to_dict()
|
json_dict['web_app'] = self.web_app.to_dict()
|
||||||
|
if self.request_user is not None:
|
||||||
|
json_dict['request_user'] = self.request_user.to_dict()
|
||||||
return json_dict
|
return json_dict
|
||||||
|
|
||||||
|
|
||||||
@ -7012,5 +7019,41 @@ class WriteAccessAllowed(JsonDeserializable):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class KeyboardButtonRequestUser(Dictionaryable):
|
||||||
|
"""
|
||||||
|
This object defines the criteria used to request a suitable user.
|
||||||
|
The identifier of the selected user will be shared with the bot when the corresponding button is pressed.
|
||||||
|
|
||||||
|
Telegram documentation: https://core.telegram.org/bots/api#keyboardbuttonrequestuser
|
||||||
|
|
||||||
|
:param request_id: Signed 32-bit identifier of the request, which will be received back in the UserShared object.
|
||||||
|
Must be unique within the message
|
||||||
|
:type request_id: :obj:`int`
|
||||||
|
|
||||||
|
:param user_is_bot: Optional. Pass True to request a bot, pass False to request a regular user.
|
||||||
|
If not specified, no additional restrictions are applied.
|
||||||
|
:type user_is_bot: :obj:`bool`
|
||||||
|
|
||||||
|
:param user_is_premium: Optional. Pass True to request a premium user, pass False to request a non-premium user.
|
||||||
|
If not specified, no additional restrictions are applied.
|
||||||
|
:type user_is_premium: :obj:`bool`
|
||||||
|
|
||||||
|
:return: Instance of the class
|
||||||
|
:rtype: :class:`telebot.types.KeyboardButtonRequestUser`
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, request_id: int, user_is_bot: Optional[bool]=None, user_is_premium: Optional[bool]=None) -> None:
|
||||||
|
self.request_id: int = request_id
|
||||||
|
self.user_is_bot: Optional[bool] = user_is_bot
|
||||||
|
self.user_is_premium: Optional[bool] = user_is_premium
|
||||||
|
|
||||||
|
def to_dict(self) -> dict:
|
||||||
|
data = {'request_id': self.request_id}
|
||||||
|
if self.user_is_bot is not None:
|
||||||
|
data['user_is_bot'] = self.user_is_bot
|
||||||
|
if self.user_is_premium is not None:
|
||||||
|
data['user_is_premium'] = self.user_is_premium
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user