From f15443df7a64608783a9569338022f4bc0ab0ea6 Mon Sep 17 00:00:00 2001 From: BadStorm Developer Date: Sat, 5 Sep 2026 17:09:30 +0200 Subject: [PATCH] feat(talkbot): preserve text messages and reply with translations --- containers/talkbot/server.py | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/containers/talkbot/server.py b/containers/talkbot/server.py index 483e673..2b927df 100644 --- a/containers/talkbot/server.py +++ b/containers/talkbot/server.py @@ -1241,9 +1241,9 @@ def process_event(job: dict) -> None: preserve_original = job.get("preserve_original", False) reply_to_message_id = job.get("reply_to_message_id") - # A caption attached to an image is not itself an inReplyTo event. In - # that case the translation must reply to the image message itself. - if preserve_original and reply_to_message_id is None: + # Text translations always reply to the message being translated. This + # also covers captions and text messages that were themselves replies. + if message_text: reply_to_message_id = message_id try: @@ -1326,25 +1326,10 @@ def process_event(job: dict) -> None: if not translations: return - if preserve_original: - log.info( - "Preserving original message %s because it has a non-audio attachment", - message_id, - ) - else: - deleted = delete_message( - token, - message_id, - ) - - if not deleted: - log.warning( - "Original message %s was not deleted. " - "Generated translations will not be posted " - "to avoid confusing duplicates.", - message_id, - ) - return + log.info( + "Preserving original text message %s and posting translations as replies", + message_id, + ) for recipient, target_language, translated in translations: post_manager_message(