Advertisement
Guest User

Untitled

a guest
Jul 14th, 2020
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. class UserProfilePhotos(JsonDeserializable):
  2. @classmethod
  3. def de_json(cls, json_string):
  4. if (json_string is None):
  5. return None
  6. obj = cls.check_json(json_string)
  7. total_count = obj['total_count']
  8. photos = [[PhotoSize.de_json(y) for y in x] for x in obj['photos']]
  9. return cls(total_count, photos)
  10.  
  11. def __init__(self, total_count, photos):
  12. self.total_count = total_count
  13. self.photos = photos
  14.  
  15. class PhotoSize(JsonDeserializable):
  16. @classmethod
  17. def de_json(cls, json_string):
  18. if (json_string is None): return None
  19. obj = cls.check_json(json_string)
  20. file_id = obj['file_id']
  21. width = obj['width']
  22. height = obj['height']
  23. file_size = obj.get('file_size')
  24. return cls(file_id, width, height, file_size)
  25.  
  26. def __init__(self, file_id, width, height, file_size=None):
  27. self.file_size = file_size
  28. self.height = height
  29. self.width = width
  30. self.file_id = file_id
  31.  
  32. def get_user_profile_photos(self, user_id, offset=None, limit=None):
  33. """
  34. Retrieves the user profile photos of the person with 'user_id'
  35. See https://core.telegram.org/bots/api#getuserprofilephotos
  36. :param user_id:
  37. :param offset:
  38. :param limit:
  39. :return: API reply.
  40. """
  41. result = apihelper.get_user_profile_photos(self.token, user_id, offset, limit)
  42. return types.UserProfilePhotos.de_json(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement