From 8354bf6bb51ef7d6b9d592d85fd8b62a07e379be Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 29 Apr 2018 23:07:37 +0300 Subject: [PATCH] Send gif stickers as-is rather than converting to webp. Fixes #132 --- mautrix_telegram/portal.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mautrix_telegram/portal.py b/mautrix_telegram/portal.py index 7c70582f..a0cd9cc5 100644 --- a/mautrix_telegram/portal.py +++ b/mautrix_telegram/portal.py @@ -716,12 +716,17 @@ class Portal: info = message.get("info", {}) mime = info.get("mimetype", None) + w, h = None, None + if type == "m.sticker": - mime, file, w, h = util.convert_image(file, source_mime=mime, target_type="webp") + if mime != "image/gif": + mime, file, w, h = util.convert_image(file, source_mime=mime, target_type="webp") + else: + # Remove sticker description + message["mxtg_filename"] = "sticker.gif" + message["body"] = "" elif "w" in info and "h" in info: w, h = info["w"], info["h"] - else: - w, h = None, None file_name = self._get_file_meta(message["mxtg_filename"], mime)