From 1eeedc613b406d1c27cc5a0e28c6e23efd5cf552 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Mon, 19 Feb 2018 15:29:32 +0100 Subject: [PATCH] Fix sending byte strings as files not working --- telethon/utils.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/telethon/utils.py b/telethon/utils.py index 2f27b79e..643fa746 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -323,17 +323,19 @@ def get_input_media(media, user_caption=None, is_photo=False): def is_image(file): """Returns True if the file extension looks like an image file""" - return (mimetypes.guess_type(file)[0] or '').startswith('image/') - + return (isinstance(file, str) and + (mimetypes.guess_type(file)[0] or '').startswith('image/')) def is_audio(file): """Returns True if the file extension looks like an audio file""" - return (mimetypes.guess_type(file)[0] or '').startswith('audio/') + return (isinstance(file, str) and + (mimetypes.guess_type(file)[0] or '').startswith('audio/')) def is_video(file): """Returns True if the file extension looks like a video file""" - return (mimetypes.guess_type(file)[0] or '').startswith('video/') + return (isinstance(file, str) and + (mimetypes.guess_type(file)[0] or '').startswith('video/')) def parse_phone(phone):