From c8f1ef57415c17c1726ba417cb85d0ddea47ad86 Mon Sep 17 00:00:00 2001 From: profitroll Date: Tue, 29 Nov 2022 10:37:06 +0100 Subject: [PATCH] Improved avatars preview a bit --- modules/inline.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/inline.py b/modules/inline.py index 97e1309..395fa1b 100644 --- a/modules/inline.py +++ b/modules/inline.py @@ -53,7 +53,9 @@ async def inline_answer(client, inline_query): if match.user.photo != None: try: - await app.download_media(match.user.photo.big_file_id, file_name=f'{configGet("cache", "locations")}{sep}avatars{sep}{match.user.photo.big_file_id}') + if not path.exists(f'{configGet("cache", "locations")}{sep}avatars{sep}{match.user.photo.big_file_id}'): + print(f'Downloaded avatar {match.user.photo.big_file_id} of {match.user.id} and uploaded to {configGet("api")}/?avatar_id={match.user.photo.big_file_id}', flush=True) + await app.download_media(match.user.photo.big_file_id, file_name=f'{configGet("cache", "locations")}{sep}avatars{sep}{match.user.photo.big_file_id}') results.append( InlineQueryResultArticle( title=str(match.user.first_name), @@ -64,7 +66,6 @@ async def inline_answer(client, inline_query): thumb_url=f'{configGet("api")}/?avatar_id={match.user.photo.big_file_id}' ) ) - print(f'{configGet("api")}/?avatar_id={match.user.photo.big_file_id}', flush=True) except ValueError: results.append( InlineQueryResultArticle(