python-telegram-bot/telegram/userprofilephotos.py
2015-07-20 08:25:04 -03:00

35 lines
967 B
Python

#!/usr/bin/env python
from telegram import TelegramObject
class UserProfilePhotos(TelegramObject):
def __init__(self,
total_count,
photos):
self.total_count = total_count
self.photos = photos
@staticmethod
def de_json(data):
if 'photos' in data:
from telegram import PhotoSize
photos = []
for photo in data['photos']:
photos.append([PhotoSize.de_json(x) for x in photo])
else:
photos = None
return UserProfilePhotos(total_count=data.get('total_count', None),
photos=photos)
def to_data(self):
data = {}
if self.total_count:
data['total_count'] = self.total_count
if self.photos:
data['photos'] = []
for photo in self.photos:
data['photos'].append([x.to_data() for x in photo])
return data