def update_profile_avatar(self, profile: Profile, user_id): response = self.requests.get('getUserProfilePhotos', {'user_id': user_id}) photos = response.json()['result']['photos'] if len(photos) == 0: raise PWarning("Нет фотографий в профиле") pa = PhotoAttachment() pa.parse_tg_photo(photos[0][-1], self) profile.set_avatar(pa.private_download_url)
def setup_photo(self, photo_event): tg_photo = PhotoAttachment() tg_photo.parse_tg_photo(photo_event, self.bot) self.attachments.append(tg_photo)