pyrofork: Add copy_text field to InlineKeyboardButton

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2024-09-20 17:53:52 +07:00
parent 44d4c0ff55
commit 74376f8da5
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5

View file

@ -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 @@ class InlineKeyboardButton(Object):
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 @@ class InlineKeyboardButton(Object):
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 @@ class InlineKeyboardButton(Object):
)
)
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 @@ class InlineKeyboardButton(Object):
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
)