Auto backup: 2026-02-21 07:01
This commit is contained in:
@@ -11,8 +11,9 @@ LOG_FILE="$SCRIPT_DIR/reminder-log.json"
|
||||
source "$SCRIPT_DIR/../../.env" 2>/dev/null || true
|
||||
|
||||
TELEGRAM_CHAT="${TELEGRAM_CHAT:-1793951355}"
|
||||
GOTIFY_URL="${GOTIFY_URL:-http://runtipi.kangaroo-eel.ts.net:8129}"
|
||||
GOTIFY_TOKEN="${GOTIFY_TOKEN:-AGKnHafW3FGzBlt}"
|
||||
NTFY_URL="${NTFY_URL:-}"
|
||||
NTFY_TOPIC="${NTFY_TOPIC:-}"
|
||||
NTFY_MIN_PRIORITY="${NTFY_MIN_PRIORITY:-4}"
|
||||
|
||||
log() {
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
|
||||
@@ -167,20 +168,29 @@ send_telegram() {
|
||||
}
|
||||
}
|
||||
|
||||
# Send Gotify message
|
||||
send_gotify() {
|
||||
# Send ntfy message
|
||||
send_ntfy() {
|
||||
local title="$1"
|
||||
local message="$2"
|
||||
local priority="${3:-5}"
|
||||
|
||||
curl -s -X POST "${GOTIFY_URL}/message?token=${GOTIFY_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"title\": \"$title\",
|
||||
\"message\": \"$message\",
|
||||
\"priority\": $priority
|
||||
}" > /dev/null || {
|
||||
log "ERROR: Failed to send Gotify message"
|
||||
local priority="${3:-4}"
|
||||
local sound="${4:-default}"
|
||||
|
||||
[[ -z "$NTFY_URL" ]] && return 0
|
||||
[[ -z "$NTFY_TOPIC" ]] && return 0
|
||||
|
||||
# Enforce minimum priority (default 4)
|
||||
if [[ "$priority" =~ ^[0-9]+$ ]] && [[ "$NTFY_MIN_PRIORITY" =~ ^[0-9]+$ ]]; then
|
||||
if (( priority < NTFY_MIN_PRIORITY )); then
|
||||
priority="$NTFY_MIN_PRIORITY"
|
||||
fi
|
||||
fi
|
||||
|
||||
curl -s -X POST "${NTFY_URL%/}/${NTFY_TOPIC}" \
|
||||
-H "Title: $title" \
|
||||
-H "Priority: $priority" \
|
||||
-H "Sound: $sound" \
|
||||
-d "$message" > /dev/null 2>&1 || {
|
||||
log "ERROR: Failed to send ntfy message"
|
||||
return 1
|
||||
}
|
||||
}
|
||||
@@ -269,12 +279,12 @@ check_birthdays() {
|
||||
log "Sending $reminder_type reminder for $name"
|
||||
send_telegram "$message"
|
||||
|
||||
# Also send to Gotify (strip markdown for cleaner display)
|
||||
# Also send to ntfy (strip markdown for cleaner display)
|
||||
local plain_message
|
||||
plain_message=$(echo -e "$message" | sed 's/\*//g')
|
||||
local priority=5
|
||||
[[ "$reminder_type" == "today" ]] && priority=8
|
||||
send_gotify "Birthday: $name" "$plain_message" "$priority"
|
||||
send_ntfy "Birthday: $name" "$plain_message" "$priority" default
|
||||
|
||||
log_reminder "$name" "$reminder_type"
|
||||
((reminders_sent++))
|
||||
|
||||
@@ -12,8 +12,9 @@ source "$SCRIPT_DIR/../../.env" 2>/dev/null || true
|
||||
ICAL_URL="${GOOGLE_CALENDAR_ICAL:-https://calendar.google.com/calendar/ical/anthonymau%40gmail.com/private-3636d9c51e7beda202676124684619ad/basic.ics}"
|
||||
BIRTHDAY_DATA="$SCRIPT_DIR/../birthday-tracker/birthdays.json"
|
||||
TELEGRAM_CHAT="${TELEGRAM_CHAT:-1793951355}"
|
||||
GOTIFY_URL="${GOTIFY_URL:-http://runtipi.kangaroo-eel.ts.net:8129}"
|
||||
GOTIFY_TOKEN="${GOTIFY_TOKEN:-AGKnHafW3FGzBlt}"
|
||||
NTFY_URL="${NTFY_URL:-}"
|
||||
NTFY_TOPIC="${NTFY_TOPIC:-}"
|
||||
NTFY_MIN_PRIORITY="${NTFY_MIN_PRIORITY:-4}"
|
||||
TEMP_ICS="/tmp/gcal-birthdays.ics"
|
||||
|
||||
log() {
|
||||
@@ -135,10 +136,14 @@ merge_birthdays() {
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"chat_id\": \"$TELEGRAM_CHAT\", \"text\": \"$message\", \"parse_mode\": \"Markdown\"}" > /dev/null || true
|
||||
|
||||
# Gotify
|
||||
curl -s -X POST "${GOTIFY_URL}/message?token=${GOTIFY_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"title\": \"Birthday Sync\", \"message\": \"Added $count new birthdays from Google Calendar: $names\", \"priority\": 5}" > /dev/null || true
|
||||
# ntfy
|
||||
if [[ -n "${NTFY_URL:-}" && -n "${NTFY_TOPIC:-}" ]]; then
|
||||
curl -s -X POST "${NTFY_URL%/}/${NTFY_TOPIC}" \
|
||||
-H "Title: Birthday Sync" \
|
||||
-H "Priority: ${NTFY_MIN_PRIORITY:-4}" \
|
||||
-H "Sound: default" \
|
||||
-d "Added $count new birthdays from Google Calendar: $names" > /dev/null 2>&1 || true
|
||||
fi
|
||||
}
|
||||
|
||||
# Show current stats
|
||||
|
||||
Reference in New Issue
Block a user