mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-09 09:22:03 +00:00
Upgrade ReplyKeyboardMarkup methods to return self
This commit is contained in:
parent
6d14790e1c
commit
def6fff4a9
1 changed files with 13 additions and 4 deletions
|
|
@ -37,7 +37,8 @@ class ReplyKeyboardMarkup(base.TelegramObject):
|
|||
Add buttons
|
||||
|
||||
:param args:
|
||||
:return:
|
||||
:return: self
|
||||
:rtype: :obj:`types.ReplyKeyboardMarkup`
|
||||
"""
|
||||
row = []
|
||||
for index, button in enumerate(args):
|
||||
|
|
@ -47,13 +48,15 @@ class ReplyKeyboardMarkup(base.TelegramObject):
|
|||
row = []
|
||||
if len(row) > 0:
|
||||
self.keyboard.append(row)
|
||||
return self
|
||||
|
||||
def row(self, *args):
|
||||
"""
|
||||
Add row
|
||||
|
||||
:param args:
|
||||
:return:
|
||||
:return: self
|
||||
:rtype: :obj:`types.ReplyKeyboardMarkup`
|
||||
"""
|
||||
btn_array = []
|
||||
for button in args:
|
||||
|
|
@ -66,11 +69,14 @@ class ReplyKeyboardMarkup(base.TelegramObject):
|
|||
Insert button to last row
|
||||
|
||||
:param button:
|
||||
:return: self
|
||||
:rtype: :obj:`types.ReplyKeyboardMarkup`
|
||||
"""
|
||||
if self.keyboard and len(self.keyboard[-1]) < self.row_width:
|
||||
self.keyboard[-1].append(button)
|
||||
else:
|
||||
self.add(button)
|
||||
return self
|
||||
|
||||
|
||||
class KeyboardButton(base.TelegramObject):
|
||||
|
|
@ -84,8 +90,11 @@ class KeyboardButton(base.TelegramObject):
|
|||
request_contact: base.Boolean = fields.Field()
|
||||
request_location: base.Boolean = fields.Field()
|
||||
|
||||
def __init__(self, text: base.String, request_contact: base.Boolean = None, request_location: base.Boolean = None):
|
||||
super(KeyboardButton, self).__init__(text=text, request_contact=request_contact,
|
||||
def __init__(self, text: base.String,
|
||||
request_contact: base.Boolean = None,
|
||||
request_location: base.Boolean = None):
|
||||
super(KeyboardButton, self).__init__(text=text,
|
||||
request_contact=request_contact,
|
||||
request_location=request_location)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue