From a803edd09b70e3ff3636e19f2dbd98c6769c6e47 Mon Sep 17 00:00:00 2001 From: meoww-bot <14239840+meoww-bot@users.noreply.github.com> Date: Wed, 2 Sep 2020 09:25:23 +0800 Subject: [PATCH] fix: button in markup should be obj, not json text --- telebot/types.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/telebot/types.py b/telebot/types.py index 45181f3..0c9b99e 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -940,7 +940,7 @@ class KeyboardButtonPollType(Dictionaryable): return {'type': self.type} -class InlineKeyboardMarkup(Dictionaryable, JsonSerializable, JsonDeserializable)): +class InlineKeyboardMarkup(Dictionaryable, JsonSerializable, JsonDeserializable): max_row_keys = 8 @classmethod @@ -948,7 +948,7 @@ class InlineKeyboardMarkup(Dictionaryable, JsonSerializable, JsonDeserializable) if (json_string is None): return None obj = cls.check_json(json_string) - keyboard = [[button for button in row] for row in obj['inline_keyboard']] + keyboard = [[InlineKeyboardButton.de_json(button) for button in row] for row in obj['inline_keyboard']] return cls(keyboard) def __init__(self, keyboard=[] ,row_width=3): @@ -990,7 +990,7 @@ class InlineKeyboardMarkup(Dictionaryable, JsonSerializable, JsonDeserializable) row_width = self.max_row_keys for row in util.chunks(args, row_width): - button_array = [button.to_dict() for button in row] + button_array = [button for button in row] self.keyboard.append(button_array) return self @@ -1020,7 +1020,8 @@ class InlineKeyboardMarkup(Dictionaryable, JsonSerializable, JsonDeserializable) return json.dumps(self.to_dict()) def to_dict(self): - json_dict = {'inline_keyboard': self.keyboard} + json_dict = dict() + json_dict['inline_keyboard'] = [[json.loads(button.to_json()) for button in row] for row in self.keyboard] return json_dict