diff --git a/example-config.yaml b/example-config.yaml
index e481784a..0addff2f 100644
--- a/example-config.yaml
+++ b/example-config.yaml
@@ -40,10 +40,11 @@ bridge:
displayname_template: "{displayname} (Telegram)"
# Set the preferred order of user identifiers which to use in the Matrix puppet display name.
- # In the (hopefully unlikely) scenario that none of the given keys are found, the numeric user ID is used.
+ # In the (hopefully unlikely) scenario that none of the given keys are found, the numeric user
+ # ID is used.
#
- # If the bridge is working properly, a phone number or an username should always be known, but the other one can
- # very well be empty.
+ # If the bridge is working properly, a phone number or an username should always be known, but
+ # the other one can very well be empty.
#
# Valid keys:
# "full name" (First and/or last name)
@@ -57,6 +58,9 @@ bridge:
- username
- phone number
+ # 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
# The prefix for commands. Only required in non-management rooms.
command_prefix: "!tg"
@@ -67,7 +71,8 @@ bridge:
- "internal-hs.example.com"
- "@user:public.example.com"
- # Admins can do things like delete portal rooms.
+ # Admins can do things like delete portal rooms. Here you must specify the exact MXID, domains
+ # are not accepted.
admins:
- "@admin:internal-hs.example.com"
diff --git a/mautrix_appservice/intent_api.py b/mautrix_appservice/intent_api.py
index f4d3fde5..b9c61121 100644
--- a/mautrix_appservice/intent_api.py
+++ b/mautrix_appservice/intent_api.py
@@ -275,6 +275,10 @@ class IntentAPI:
events.remove(event_id)
self.set_pinned_messages(room_id, events)
+ def get_event(self, room_id, event_id):
+ self.ensure_joined(room_id)
+ return self.client._send("GET", f"/rooms/{room_id}/event/{event_id}")
+
def set_typing(self, room_id, is_typing=True, timeout=5000):
self.ensure_joined(room_id)
return self.client.set_typing(room_id, is_typing, timeout)
diff --git a/mautrix_telegram/formatter.py b/mautrix_telegram/formatter.py
index 030f72aa..d2f74b9c 100644
--- a/mautrix_telegram/formatter.py
+++ b/mautrix_telegram/formatter.py
@@ -20,6 +20,8 @@ from collections import deque
import re
import logging
+from matrix_client.errors import MatrixRequestError
+
from telethon.tl.types import *
from . import user as u, puppet as p
@@ -194,7 +196,7 @@ def matrix_to_telegram(html, tg_space=None):
# endregion
# region Telegram to Matrix
-def telegram_event_to_matrix(evt, source):
+def telegram_event_to_matrix(evt, source, native_replies=False, main_intent=None):
text = evt.message
html = telegram_to_matrix(evt.message, evt.entities) if evt.entities else None
@@ -225,7 +227,17 @@ def telegram_event_to_matrix(evt, source):
PeerChannel) else source.tgid
msg = DBMessage.query.get((evt.reply_to_msg_id, space))
if msg:
- quote = f"Quote
"
+ if native_replies:
+ quote = f"Quote
"
+ else:
+ 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}" + except (ValueError, KeyError, MatrixRequestError): + quote = "Reply to someone (failed to fetch message)