From b867b8ce134f9762f160123759edc29084e039a2 Mon Sep 17 00:00:00 2001 From: gahusb Date: Wed, 15 Apr 2026 00:49:55 +0900 Subject: [PATCH] =?UTF-8?q?feat(agent-office):=20=EC=95=84=EC=B9=A8=20?= =?UTF-8?q?=EC=8B=9C=EC=9E=A5=20=EB=B8=8C=EB=A6=AC=ED=95=91=20=EC=95=84?= =?UTF-8?q?=EB=82=B4=20=ED=85=94=EB=A0=88=EA=B7=B8=EB=9E=A8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EC=A0=84=EC=86=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - TELEGRAM_WIFE_CHAT_ID 환경변수 추가 (빈 값이면 비활성) - send_raw()에 chat_id override 파라미터 추가 - 주식 에이전트 브리핑 전송 후, 아내 chat에 제목+본문만 간결 포맷으로 추가 전송 (기술 메타데이터/버튼 없음, 읽기 전용) NAS .env에 TELEGRAM_WIFE_CHAT_ID 추가 필요. Co-Authored-By: Claude Opus 4.6 --- agent-office/app/agents/stock.py | 10 ++++++++++ agent-office/app/config.py | 1 + agent-office/app/telegram/messaging.py | 6 +++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/agent-office/app/agents/stock.py b/agent-office/app/agents/stock.py index c59bd4a..87934d8 100644 --- a/agent-office/app/agents/stock.py +++ b/agent-office/app/agents/stock.py @@ -37,6 +37,16 @@ class StockAgent(BaseAgent): }, ) + # 아내 chat 추가 전송 (설정된 경우) — 제목 + 본문만 간결하게 + from ..config import TELEGRAM_WIFE_CHAT_ID + if TELEGRAM_WIFE_CHAT_ID: + from ..telegram.messaging import send_raw + wife_text = f"📈 아침 시장 브리핑\n\n{result['summary']}" + wife_result = await send_raw(wife_text, chat_id=TELEGRAM_WIFE_CHAT_ID) + if not wife_result.get("ok"): + desc = wife_result.get("description") or "unknown" + add_log(self.agent_id, f"Wife telegram send failed: {desc}", "warning", task_id) + update_task_status(task_id, "succeeded", { "summary": result["summary"], "article_count": result.get("article_count", 0), diff --git a/agent-office/app/config.py b/agent-office/app/config.py index d113807..ddede7a 100644 --- a/agent-office/app/config.py +++ b/agent-office/app/config.py @@ -10,6 +10,7 @@ REALESTATE_LAB_URL = os.getenv("REALESTATE_LAB_URL", "http://localhost:18800") TELEGRAM_BOT_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN", "") TELEGRAM_CHAT_ID = os.getenv("TELEGRAM_CHAT_ID", "") TELEGRAM_WEBHOOK_URL = os.getenv("TELEGRAM_WEBHOOK_URL", "") +TELEGRAM_WIFE_CHAT_ID = os.getenv("TELEGRAM_WIFE_CHAT_ID", "") # Database DB_PATH = os.getenv("AGENT_OFFICE_DB_PATH", "/app/data/agent_office.db") diff --git a/agent-office/app/telegram/messaging.py b/agent-office/app/telegram/messaging.py index 75dfb4d..49a3ee6 100644 --- a/agent-office/app/telegram/messaging.py +++ b/agent-office/app/telegram/messaging.py @@ -8,12 +8,12 @@ from .client import _enabled, api_call from .formatter import MessageKind, format_agent_message -async def send_raw(text: str, reply_markup: Optional[dict] = None) -> dict: - """가장 저수준. 원문 텍스트 그대로 전송.""" +async def send_raw(text: str, reply_markup: Optional[dict] = None, chat_id: Optional[str] = None) -> dict: + """가장 저수준. 원문 텍스트 그대로 전송. chat_id 생략 시 기본 TELEGRAM_CHAT_ID로.""" if not _enabled(): return {"ok": False, "message_id": None} payload = { - "chat_id": TELEGRAM_CHAT_ID, + "chat_id": chat_id or TELEGRAM_CHAT_ID, "text": text, "parse_mode": "HTML", }