mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-03-03 19:00:21 +03:00
Fix Telegram only recognises 3 image filetypes
This commit is contained in:
parent
423f0f366c
commit
45b7318f08
|
@ -4,10 +4,11 @@ to convert between an entity like an User, Chat, etc. into its Input version)
|
||||||
"""
|
"""
|
||||||
import math
|
import math
|
||||||
import mimetypes
|
import mimetypes
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import types
|
import types
|
||||||
from collections import UserList
|
from collections import UserList
|
||||||
from mimetypes import add_type, guess_extension
|
from mimetypes import guess_extension
|
||||||
|
|
||||||
from .tl.types import (
|
from .tl.types import (
|
||||||
Channel, ChannelForbidden, Chat, ChatEmpty, ChatForbidden, ChatFull,
|
Channel, ChannelForbidden, Chat, ChatEmpty, ChatForbidden, ChatFull,
|
||||||
|
@ -315,11 +316,13 @@ def get_input_media(media, is_photo=False):
|
||||||
|
|
||||||
|
|
||||||
def is_image(file):
|
def is_image(file):
|
||||||
"""Returns True if the file extension looks like an image file"""
|
"""
|
||||||
|
Returns True if the file extension looks like an image file to Telegram.
|
||||||
|
"""
|
||||||
if not isinstance(file, str):
|
if not isinstance(file, str):
|
||||||
return False
|
return False
|
||||||
mime = mimetypes.guess_type(file)[0] or ''
|
_, ext = os.path.splitext(file)
|
||||||
return mime.startswith('image/') and not mime.endswith('/webp')
|
return re.match(r'\.(png|jpe?g|gif)', ext, re.IGNORECASE)
|
||||||
|
|
||||||
|
|
||||||
def is_audio(file):
|
def is_audio(file):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user