From f0c06aa9b8b116869c3008c1f7102f1f01170d5e Mon Sep 17 00:00:00 2001 From: floordiv Date: Fri, 9 Apr 2021 03:29:43 +0300 Subject: [PATCH] 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) --- aiogram/types/reply_keyboard.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/aiogram/types/reply_keyboard.py b/aiogram/types/reply_keyboard.py index ffe07ae1..271906bd 100644 --- a/aiogram/types/reply_keyboard.py +++ b/aiogram/types/reply_keyboard.py @@ -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): """