- Marked shrimp_data subproject as dirty - Added pre-tool hook configuration to settings.local.json
42 lines
1.2 KiB
Bash
Executable File
42 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Telegram 메시지 발송 공통 유틸리티
|
|
# 사용법: notify_telegram.sh "메시지 본문"
|
|
#
|
|
# 필요 환경변수:
|
|
# TELEGRAM_BOT_TOKEN - BotFather 발급 토큰
|
|
# TELEGRAM_CHAT_ID - 알림을 받을 채팅 ID
|
|
|
|
set -euo pipefail
|
|
|
|
# 환경변수 미설정 시 .env 파일에서 로드 (Claude Code 훅 실행 환경 대응)
|
|
ENV_FILE="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)/.env"
|
|
if [[ -f "$ENV_FILE" ]]; then
|
|
# export 구문을 포함한 .env 파일 소싱
|
|
set -a
|
|
# shellcheck source=/dev/null
|
|
source "$ENV_FILE"
|
|
set +a
|
|
fi
|
|
|
|
TELEGRAM_BOT_TOKEN="${TELEGRAM_BOT_TOKEN:-}"
|
|
TELEGRAM_CHAT_ID="${TELEGRAM_CHAT_ID:-}"
|
|
MESSAGE="${1:-}"
|
|
|
|
# 환경변수 미설정 시 조용히 종료 (훅 실패로 Claude 작업 중단 방지)
|
|
if [[ -z "$TELEGRAM_BOT_TOKEN" || -z "$TELEGRAM_CHAT_ID" ]]; then
|
|
exit 0
|
|
fi
|
|
|
|
if [[ -z "$MESSAGE" ]]; then
|
|
exit 0
|
|
fi
|
|
|
|
curl -s -X POST \
|
|
"https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \
|
|
-H "Content-Type: application/json" \
|
|
-d "$(jq -n \
|
|
--argjson chat_id "$TELEGRAM_CHAT_ID" \
|
|
--arg text "$MESSAGE" \
|
|
'{chat_id: $chat_id, text: $text, parse_mode: "Markdown"}')" \
|
|
> /dev/null
|