From d0b299ed172165b37140e4555021a93c028c31ee Mon Sep 17 00:00:00 2001 From: danny28506 Date: Sun, 12 Jan 2025 17:27:20 -0500 Subject: [PATCH] Script cloned from raspinoaa v2 github. --- push_discord.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 push_discord.sh diff --git a/push_discord.sh b/push_discord.sh new file mode 100644 index 0000000..2f4fb96 --- /dev/null +++ b/push_discord.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# +# Purpose: Send image and message to a Discord webhook URL that will post the data to a Discord channel. +# +# Input parameters: +# 1. Image +# 2. Message +# +# Example: +# ./scripts/push_processors/push_discord.sh /srv/images/NOAA-18-20210212-091356-MCIR.jpg "test" + +# import common lib and settings +. "$HOME/.noaa-v2.conf" +. "$NOAA_HOME/scripts/common.sh" + +# input params +DISCORD_WEBHOOK=$1 +IMAGE=$2 +MESSAGE=$3 + +# check that the file exists and is accessible +if [ -f "${IMAGE}" ]; then + log "Sending message to Discord webhook" "INFO" + push_log=$(curl -H "Content-Type: multipart/form-data" \ + -F file=@$IMAGE \ + -F "payload_json={\"content\":\"$MESSAGE\"}" \ + $DISCORD_WEBHOOK 2>&1) + log "${push_log}" "INFO" +else + log "Could not find or access image/attachment - not sending message to Discord" "ERROR" +fi