@@ -1419,3 +1419,80 @@ def __init__(self, id, audio_file_id, reply_markup=None, input_message_content=N
14191419 self .reply_markup = reply_markup
14201420 self .input_message_content = input_message_content
14211421 self .payload_dic ['audio_file_id' ] = audio_file_id
1422+
1423+
1424+ # Games
1425+
1426+ class Game (JsonDeserializable ):
1427+ @classmethod
1428+ def de_json (cls , json_string ):
1429+ obj = cls .check_json (json_string )
1430+ title = obj ['title' ]
1431+ description = obj ['description' ]
1432+ photo = Game .parse_photo (obj ['photo' ])
1433+ text = obj .get ('text' )
1434+ text_entities = None
1435+ if 'text_entities' in obj :
1436+ text_entities = Game .parse_entities (obj ['text_entities' ])
1437+ animation = None
1438+ if 'animation' in obj :
1439+ animation = Animation .de_json (obj ['animation' ])
1440+ return cls (title , description , photo , text , text_entities , animation )
1441+
1442+ @classmethod
1443+ def parse_photo (cls , photo_size_array ):
1444+ ret = []
1445+ for ps in photo_size_array :
1446+ ret .append (PhotoSize .de_json (ps ))
1447+ return ret
1448+
1449+ @classmethod
1450+ def parse_entities (cls , message_entity_array ):
1451+ ret = []
1452+ for me in message_entity_array :
1453+ ret .append (MessageEntity .de_json (me ))
1454+ return ret
1455+
1456+ def __init__ (self , title , description , photo , text = None , text_entities = None , animation = None ):
1457+ self .title = title
1458+ self .description = description
1459+ self .photo = photo
1460+ self .text = text
1461+ self .text_entities = text_entities
1462+ self .animation = animation
1463+
1464+
1465+ class Animation (JsonDeserializable ):
1466+ @classmethod
1467+ def de_json (cls , json_string ):
1468+ obj = cls .check_json (json_string )
1469+ file_id = obj ['file_id' ]
1470+ thumb = None
1471+ if 'thumb' in obj :
1472+ thumb = PhotoSize .de_json (obj ['thumb' ])
1473+ file_name = obj .get ('file_name' )
1474+ mime_type = obj .get ('mime_type' )
1475+ file_size = obj .get ('file_size' )
1476+ return cls (file_id , thumb , file_name , mime_type , file_size )
1477+
1478+ def __init__ (self , file_id , thumb = None , file_name = None , mime_type = None , file_size = None ):
1479+ self .file_id = file_id
1480+ self .thumb = thumb
1481+ self .file_name = file_name
1482+ self .mime_type = mime_type
1483+ self .file_size = file_size
1484+
1485+
1486+ class GameHighScore (JsonDeserializable ):
1487+ @classmethod
1488+ def de_json (cls , json_string ):
1489+ obj = cls .check_json (json_string )
1490+ position = obj ['position' ]
1491+ user = User .de_json (obj ['user' ])
1492+ score = obj ['score' ]
1493+ return cls (position , user , score )
1494+
1495+ def __init__ (self , position , user , score ):
1496+ self .position = position
1497+ self .user = user
1498+ self .score = score
0 commit comments