Skip to content

Commit

Permalink
Added the fields request_title, request_username, and request_photo t…
Browse files Browse the repository at this point in the history
…o the class KeyboardButtonRequestChat.
  • Loading branch information
SpEcHiDe committed Apr 1, 2024
1 parent abe9933 commit 53f6d7d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/source/releases/changes-in-this-fork.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ it can take advantage of new goodies!
| Scheme layer used: 177 |
+------------------------+

- Added the fields ``request_title``, ``request_username``, and ``request_photo`` to the class :meth:`~pyrogram.types.KeyboardButtonRequestChat`.
- Added the fields ``request_name``, ``request_username``, and ``request_photo`` to the class :meth:`~pyrogram.types.KeyboardButtonRequestUsers`.

+------------------------+
Expand Down
13 changes: 11 additions & 2 deletions pyrogram/types/bots_and_keyboards/keyboard_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ def read(b):
user_administrator_rights=user_administrator_rights,
bot_administrator_rights=bot_administrator_rights,
bot_is_member=getattr(b.peer_type, "bot_participant", None),
request_title=_nr,
request_username=_ur,
request_photo=_pr
)
)

Expand Down Expand Up @@ -194,7 +197,10 @@ def write(self):
user_admin_rights = self.request_chat.user_administrator_rights.write() if self.request_chat.user_administrator_rights else None
bot_admin_rights = self.request_chat.bot_administrator_rights.write() if self.request_chat.bot_administrator_rights else None
if self.request_chat.chat_is_channel:
return raw.types.KeyboardButtonRequestPeer(
return raw.types.InputKeyboardButtonRequestPeer(
name_requested=self.request_chat.request_title,
username_requested=self.request_chat.request_username,
photo_requested=self.request_chat.request_photo,
text=self.text,
button_id=self.request_chat.request_id,
peer_type=raw.types.RequestPeerTypeBroadcast(
Expand All @@ -206,7 +212,10 @@ def write(self):
max_quantity=1
)
else:
return raw.types.KeyboardButtonRequestPeer(
return raw.types.InputKeyboardButtonRequestPeer(
name_requested=self.request_chat.request_title,
username_requested=self.request_chat.request_username,
photo_requested=self.request_chat.request_photo,
text=self.text,
button_id=self.request_chat.request_id,
peer_type=raw.types.RequestPeerTypeChat(
Expand Down
20 changes: 18 additions & 2 deletions pyrogram/types/bots_and_keyboards/keyboard_button_request_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

class KeyboardButtonRequestChat(Object):
"""This object defines the criteria used to request a suitable chat.
The identifier of the selected chat will be shared with the bot when the corresponding button is pressed.
Information about the selected chat will be shared with the bot when the corresponding button is pressed.
The bot will be granted requested rights in the сhat if appropriate.
`More about requesting chats. <https://core.telegram.org/bots/features#chat-and-user-selection>`_
Parameters:
Expand Down Expand Up @@ -50,6 +51,15 @@ class KeyboardButtonRequestChat(Object):
bot_is_member (``bool``, *optional*):
Pass True to request a chat with the bot as a member. Otherwise, no additional restrictions are applied.
request_title (``bool``, *optional*):
Pass True to request the chat's title
request_username (``bool``, *optional*):
Pass True to request the chat's username
request_photo (``bool``, *optional*):
Pass True to request the chat's photo
"""
def __init__(
self,
Expand All @@ -60,7 +70,10 @@ def __init__(
chat_is_created: bool = None,
user_administrator_rights: "types.ChatPrivileges" = None,
bot_administrator_rights: "types.ChatPrivileges" = None,
bot_is_member: bool = None
bot_is_member: bool = None,
request_title: bool = None,
request_username: bool = None,
request_photo: bool = None
):
self.request_id = request_id
self.chat_is_channel = chat_is_channel
Expand All @@ -70,3 +83,6 @@ def __init__(
self.user_administrator_rights = user_administrator_rights
self.bot_administrator_rights = bot_administrator_rights
self.bot_is_member = bot_is_member
self.request_title = request_title
self.request_username = request_username
self.request_photo = request_photo

0 comments on commit 53f6d7d

Please sign in to comment.