mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-11 01:54:53 +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
|
Add buttons
|
||||||
|
|
||||||
:param args:
|
:param args:
|
||||||
:return:
|
:return: self
|
||||||
|
:rtype: :obj:`types.ReplyKeyboardMarkup`
|
||||||
"""
|
"""
|
||||||
row = []
|
row = []
|
||||||
for index, button in enumerate(args):
|
for index, button in enumerate(args):
|
||||||
|
|
@ -47,13 +48,15 @@ class ReplyKeyboardMarkup(base.TelegramObject):
|
||||||
row = []
|
row = []
|
||||||
if len(row) > 0:
|
if len(row) > 0:
|
||||||
self.keyboard.append(row)
|
self.keyboard.append(row)
|
||||||
|
return self
|
||||||
|
|
||||||
def row(self, *args):
|
def row(self, *args):
|
||||||
"""
|
"""
|
||||||
Add row
|
Add row
|
||||||
|
|
||||||
:param args:
|
:param args:
|
||||||
:return:
|
:return: self
|
||||||
|
:rtype: :obj:`types.ReplyKeyboardMarkup`
|
||||||
"""
|
"""
|
||||||
btn_array = []
|
btn_array = []
|
||||||
for button in args:
|
for button in args:
|
||||||
|
|
@ -66,11 +69,14 @@ class ReplyKeyboardMarkup(base.TelegramObject):
|
||||||
Insert button to last row
|
Insert button to last row
|
||||||
|
|
||||||
:param button:
|
:param button:
|
||||||
|
:return: self
|
||||||
|
:rtype: :obj:`types.ReplyKeyboardMarkup`
|
||||||
"""
|
"""
|
||||||
if self.keyboard and len(self.keyboard[-1]) < self.row_width:
|
if self.keyboard and len(self.keyboard[-1]) < self.row_width:
|
||||||
self.keyboard[-1].append(button)
|
self.keyboard[-1].append(button)
|
||||||
else:
|
else:
|
||||||
self.add(button)
|
self.add(button)
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
class KeyboardButton(base.TelegramObject):
|
class KeyboardButton(base.TelegramObject):
|
||||||
|
|
@ -84,8 +90,11 @@ class KeyboardButton(base.TelegramObject):
|
||||||
request_contact: base.Boolean = fields.Field()
|
request_contact: base.Boolean = fields.Field()
|
||||||
request_location: 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):
|
def __init__(self, text: base.String,
|
||||||
super(KeyboardButton, self).__init__(text=text, request_contact=request_contact,
|
request_contact: base.Boolean = None,
|
||||||
|
request_location: base.Boolean = None):
|
||||||
|
super(KeyboardButton, self).__init__(text=text,
|
||||||
|
request_contact=request_contact,
|
||||||
request_location=request_location)
|
request_location=request_location)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue