From 6cf2a33ace79145a3a2b48a36b7666cfdf03571b Mon Sep 17 00:00:00 2001 From: wulan17 Date: Fri, 20 Sep 2024 17:53:52 +0700 Subject: [PATCH] pyrofork: Add copy_text field to InlineKeyboardButton Signed-off-by: wulan17 --- .../inline_keyboard_button.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pyrogram/types/bots_and_keyboards/inline_keyboard_button.py b/pyrogram/types/bots_and_keyboards/inline_keyboard_button.py index a6bbb795b..b49db3d7e 100644 --- a/pyrogram/types/bots_and_keyboards/inline_keyboard_button.py +++ b/pyrogram/types/bots_and_keyboards/inline_keyboard_button.py @@ -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__( @@ -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__() @@ -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"): @@ -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) @@ -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 + )