#!/usr/bin/env bash
set -euo pipefail

msg="$1"

# Apprise CLI
if command -v apprise >/dev/null 2>&1; then
    apprise -b "$msg" >/dev/null 2>&1 || true
fi

# Apprise API
if [[ -n "${APPRISE_API_URL:-}" ]]; then
    curl -s -X POST \
        -H "Content-Type: application/json" \
        -F "{\"body\":\"$msg\"}" \
        -F "tags=all" \
        "$APPRISE_API_URL" >/dev/null 2>&1 || true
fi
