[2026-05-15] Discord Stop 훅 추가 및 notifier User-Agent 수정

- .claude/discord_notify.py: 세션 종료 시 git log/status를 Discord로 전송
- .claude/settings.json: Stop 훅 등록
- notifier.py: Cloudflare 차단 방지를 위해 User-Agent 헤더 추가
- .gitignore: settings.local.json 제외

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-15 13:49:10 +09:00
parent b61e1bec7f
commit de37f0642c
4 changed files with 51 additions and 2 deletions
+34
View File
@@ -0,0 +1,34 @@
import subprocess, json, urllib.request, datetime, sys
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()
log = run(['git', 'log', '--oneline', '-5'])
status = run(['git', 'status', '--short'])
diff_stat = run(['git', 'diff', '--stat'])
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
parts = [f"**[Claude Code 작업완료] {now}**"]
if log:
parts.append(f"```\n{log}\n```")
if status or diff_stat:
combined = '\n'.join(filter(None, [status, diff_stat]))
parts.append(f"**미커밋 변경:**\n```\n{combined}\n```")
if len(parts) == 1:
parts.append("_변경사항 없음_")
msg = '\n'.join(parts)
if len(msg) > 1990:
msg = msg[:1987] + '...'
data = json.dumps({'content': msg}).encode('utf-8')
req = urllib.request.Request(WEBHOOK, data=data, headers={'Content-Type': 'application/json', 'User-Agent': 'DiscordBot (stockbot, 1.0)'}, method='POST')
try:
urllib.request.urlopen(req)
except Exception as e:
print(f"Discord notify failed: {e}", file=sys.stderr)
+14 -1
View File
@@ -1,4 +1,17 @@
{
"dangerouslySkipPermissions": true,
"instructions": "코드만 출력, 설명은 주석으로. 수정은 변경된 함수/diff 단위만. 답변 마지막에 1줄 요약. 상세 설명은 요청 시에만. 수정 후 반드시 git commit/push."
"instructions": "코드만 출력, 설명은 주석으로. 수정은 변경된 함수/diff 단위만. 답변 마지막에 1줄 요약. 상세 설명은 요청 시에만. 수정 후 반드시 git commit/push.",
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "python .claude/discord_notify.py",
"timeout": 30
}
]
}
]
}
}