aiogram.types.inline_keyboard: added all the same behavior for InlineKeyboardMarkup as ReplyKeyboardMarkup's operators overloading

This commit is contained in:
floordiv 2021-04-09 12:26:57 +03:00
parent f0c06aa9b8
commit efbef64cd3

View file

@ -23,6 +23,7 @@ class InlineKeyboardMarkup(base.TelegramObject):
conf = kwargs.pop('conf', {}) or {}
conf['row_width'] = row_width
self.other_kwargs = kwargs
super(InlineKeyboardMarkup, self).__init__(**kwargs,
conf=conf,
@ -82,6 +83,17 @@ class InlineKeyboardMarkup(base.TelegramObject):
self.add(button)
return self
def __iadd__(self, other):
return self.add(other)
def __add__(self, other):
return InlineKeyboardMarkup(
inline_keyboard=self.inline_keyboard,
row_width=self.row_width,
conf=self.conf,
**self.other_kwargs
)
class InlineKeyboardButton(base.TelegramObject):
"""