diff --git a/example-config.yaml b/example-config.yaml index 0addff2f..6a117c89 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -60,7 +60,13 @@ bridge: # Whether or not to use native Matrix replies. At the time of writing, only riot-web supports # replies and the format of them is subject to change. - native_replies: False + native_replies: True + # If native replies are disabled, should the custom replies contain a link to the message being + # replied to? + # + # Warning: Using this on a client with native replies will not look good: the message will have + # a native quote AND a non-native quote. + link_in_reply: False # The prefix for commands. Only required in non-management rooms. command_prefix: "!tg" diff --git a/mautrix_telegram/formatter.py b/mautrix_telegram/formatter.py index d2f74b9c..8b0d7577 100644 --- a/mautrix_telegram/formatter.py +++ b/mautrix_telegram/formatter.py @@ -196,7 +196,8 @@ def matrix_to_telegram(html, tg_space=None): # endregion # region Telegram to Matrix -def telegram_event_to_matrix(evt, source, native_replies=False, main_intent=None): +def telegram_event_to_matrix(evt, source, native_replies=False, message_link_in_reply=False, + main_intent=None): text = evt.message html = telegram_to_matrix(evt.message, evt.entities) if evt.entities else None @@ -233,11 +234,17 @@ def telegram_event_to_matrix(evt, source, native_replies=False, main_intent=None try: event = main_intent.get_event(msg.mx_room, msg.mxid) content = event["content"] - body = content["formatted_body"] if "formatted_body" in content else content["body"] - reply_to = f"event['sender']" - quote = f"Reply to {reply_to}
{body}" + body = (content["formatted_body"] + if "formatted_body" in content + else content["body"]) + reply_to_user = ("{event['sender']}") + reply_to_msg = (("Reply") + if message_link_in_reply else "Reply") + quote = f"{reply_to_msg} to {reply_to_user}
{body}" except (ValueError, KeyError, MatrixRequestError): - quote = "Reply to someone (failed to fetch message)