aiogram.types.reply_keyboard: implemented __iadd__ method (allows adding buttons using += operator instead of calling .add() method), __add__ (get new keyboard from 2+ other keyboards by adding them)

This commit is contained in:
floordiv 2021-04-09 03:29:43 +03:00
parent 79c59b34f9
commit f0c06aa9b8

View file

@ -90,6 +90,16 @@ class ReplyKeyboardMarkup(base.TelegramObject):
self.add(button)
return self
def __iadd__(self, other):
return self.add(other)
def __add__(self, other):
return ReplyKeyboardMarkup(
keyboard=self.keyboard + other.keyboard, resize_keyboard=self.resize_keyboard,
one_time_keyboard=self.one_time_keyboard, selective=self.selective,
row_width=self.row_width
)
class KeyboardButton(base.TelegramObject):
"""