diff --git a/mautrix_telegram/formatter/from_telegram.py b/mautrix_telegram/formatter/from_telegram.py
index d2269d90..4e886a3c 100644
--- a/mautrix_telegram/formatter/from_telegram.py
+++ b/mautrix_telegram/formatter/from_telegram.py
@@ -20,7 +20,7 @@ from typing import Optional, List, Tuple
try:
from lxml.html.diff import htmldiff
except ImportError:
- htmldiff = None
+ htmldiff = None # type: function
import logging
import re
@@ -89,9 +89,10 @@ async def _add_forward_header(source, text: str, html: Optional[str],
fwd_from_text = "Unknown source"
fwd_from_html = f"{fwd_from_text}"
- text = f"Forwarded from {fwd_from}:\n{text}"
+ text = "\n".join([f"> {line}" for line in text.split("\n")])
+ text = f"Forwarded from {fwd_from_text}:\n{text}"
html = (f"Forwarded message from {fwd_from_html}
"
- f"
{html}") + f"
") return text, html @@ -142,9 +143,9 @@ async def _add_reply_header(source: u.User, text: str, html: str, evt: Message, if is_edit and should_highlight_edits: html = highlight_edits(html or escape(text), r_html_body) - except (ValueError, KeyError, MatrixRequestError): + except (ValueError, KeyError, MatrixRequestError) as e: r_sender_link = "unknown user" - # r_sender = "unknown user" + r_displayname = "unknown user" r_text_body = "Failed to fetch message" r_html_body = "Failed to fetch message" diff --git a/mautrix_telegram/formatter/util.py b/mautrix_telegram/formatter/util.py index f10146b4..3b91a527 100644 --- a/mautrix_telegram/formatter/util.py +++ b/mautrix_telegram/formatter/util.py @@ -45,7 +45,10 @@ def trim_reply_fallback_text(text: str) -> str: return "\n".join(lines) -html_reply_fallback_regex = re.compile(r"^{html}
[\s\S]+?") +html_reply_fallback_regex = re.compile("^
" + r"[\s\S]+?" + "()?" + "") def trim_reply_fallback_html(html: str) -> str: