Ignore avatar download errors

This commit is contained in:
Tulir Asokan
2018-01-28 22:04:54 +02:00
parent ec5a75c0c6
commit 6a8b1ce91d
2 changed files with 10 additions and 3 deletions
+5 -1
View File
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re
from telethon.tl.types import UserProfilePhoto
from telethon.errors.rpc_error_list import LocationInvalidError
from .db import Puppet as DBPuppet
config = None
@@ -105,7 +106,10 @@ class Puppet:
def update_avatar(self, source, photo):
photo_id = f"{photo.volume_id}-{photo.local_id}"
if self.photo_id != photo_id:
file = source.download_file(photo)
try:
file = source.download_file(photo)
except LocationInvalidError:
return False
uploaded = self.intent.upload_file(file)
self.intent.set_avatar(uploaded["content_uri"])
self.photo_id = photo_id