feat(talkbot): preserve text messages and reply with translations
Этот коммит содержится в:
@@ -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(
|
||||
|
||||
Ссылка в новой задаче
Block a user