diff --git a/mautrix_telegram/portal_util/message_convert.py b/mautrix_telegram/portal_util/message_convert.py index f7aa5532..3652c26e 100644 --- a/mautrix_telegram/portal_util/message_convert.py +++ b/mautrix_telegram/portal_util/message_convert.py @@ -237,10 +237,12 @@ def _caption_to_message(converted: ConvertedMessage) -> None: content["format"] = Format.HTML.value def _get_external_url(self, evt: Message) -> str | None: - if self.portal.peer_type == "chat": - return f"https://t.me/c/{self.portal.tgid}/{evt.id}" - if self.portal.username is not None: + if self.portal.peer_type == "channel" and self.portal.username is not None: return f"https://t.me/{self.portal.username}/{evt.id}" + elif self.portal.peer_type != "user": + return f"https://t.me/c/{self.portal.tgid}/{evt.id}" + else: + return f"https://t.me/{self.portal.tgid}/{evt.id}" return None @staticmethod