#!/bin/bash -eu TITLE="$1" MESSAGE="$2" function send_pushover () { log "Sending Pushover message." source /root/.teslaCamPushoverCredentials # shellcheck disable=SC2154 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." source /root/.teslaCamGotifySettings # shellcheck disable=SC2154 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." source /root/.teslaCamIftttSettings # shellcheck disable=SC2154 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." source /root/.teslaCamSNSTopicARN # shellcheck disable=SC2154 python3 /root/bin/send_sns.py -t "$sns_topic_arn" -s "$TITLE" -m "$MESSAGE" } function send_telegram () { if [ -n "${TELEGRAM_ENABLED+x}" ] then 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 fi } function send_webhook () { log "Sending Webhook message." source /root/.teslaCamWebhookSettings # shellcheck disable=SC2154 curl -X POST \ -d "{\"value1\":\"${TITLE}\",\"value2\":\"${MESSAGE}\"}" \ -H "Content-Type: application/json" \ "$WEBHOOK_URL" } log "$MESSAGE" [ -r "/root/.teslaCamPushoverCredentials" ] && send_pushover [ -r "/root/.teslaCamGotifySettings" ] && send_gotify [ -r "/root/.teslaCamIftttSettings" ] && send_ifttt [ -r "/root/.teslaCamSNSTopicARN" ] && send_sns [ -r "/root/.teslaCamWebhookSettings" ] && send_webhook send_telegram