From 768d51c4ae8c245d4a55045d2ff41d362d151137 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 19 Aug 2023 12:09:03 +0300 Subject: [PATCH] Add fallback message for invoices --- mautrix_telegram/portal_util/message_convert.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mautrix_telegram/portal_util/message_convert.py b/mautrix_telegram/portal_util/message_convert.py index ec37d957..3a239ac4 100644 --- a/mautrix_telegram/portal_util/message_convert.py +++ b/mautrix_telegram/portal_util/message_convert.py @@ -42,6 +42,7 @@ from telethon.tl.types import ( MessageMediaGame, MessageMediaGeo, MessageMediaGeoLive, + MessageMediaInvoice, MessageMediaPhoto, MessageMediaPoll, MessageMediaStory, @@ -145,6 +146,7 @@ class TelegramMessageConverter: MessageMediaGame: self._convert_game, MessageMediaContact: self._convert_contact, MessageMediaStory: self._convert_story, + MessageMediaInvoice: self._convert_invoice, } self._allowed_media = tuple(self._media_converters.keys()) @@ -716,6 +718,17 @@ class TelegramMessageConverter: content["fi.mau.telegram.unsupported"] = True return ConvertedMessage(content=content) + @staticmethod + async def _convert_invoice( + source: au.AbstractUser, evt: Message, client: MautrixTelegramClient, **_ + ) -> ConvertedMessage: + content = await formatter.telegram_to_matrix( + evt, source, client, override_text="Invoices are not yet supported" + ) + content.msgtype = MessageType.NOTICE + content["fi.mau.telegram.unsupported"] = True + return ConvertedMessage(content=content) + def _parse_document_attributes(attributes: list[TypeDocumentAttribute]) -> DocAttrs: name, mime_type, is_sticker, sticker_alt, width, height = None, None, False, None, 0, 0