Skip to content

Commit

Permalink
Add support for pay button
Browse files Browse the repository at this point in the history
  • Loading branch information
KurimuzonAkuma committed Aug 22, 2024
1 parent 981ec3f commit 7377290
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pyrogram/types/bots_and_keyboards/inline_keyboard_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ 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.
pay (``bool``, *optional*):
Change text of pay button.
Available in :meth:`~pyrogram.Client.send_invoice`.
"""

def __init__(
Expand All @@ -85,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,
pay: bool = None
):
super().__init__()

Expand All @@ -99,7 +104,7 @@ def __init__(
self.switch_inline_query_current_chat = switch_inline_query_current_chat
self.callback_game = callback_game
self.requires_password = requires_password
# self.pay = pay
self.pay = pay

@staticmethod
def read(b: "raw.base.KeyboardButton"):
Expand Down Expand Up @@ -163,7 +168,8 @@ def read(b: "raw.base.KeyboardButton"):

if isinstance(b, raw.types.KeyboardButtonBuy):
return InlineKeyboardButton(
text=b.text
text=b.text,
pay=True
)

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

if self.pay is not None:
return raw.types.KeyboardButtonBuy(text=self.text)

0 comments on commit 7377290

Please sign in to comment.