diff --git a/aiogram/types/__init__.py b/aiogram/types/__init__.py index 7b1e1e6a..a0d0982a 100644 --- a/aiogram/types/__init__.py +++ b/aiogram/types/__init__.py @@ -89,8 +89,7 @@ class Deserializable: @classmethod def deserialize(cls, obj): + if isinstance(obj, list): + return deserialize_array(cls, obj) return deserialize(cls, obj) - @classmethod - def deserialize_array(cls, objs): - return deserialize_array(cls, objs) diff --git a/aiogram/types/game.py b/aiogram/types/game.py index b1c17917..ada89d44 100644 --- a/aiogram/types/game.py +++ b/aiogram/types/game.py @@ -19,9 +19,9 @@ class Game(Deserializable): title = raw_data.get('title') description = raw_data.get('description') - photo = PhotoSize.deserialize_array(raw_data.get('photo')) + photo = PhotoSize.deserialize(raw_data.get('photo')) text = raw_data.get('text') - text_entities = MessageEntity.deserialize_array(raw_data.get('text_entities')) + text_entities = MessageEntity.deserialize(raw_data.get('text_entities')) animation = Animation.deserialize(raw_data.get('animation')) return Game(title, description, photo, text, text_entities, animation) diff --git a/aiogram/types/message.py b/aiogram/types/message.py index 59ec36d7..93730b15 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -86,7 +86,7 @@ class Message(Deserializable): reply_to_message = Message.deserialize(raw_data.get('reply_to_message', {})) edit_date = cls._parse_date(raw_data.get('edit_date', 0)) text = raw_data.get('text') - entities = MessageEntity.deserialize_array(raw_data.get('entities')) + entities = MessageEntity.deserialize(raw_data.get('entities')) audio = Audio.deserialize(raw_data.get('audio')) document = Document.deserialize(raw_data.get('document')) game = Game.deserialize(raw_data.get('game')) @@ -95,7 +95,7 @@ class Message(Deserializable): video = Video.deserialize(raw_data.get('video')) voice = Voice.deserialize(raw_data.get('voice')) video_note = VideoNote.deserialize(raw_data.get('video_note')) - new_chat_members = User.deserialize_array(raw_data.get('new_chat_members')) + new_chat_members = User.deserialize(raw_data.get('new_chat_members')) caption = raw_data.get('caption') contact = Contact.deserialize(raw_data.get('contact')) location = Location.deserialize(raw_data.get('location')) @@ -103,7 +103,7 @@ class Message(Deserializable): left_chat_member = User.deserialize(raw_data.get('left_chat_member')) new_chat_title = raw_data.get('new_chat_title') new_chat_photo = raw_data.get('new_chat_photo') - delete_chat_photo = PhotoSize.deserialize_array(raw_data.get('delete_chat_photo')) + delete_chat_photo = PhotoSize.deserialize(raw_data.get('delete_chat_photo')) group_chat_created = raw_data.get('group_chat_created') supergroup_chat_created = raw_data.get('supergroup_chat_created') channel_chat_created = raw_data.get('channel_chat_created') diff --git a/aiogram/types/user_profile_photos.py b/aiogram/types/user_profile_photos.py index 627a6799..9217a1cf 100644 --- a/aiogram/types/user_profile_photos.py +++ b/aiogram/types/user_profile_photos.py @@ -12,6 +12,6 @@ class UserProfilePhotos(Deserializable): raw_data = cls.check_json(raw_data) total_count = raw_data.get('total_count') - photos = PhotoSize.deserialize_array(raw_data.get('photos')) + photos = PhotoSize.deserialize(raw_data.get('photos')) return UserProfilePhotos(total_count, photos)