From efbef64cd335dc381076f9d7f4d0a8a5110870b7 Mon Sep 17 00:00:00 2001 From: floordiv Date: Fri, 9 Apr 2021 12:26:57 +0300 Subject: [PATCH] aiogram.types.inline_keyboard: added all the same behavior for InlineKeyboardMarkup as ReplyKeyboardMarkup's operators overloading --- aiogram/types/inline_keyboard.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/aiogram/types/inline_keyboard.py b/aiogram/types/inline_keyboard.py index 97ad35da..8ba946e7 100644 --- a/aiogram/types/inline_keyboard.py +++ b/aiogram/types/inline_keyboard.py @@ -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): """