Skip to content

Commit

Permalink
pyrofork: Add copy_text field to InlineKeyboardButton
Browse files Browse the repository at this point in the history
Signed-off-by: wulan17 <[email protected]>
  • Loading branch information
wulan17 committed Sep 20, 2024
1 parent 440fd13 commit 6cf2a33
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pyrogram/types/bots_and_keyboards/inline_keyboard_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class InlineKeyboardButton(Object):
callback_data_with_password (``bytes``, *optional*):
A button that asks for the 2-step verification password of the current user and then sends a callback query to a bot Data to be sent to the bot via a callback query.
copy_text (``str``, *optional*):
A button that copies the text to the clipboard.
"""

def __init__(
Expand All @@ -86,7 +89,8 @@ def __init__(
switch_inline_query: Optional[str] = None,
switch_inline_query_current_chat: Optional[str] = None,
callback_game: Optional["types.CallbackGame"] = None,
requires_password: Optional[bool] = None
requires_password: Optional[bool] = None,
copy_text: Optional[str] = None
):
super().__init__()

Expand All @@ -101,6 +105,7 @@ def __init__(
self.callback_game = callback_game
self.requires_password = requires_password
# self.pay = pay
self.copy_text = copy_text

@staticmethod
def read(b: "raw.base.KeyboardButton"):
Expand Down Expand Up @@ -162,6 +167,12 @@ def read(b: "raw.base.KeyboardButton"):
)
)

if isinstance(b, raw.types.KeyboardButtonCopy):
return types.InlineKeyboardButton(
text=b.text,
copy_text=b.copy_text
)

if isinstance(b, raw.types.KeyboardButtonBuy):
return types.InlineKeyboardButtonBuy.read(b)

Expand Down Expand Up @@ -217,3 +228,9 @@ async def write(self, client: "pyrogram.Client"):
text=self.text,
url=self.web_app.url
)

if self.copy_text is not None:
return raw.types.KeyboardButtonCopy(
text=self.text,
copy_text=self.copy_text
)

0 comments on commit 6cf2a33

Please sign in to comment.