def backup_propic(self):
"""Backups the profile picture for the given
entity as the current peer profile picture, returning its path"""
# Allow multiple versions of the profile picture
# TODO Maybe this should be another method, because when downloading media... We also have multiple versions
filename = self.media_handler.get_propic_path(self.entity, allow_multiple=True)
generic_filename = self.media_handler.get_propic_path(self.entity)
if filename: # User may not have a profile picture
if not isfile(filename):
# Only download the file if it doesn't exist yet
self.client.download_profile_photo(self.entity.photo,
file_path=filename,
add_extension=False)
# If we downloaded a new version, copy it to the "default" generic file
if isfile(generic_filename):
remove(generic_filename)
shutil.copy(filename, generic_filename)
# The user may not have a profile picture
return generic_filename
评论列表
文章目录