Feat: [2.0.5] 에러 발생 시 Discord 알림 전송
Some checks failed
news-summary-bot-cicd / build_push_deploy (push) Failing after 3m42s

- 요약 처리 중 에러 발생 시 Discord에 에러 상세 내용 전송
- 에러 타입, 메시지, 영상 정보를 포함한 embed 형식

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
sm4640
2026-03-24 16:27:03 +09:00
parent 11852bf48c
commit af0e2fca8a
2 changed files with 37 additions and 6 deletions

View File

@@ -107,3 +107,29 @@ async def send_to_discord(title: str, video_url: str, summary: str) -> None:
async with httpx.AsyncClient() as client:
resp = await client.post(settings.discord_webhook_url, json=payload)
resp.raise_for_status()
async def send_error_to_discord(
title: str, video_url: str, error: Exception
) -> None:
"""에러 발생 시 Discord 웹훅으로 에러 내용 전송."""
error_type = type(error).__name__
error_msg = str(error)[:1024]
embed = {
"title": "❌ 뉴스 요약 실패",
"color": 0xED4245,
"fields": [
{"name": "영상 제목", "value": title or "(제목 없음)", "inline": False},
{"name": "영상 URL", "value": video_url, "inline": False},
{"name": "에러 타입", "value": f"`{error_type}`", "inline": True},
{"name": "에러 내용", "value": f"```\n{error_msg}\n```", "inline": False},
],
"footer": {"text": "YouTube 뉴스 요약 봇 - 에러 알림"},
"timestamp": datetime.now(timezone.utc).isoformat(),
}
payload = {"embeds": [embed]}
async with httpx.AsyncClient() as client:
await client.post(settings.discord_webhook_url, json=payload)