Refactor bot keyboard types · stack-queue/pyrogram@a683e3e · GitHub
Skip to content

Commit a683e3e

Browse files
committed
Refactor bot keyboard types
1 parent 3f64324 commit a683e3e

6 files changed

Lines changed: 27 additions & 45 deletions

File tree

pyrogram/client/types/bots/force_reply.py

Lines changed: 4 additions & 4 deletions

pyrogram/client/types/bots/inline_keyboard_button.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from pyrogram.api.core import Object
20-
2119
from pyrogram.api.types import (
2220
KeyboardButtonUrl, KeyboardButtonCallback,
2321
KeyboardButtonSwitchInline
2422
)
23+
from ..pyrogram_type import PyrogramType
2524

2625

27-
class InlineKeyboardButton(Object):
26+
class InlineKeyboardButton(PyrogramType):
2827
"""This object represents one button of an inline keyboard. You must use exactly one of the optional fields.
2928
3029
Args:
@@ -54,18 +53,10 @@ class InlineKeyboardButton(Object):
5453

5554
# TODO: Add callback_game and pay fields
5655

57-
ID = 0xb0700019
58-
59-
def __init__(
60-
self,
61-
text: str,
62-
callback_data: bytes = None,
63-
url: str = None,
64-
switch_inline_query: str = None,
65-
switch_inline_query_current_chat: str = None,
66-
# callback_game=None,
67-
# pay: bool = None
68-
):
56+
def __init__(self, text: str, callback_data: bytes = None, url: str = None,
57+
switch_inline_query: str = None, switch_inline_query_current_chat: str = None):
58+
super().__init__(None, None)
59+
6960
self.text = text
7061
self.url = url
7162
self.callback_data = callback_data

pyrogram/client/types/bots/inline_keyboard_markup.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,22 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from pyrogram.api.core import Object
20-
2119
from pyrogram.api.types import ReplyInlineMarkup, KeyboardButtonRow
2220
from . import InlineKeyboardButton
21+
from ..pyrogram_type import PyrogramType
2322

2423

25-
class InlineKeyboardMarkup(Object):
24+
class InlineKeyboardMarkup(PyrogramType):
2625
"""This object represents an inline keyboard that appears right next to the message it belongs to.
2726
2827
Args:
2928
inline_keyboard (List of List of :obj:`InlineKeyboardButton <pyrogram.InlineKeyboardButton>`):
3029
List of button rows, each represented by a List of InlineKeyboardButton objects.
3130
"""
3231

33-
ID = 0xb0700020
34-
3532
def __init__(self, inline_keyboard: list):
33+
super().__init__(None, None)
34+
3635
self.inline_keyboard = inline_keyboard
3736

3837
@staticmethod

pyrogram/client/types/bots/keyboard_button.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from pyrogram.api.core import Object
20-
2119
from pyrogram.api.types import KeyboardButton as RawKeyboardButton
2220
from pyrogram.api.types import KeyboardButtonRequestPhone, KeyboardButtonRequestGeoLocation
21+
from ..pyrogram_type import PyrogramType
2322

2423

25-
class KeyboardButton(Object):
24+
class KeyboardButton(PyrogramType):
2625
"""This object represents one button of the reply keyboard.
2726
For simple text buttons String can be used instead of this object to specify text of the button.
2827
Optional fields are mutually exclusive.
@@ -41,9 +40,9 @@ class KeyboardButton(Object):
4140
Available in private chats only.
4241
"""
4342

44-
ID = 0xb0700021
45-
4643
def __init__(self, text: str, request_contact: bool = None, request_location: bool = None):
44+
super().__init__(None, None)
45+
4746
self.text = text
4847
self.request_contact = request_contact
4948
self.request_location = request_location

pyrogram/client/types/bots/reply_keyboard_markup.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from pyrogram.api.core import Object
20-
2119
from pyrogram.api.types import KeyboardButtonRow
2220
from pyrogram.api.types import ReplyKeyboardMarkup as RawReplyKeyboardMarkup
23-
2421
from . import KeyboardButton
22+
from ..pyrogram_type import PyrogramType
2523

2624

27-
class ReplyKeyboardMarkup(Object):
25+
class ReplyKeyboardMarkup(PyrogramType):
2826
"""This object represents a custom keyboard with reply options.
2927
3028
Args:
@@ -49,15 +47,10 @@ class ReplyKeyboardMarkup(Object):
4947
select the new language. Other users in the group don't see the keyboard.
5048
"""
5149

52-
ID = 0xb0700022
50+
def __init__(self, keyboard: list, resize_keyboard: bool = None, one_time_keyboard: bool = None,
51+
selective: bool = None):
52+
super().__init__(None, None)
5353

54-
def __init__(
55-
self,
56-
keyboard: list,
57-
resize_keyboard: bool = None,
58-
one_time_keyboard: bool = None,
59-
selective: bool = None
60-
):
6154
self.keyboard = keyboard
6255
self.resize_keyboard = resize_keyboard
6356
self.one_time_keyboard = one_time_keyboard

pyrogram/client/types/bots/reply_keyboard_remove.py

Lines changed: 4 additions & 4 deletions

0 commit comments

Comments
 (0)