python-telegram-bot/telegram/userprofilephotos.py

36 lines
967 B
Python
Raw Normal View History

2015-07-08 15:10:08 +02:00
#!/usr/bin/env python
2015-07-20 12:53:58 +02:00
from telegram import TelegramObject
2015-07-09 16:40:44 +02:00
class UserProfilePhotos(TelegramObject):
2015-07-09 02:58:13 +02:00
def __init__(self,
total_count,
photos):
self.total_count = total_count
self.photos = photos
2015-07-08 15:10:08 +02:00
@staticmethod
def de_json(data):
2015-07-08 15:10:08 +02:00
if 'photos' in data:
from telegram import PhotoSize
photos = []
for photo in data['photos']:
photos.append([PhotoSize.de_json(x) for x in photo])
2015-07-08 15:10:08 +02:00
else:
photos = None
2015-07-08 15:10:08 +02:00
return UserProfilePhotos(total_count=data.get('total_count', None),
photos=photos)
2015-07-09 16:40:44 +02:00
def to_dict(self):
data = {}
2015-07-09 16:40:44 +02:00
if self.total_count:
data['total_count'] = self.total_count
2015-07-09 16:40:44 +02:00
if self.photos:
data['photos'] = []
2015-07-09 16:40:44 +02:00
for photo in self.photos:
data['photos'].append([x.to_dict() for x in photo])
return data