[2026-05-15] Discord 알림 중복 발송 수정
- 커밋 없는 세션(스케줄러 태스크 등)은 알림 생략 - commit + push 완료 후 1회만 발송 - push 안된 경우 경고 메시지 포함 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+16
-10
@@ -3,27 +3,33 @@ import subprocess, json, urllib.request, datetime, sys, pathlib
|
||||
WEBHOOK = "https://discord.com/api/webhooks/1504705352166543370/H3dhs_4LaxnaFj_mhUUi02qpk3JegE_Ji9C6rNpEqRNv_iW6aqvso8VyPw17048Nt0oF"
|
||||
|
||||
def run(cmd):
|
||||
return subprocess.run(cmd, capture_output=True, text=True, encoding='utf-8', errors='replace').stdout.strip()
|
||||
r = subprocess.run(cmd, capture_output=True, text=True, encoding='utf-8', errors='replace')
|
||||
return r.stdout.strip(), r.returncode
|
||||
|
||||
SESSION_SHA_FILE = pathlib.Path('.claude/session_start_sha.txt')
|
||||
start_sha = SESSION_SHA_FILE.read_text().strip() if SESSION_SHA_FILE.exists() else ''
|
||||
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
|
||||
|
||||
# 이번 세션 커밋 메시지
|
||||
if start_sha:
|
||||
messages = run(['git', 'log', '--pretty=format:%s', f'{start_sha}..HEAD'])
|
||||
messages, _ = run(['git', 'log', '--pretty=format:%s', f'{start_sha}..HEAD'])
|
||||
else:
|
||||
messages = run(['git', 'log', '--pretty=format:%s', '-5'])
|
||||
messages, _ = run(['git', 'log', '--pretty=format:%s', '-5'])
|
||||
|
||||
parts = [f"**[Claude Code] {now}**"]
|
||||
# 커밋 없으면 조용히 종료 (스케줄러 태스크 등 노이즈 방지)
|
||||
if not messages.strip():
|
||||
sys.exit(0)
|
||||
|
||||
# push 상태 확인
|
||||
unpushed, _ = run(['git', 'log', '--oneline', 'origin/master..HEAD'])
|
||||
if unpushed:
|
||||
push_status = "⚠️ Push 안됨 — 수동으로 push 필요"
|
||||
else:
|
||||
push_status = "✅ Commit + Push 완료"
|
||||
|
||||
if messages:
|
||||
bullets = '\n'.join(f"• {m}" for m in messages.splitlines() if m.strip())
|
||||
parts.append(f"**변경 내용:**\n{bullets}")
|
||||
parts.append("✅ 커밋 완료")
|
||||
else:
|
||||
parts.append("_이번 세션 커밋 없음_")
|
||||
msg = f"**[Claude Code] {now}**\n\n**변경 내용:**\n{bullets}\n\n{push_status}"
|
||||
|
||||
msg = '\n\n'.join(parts)
|
||||
if len(msg) > 1990:
|
||||
msg = msg[:1987] + '...'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user