#!/bin/bash -eu title="$1" message="$2" function send_pushover () { log "Sending Pushover message." curl -F "token=$PUSHOVER_APP_KEY" \ -F "user=$PUSHOVER_USER_KEY" \ -F "title=$title" \ -F "message=$message" \ https://api.pushover.net/1/messages } function send_gotify () { log "Sending Gotify message." curl -X POST \ -F "title=$title" \ -F "message=$message" \ -F "priority=$GOTIFY_PRIORITY" \ "$GOTIFY_DOMAIN/message?token=$GOTIFY_APP_TOKEN" } function send_ifttt () { log "Sending IFTTT message." curl -X POST -H "Content-Type: application/json" -d \ '{"value1":"'"$title"'","value2":"'"$message"'"}' \ "https://maker.ifttt.com/trigger/$IFTTT_EVENT_NAME/with/key/$IFTTT_KEY" } function send_sns () { log "Sending SNS message." python3 /root/bin/send_sns.py -t "$AWS_SNS_TOPIC_ARN" -s "$title" -m "$message" } function send_matrix() { log "Send Matrix message." python3 /root/bin/send_matrix.py "$MATRIX_SERVER_URL" "$MATRIX_USERNAME" "$MATRIX_PASSWORD" "$MATRIX_ROOM" "$message" } function send_telegram () { log "Sending Telegram message." curl -v -H "Content-Type: application/json" -d \ '{"chat_id": "'"$TELEGRAM_CHAT_ID"'", "text": "'"$title $message"'", "disable_notification": '"$TELEGRAM_SILENT_NOTIFY"' }' \ https://api.telegram.org/"$TELEGRAM_BOT_TOKEN"/sendMessage } function send_webhook () { log "Sending Webhook message." curl -X POST \ -d "{\"value1\":\"${title}\",\"value2\":\"${message}\"}" \ -H "Content-Type: application/json" \ "$WEBHOOK_URL" } log "$message" [ "${PUSHOVER_ENABLED:-false}" = "true" ] && send_pushover [ "${GOTIFY_ENABLED:-false}" = "true" ] && send_gotify [ "${IFTTT_ENABLED:-false}" = "true" ] && send_ifttt [ "${SNS_ENABLED:-false}" = "true" ] && send_sns [ "${WEBHOOK_ENABLED:-false}" = "true" ] && send_webhook [ "${TELEGRAM_ENABLED:-false}" = "true" ] && send_telegram [ "${MATRIX_ENABLED:-false}" = "true" ] && send_matrix exit 0