[2026-05-15] 스케줄러 인코딩·권한·Discord 알림 수정
- run_*.ps1: PSScriptRoot 경로, claude.cmd 전체경로, UTF-8 BOM 저장으로 한글 깨짐 해결 - settings.json: PYTHONUTF8=1 환경변수, 글로벌 bypassPermissions 추가 - discord_notify.py: 커밋 메시지 불릿 + 커밋 완료 여부만 전송하도록 간소화 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+18
-25
@@ -1,45 +1,38 @@
|
||||
import subprocess, json, urllib.request, datetime, sys
|
||||
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()
|
||||
|
||||
import pathlib
|
||||
|
||||
SESSION_SHA_FILE = pathlib.Path('.claude/session_start_sha.txt')
|
||||
|
||||
# 세션 시작 시 저장된 HEAD와 비교해 이번 세션 커밋만 표시
|
||||
start_sha = SESSION_SHA_FILE.read_text().strip() if SESSION_SHA_FILE.exists() else ''
|
||||
if start_sha:
|
||||
log = run(['git', 'log', '--oneline', f'{start_sha}..HEAD'])
|
||||
else:
|
||||
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 start_sha:
|
||||
messages = run(['git', 'log', '--pretty=format:%s', f'{start_sha}..HEAD'])
|
||||
else:
|
||||
messages = run(['git', 'log', '--pretty=format:%s', '-5'])
|
||||
|
||||
if log:
|
||||
parts.append(f"```\n{log}\n```")
|
||||
elif not status and not diff_stat:
|
||||
parts.append("_이번 세션 변경사항 없음_")
|
||||
parts = [f"**[Claude Code] {now}**"]
|
||||
|
||||
if status or diff_stat:
|
||||
combined = '\n'.join(filter(None, [status, diff_stat]))
|
||||
parts.append(f"**미커밋 변경:**\n```\n{combined}\n```")
|
||||
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("_이번 세션 커밋 없음_")
|
||||
|
||||
if len(parts) == 1:
|
||||
parts.append("_변경사항 없음_")
|
||||
|
||||
msg = '\n'.join(parts)
|
||||
msg = '\n\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')
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user