Skip to content

Commit 3b7578e

Browse files
committed
debug process forwarded message
1 parent 901c57a commit 3b7578e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/app/telegram/payloads/single.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ def escape_markdown(text: str) -> str:
88
return re.sub(f"([{re.escape(escape_chars)}])", r"\\\1", text)
99

1010

11+
def make_clickable_forwarded_text(original_channel: str, text: str) -> str:
12+
escaped_text = escape_markdown(text)
13+
escaped_channel = escape_markdown(original_channel)
14+
return f"[🔁 Weitergeleitet von @{escaped_channel}](https://t.me/{original_channel})\n\n{escaped_text}"
15+
16+
1117
def process_photo_payload(post):
1218
photo = max(post.get("photo", []), key=lambda p: p["file_size"])
1319
return {
@@ -42,11 +48,10 @@ def process_text_payload(post):
4248
def process_forwarded_payload(post):
4349
original_channel = post["chat"].get("username", "Quelle")
4450
text = post.get("text", "")
45-
final_text = f"*🔁 Weitergeleitet von @{escape_markdown(original_channel)}:*\n\n{escape_markdown(text)}"
4651
return {
4752
"chat_id": TARGET_CHAT_ID,
4853
"from_chat_id": post["chat"]["id"],
49-
"text": final_text,
54+
"text": make_clickable_forwarded_text(original_channel, text),
5055
"parse_mode": "MarkdownV2",
5156
"disable_web_page_preview": True,
5257
}

0 commit comments

Comments
 (0)