support WEBP

This commit is contained in:
io mintz 2020-05-18 02:03:31 +00:00
parent fcc1f405e3
commit 7e5f01b82d
2 changed files with 4 additions and 2 deletions

View File

@ -60,14 +60,14 @@ class FileTooBigError(EmoteManagerError):
self.limit = limit
class InvalidFileError(EmoteManagerError):
"""The file is not a zip, tar, GIF, PNG, or JPG file."""
"""The file is not a zip, tar, GIF, PNG, JPG, or WEBP file."""
def __init__(self):
super().__init__('Invalid file given.')
class InvalidImageError(InvalidFileError):
"""The image is not a GIF, PNG, or JPG"""
def __init__(self):
super(Exception, self).__init__('The image supplied was not a GIF, PNG, or JPG.')
super(Exception, self).__init__('The image supplied was not a GIF, PNG, JPG, or WEBP file.')
class PermissionDeniedError(EmoteManagerError):
"""Raised when a user tries to modify an emote without the Manage Emojis permission"""

View File

@ -87,6 +87,8 @@ def mime_type_for_image(data):
return 'image/jpeg'
if data.startswith((b'GIF87a', b'GIF89a')):
return 'image/gif'
if data.startswith(b'RIFF') and data[8:12] == b'WEBP':
return 'image/webp'
raise errors.InvalidImageError
def image_to_base64_url(data):