|
| 1 | +# Pyrogram - Telegram MTProto API Client Library for Python |
| 2 | +# Copyright (C) 2017-present Dan <https://github.com/delivrance> |
| 3 | +# |
| 4 | +# This file is part of Pyrogram. |
| 5 | +# |
| 6 | +# Pyrogram is free software: you can redistribute it and/or modify |
| 7 | +# it under the terms of the GNU Lesser General Public License as published |
| 8 | +# by the Free Software Foundation, either version 3 of the License, or |
| 9 | +# (at your option) any later version. |
| 10 | +# |
| 11 | +# Pyrogram is distributed in the hope that it will be useful, |
| 12 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | +# GNU Lesser General Public License for more details. |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU Lesser General Public License |
| 17 | +# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + |
| 19 | +from pyrogram import raw |
| 20 | +from ..object import Object |
| 21 | + |
| 22 | + |
| 23 | +class KeyboardButtonStyle(Object): |
| 24 | + """Style configuration for keyboard buttons. |
| 25 | +
|
| 26 | + Parameters: |
| 27 | + bg_primary (``bool``, *optional*): |
| 28 | + Use primary background color for the button. |
| 29 | +
|
| 30 | + bg_danger (``bool``, *optional*): |
| 31 | + Use danger/red background color for the button. |
| 32 | +
|
| 33 | + bg_success (``bool``, *optional*): |
| 34 | + Use success/green background color for the button. |
| 35 | +
|
| 36 | + icon (``int``, *optional*): |
| 37 | + Custom emoji ID to use as button icon. |
| 38 | + """ |
| 39 | + |
| 40 | + def __init__( |
| 41 | + self, |
| 42 | + *, |
| 43 | + bg_primary: bool = None, |
| 44 | + bg_danger: bool = None, |
| 45 | + bg_success: bool = None, |
| 46 | + icon: int = None |
| 47 | + ): |
| 48 | + super().__init__() |
| 49 | + |
| 50 | + self.bg_primary = bg_primary |
| 51 | + self.bg_danger = bg_danger |
| 52 | + self.bg_success = bg_success |
| 53 | + self.icon = icon |
| 54 | + |
| 55 | + @staticmethod |
| 56 | + def read(style: "raw.types.KeyboardButtonStyle") -> "KeyboardButtonStyle": |
| 57 | + if style is None: |
| 58 | + return None |
| 59 | + |
| 60 | + return KeyboardButtonStyle( |
| 61 | + bg_primary=style.bg_primary or None, |
| 62 | + bg_danger=style.bg_danger or None, |
| 63 | + bg_success=style.bg_success or None, |
| 64 | + icon=style.icon |
| 65 | + ) |
| 66 | + |
| 67 | + def write(self) -> "raw.types.KeyboardButtonStyle": |
| 68 | + return raw.types.KeyboardButtonStyle( |
| 69 | + bg_primary=self.bg_primary, |
| 70 | + bg_danger=self.bg_danger, |
| 71 | + bg_success=self.bg_success, |
| 72 | + icon=self.icon |
| 73 | + ) |
0 commit comments