From e6e33bb434c8f75985ba1271b2f474aec7a08600 Mon Sep 17 00:00:00 2001 From: YeeChanKo Date: Mon, 6 Aug 2018 11:17:03 +0900 Subject: [PATCH] Fixed conditional branch in _file_to_media --- telethon/client/uploads.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/telethon/client/uploads.py b/telethon/client/uploads.py index 8bf3c48e..e0c2596f 100644 --- a/telethon/client/uploads.py +++ b/telethon/client/uploads.py @@ -393,18 +393,19 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods): file_handle = None as_image = utils.is_image(file) and not force_document use_cache = types.InputPhoto if as_image else types.InputDocument - if not isinstance(file, str): - file_handle = await self.upload_file( - file, progress_callback=progress_callback, - use_cache=use_cache if allow_cache else None - ) - elif re.match('https?://', file): + + if re.match('https?://', file): if as_image: media = types.InputMediaPhotoExternal(file) elif not force_document and utils.is_gif(file): media = types.InputMediaGifExternal(file, '') else: media = types.InputMediaDocumentExternal(file) + elif isinstance(file, str): + file_handle = await self.upload_file( + file, progress_callback=progress_callback, + use_cache=use_cache if allow_cache else None + ) else: bot_file = utils.resolve_bot_file_id(file) if bot_file: