diff --git a/harness/tg_inbox.py b/harness/tg_inbox.py index 3f4a9d1..3ae54a5 100644 --- a/harness/tg_inbox.py +++ b/harness/tg_inbox.py @@ -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)