feat(agent-office): notification broadcast + telegram tracking + activity feed API
- Add WebSocket notification messages for task_assigned/task_completed - Structure telegram send_message return value with ok/message_id - Track telegram delivery status in task result_data - Add test_telegram command to stock agent - Add GET /api/agent-office/activity unified feed endpoint Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,15 +22,24 @@ class StockAgent(BaseAgent):
|
||||
|
||||
summary = self._format_news_summary(news, indices)
|
||||
|
||||
update_task_status(task_id, "succeeded", {
|
||||
"summary": summary,
|
||||
"news_count": len(news) if isinstance(news, list) else 0,
|
||||
})
|
||||
|
||||
await self.transition("reporting", "뉴스 요약 전송 중...")
|
||||
|
||||
from ..telegram_bot import send_stock_summary
|
||||
await send_stock_summary(summary)
|
||||
tg_result = await send_stock_summary(summary)
|
||||
|
||||
update_task_status(task_id, "succeeded", {
|
||||
"summary": summary,
|
||||
"news_count": len(news) if isinstance(news, list) else 0,
|
||||
"telegram_sent": tg_result.get("ok", False),
|
||||
"telegram_message_id": tg_result.get("message_id"),
|
||||
})
|
||||
|
||||
if not tg_result.get("ok"):
|
||||
add_log(self.agent_id, "Telegram send failed", "warning", task_id)
|
||||
if self._ws_manager:
|
||||
await self._ws_manager.send_notification(
|
||||
self.agent_id, "telegram_failed", task_id, "텔레그램 전송 실패"
|
||||
)
|
||||
|
||||
await self.transition("idle", "뉴스 요약 완료")
|
||||
|
||||
@@ -40,6 +49,15 @@ class StockAgent(BaseAgent):
|
||||
await self.transition("idle", f"오류: {e}")
|
||||
|
||||
async def on_command(self, command: str, params: dict) -> dict:
|
||||
if command == "test_telegram":
|
||||
from ..telegram_bot import send_message
|
||||
result = await send_message("🔔 [주식 에이전트] 텔레그램 테스트 메시지입니다.")
|
||||
return {
|
||||
"ok": result.get("ok", False),
|
||||
"message": "텔레그램 전송 성공" if result.get("ok") else "텔레그램 전송 실패",
|
||||
"telegram_message_id": result.get("message_id"),
|
||||
}
|
||||
|
||||
if command == "fetch_news":
|
||||
await self.on_schedule()
|
||||
return {"ok": True, "message": "뉴스 수집 시작"}
|
||||
|
||||
Reference in New Issue
Block a user