tg_inbox: сохранять file_id/длительность голосовых и фото (нужно для транскрипции)

This commit is contained in:
Simbiot Harness 2026-09-29 17:12:47 +00:00
parent 728ebb86c0
commit 43e3c3b63b

View file

@ -73,6 +73,14 @@ def receive_message(update: dict):
kind = "document"
elif msg.get("animation"):
kind = "animation"
# file_id нужен, чтобы потом скачать файл (голосовое → транскрипция, фото → OCR)
file = (msg.get("voice") or msg.get("audio") or msg.get("document")
or msg.get("video") or msg.get("video_note") or {})
file_id = file.get("file_id")
duration = file.get("duration") or file.get("duration_seconds")
photo = msg.get("photo")
if photo and not file_id:
file_id = photo[-1].get("file_id") # самый большой размер
data = {
"update_id": update["update_id"],
"chat_id": chat.get("id"),
@ -81,6 +89,8 @@ def receive_message(update: dict):
"first_name": user.get("first_name"),
"text": (msg.get("text") or msg.get("caption") or "")[:4000],
"kind": kind,
"file_id": file_id,
"duration": duration,
"date": msg.get("date"),
}
es.append_event("inbox", f"m-{update['update_id']}", "MessageReceived", data)