mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-13 18:43:53 +00:00
Add all deserializable types.
This commit is contained in:
parent
1351e65124
commit
8350483c98
27 changed files with 413 additions and 149 deletions
27
aiogram/types/game.py
Normal file
27
aiogram/types/game.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from aiogram.types.animation import Animation
|
||||
from aiogram.types.message_entity import MessageEntity
|
||||
from aiogram.types.photo_size import PhotoSize
|
||||
from . import Deserializable
|
||||
|
||||
|
||||
class Game(Deserializable):
|
||||
def __init__(self, title, description, photo, text, text_entities, animation):
|
||||
self.title = title
|
||||
self.description = description
|
||||
self.photo = photo
|
||||
self.text = text
|
||||
self.text_entities = text_entities
|
||||
self.animation = animation
|
||||
|
||||
@classmethod
|
||||
def de_json(cls, raw_data):
|
||||
raw_data = cls.check_json(raw_data)
|
||||
|
||||
title = raw_data.get('title')
|
||||
description = raw_data.get('description')
|
||||
photo = PhotoSize.deserialize_array(raw_data.get('photo'))
|
||||
text = raw_data.get('text')
|
||||
text_entities = MessageEntity.deserialize_array(raw_data.get('text_entities'))
|
||||
animation = Animation.deserialize(raw_data.get('animation'))
|
||||
|
||||
return Game(title, description, photo, text, text_entities, animation)
|
||||
Loading…
Add table
Add a link
Reference in a new issue