fix(phase34): polling loop 補圖片路由 — _handle_chat_message photo handler
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled
text=None 時直接 return,導致圖片訊息被丟棄 在 text 檢查前插入 photo 路由,呼叫 image_analysis_service Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3542,6 +3542,26 @@ class TelegramGateway:
|
||||
message_id = message.get("message_id")
|
||||
username = user.get("username") or user.get("first_name") or str(user_id)
|
||||
|
||||
# Phase 34 (ADR-067 2026-04-10): 圖片訊息路由
|
||||
photos = message.get("photo")
|
||||
if photos and user_id:
|
||||
if not user.get("is_bot"):
|
||||
best = max(photos, key=lambda p: p.get("file_size", 0))
|
||||
file_id = best.get("file_id", "")
|
||||
caption = message.get("caption", "請用繁體中文描述這張圖片")
|
||||
if file_id:
|
||||
try:
|
||||
from src.services.image_analysis_service import get_image_analysis_service
|
||||
svc = get_image_analysis_service()
|
||||
await svc.download_and_analyze(
|
||||
chat_id=str(chat_id),
|
||||
file_id=file_id,
|
||||
question=caption,
|
||||
)
|
||||
except Exception as _img_err:
|
||||
logger.warning("image_analysis_polling_failed", error=str(_img_err))
|
||||
return
|
||||
|
||||
if not text or not user_id:
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user