diff --git a/example-config.yaml b/example-config.yaml index 71b91ee0..e32da570 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -148,7 +148,7 @@ bridge: - "@importantbot:example.com" # Whether to bridge Telegram bot messages as m.notices or m.texts. bot_messages_as_notices: true - # Use inline images instead of m.image to make rich captions possible. + # Use inline images instead of a separate message for the caption. # N.B. Inline images are not supported on all clients (e.g. Riot iOS). inline_images: false # Whether to send stickers as the new native m.sticker type or normal m.images. diff --git a/mautrix_telegram/portal.py b/mautrix_telegram/portal.py index e62b5ab7..1f8c1525 100644 --- a/mautrix_telegram/portal.py +++ b/mautrix_telegram/portal.py @@ -1243,11 +1243,19 @@ class Portal: "orientation": 0, "mimetype": file.mime_type, } - name = evt.message + ext_override = { + "image/jpeg": ".jpg" + } + name = "image" + ext_override.get(file.mime_type, mimetypes.guess_extension(file.mime_type)) await intent.set_typing(self.mxid, is_typing=False) - return await intent.send_image(self.mxid, file.mxc, info=info, text=name, - relates_to=relates_to, timestamp=evt.date, - external_url=self.get_external_url(evt)) + result = await intent.send_image(self.mxid, file.mxc, info=info, text=name, + relates_to=relates_to, timestamp=evt.date, + external_url=self.get_external_url(evt)) + if evt.message: + text, html, _ = await formatter.telegram_to_matrix(evt, source, self.main_intent) + await intent.send_text(self.mxid, text, html=html, timestamp=evt.date, + external_url=self.get_external_url(evt)) + return result @staticmethod def _parse_telegram_document_attributes(attributes: List[TypeDocumentAttribute]) -> Dict: