sh.zio.notify: add file support
parent
a9cfc4824b
commit
2948a24fe8
|
@ -5,20 +5,11 @@ _PLUG_DESCRIPTION=""
|
||||||
_PLUG_ARGS=(
|
_PLUG_ARGS=(
|
||||||
"message;m;;string;(No Message)"
|
"message;m;;string;(No Message)"
|
||||||
"title;t;;string;(No Title)"
|
"title;t;;string;(No Title)"
|
||||||
|
"file;f;;path"
|
||||||
"level;l;;string;info"
|
"level;l;;string;info"
|
||||||
"invoked-by;i;;string"
|
"invoked-by;i;;string"
|
||||||
)
|
)
|
||||||
|
|
||||||
function get_cache_header() {
|
|
||||||
topic="$1"
|
|
||||||
|
|
||||||
if [[ "$topic" == "zio_test" ]]; then
|
|
||||||
echo ""
|
|
||||||
else
|
|
||||||
echo "Cache: no"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_level_emoji() {
|
function get_level_emoji() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"critical"|"error") echo "⛔" ;;
|
"critical"|"error") echo "⛔" ;;
|
||||||
|
@ -75,11 +66,28 @@ function main() {
|
||||||
"topic": "'$n_topic'"
|
"topic": "'$n_topic'"
|
||||||
}'
|
}'
|
||||||
|
|
||||||
curl -d "$body" \
|
curl_command="curl -d \"$body\""
|
||||||
-H "Authorization: Bearer $token" \
|
curl_command+=" -H \"Authorization: Bearer $token\""
|
||||||
-H "$(get_cache_header "$n_topic")" \
|
curl_command+=" -H \"Markdown: yes\""
|
||||||
-H "Markdown: yes" \
|
|
||||||
"https://ntfy.zio.sh/"
|
if [[ "$n_topic" == "zio_test" ]]; then
|
||||||
|
curl_command+=" -H \"Cache: no\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$_file" != "" ]]; then
|
||||||
|
if [[ ! -f "$_file" ]]; then
|
||||||
|
die "Cannot attach '$_file': file does not exist"
|
||||||
|
fi
|
||||||
|
|
||||||
|
full_file="$(realpath -s "$_file")"
|
||||||
|
|
||||||
|
curl_command+=" -T \"$full_file\""
|
||||||
|
curl_command+=" -H \"Filename: $(basename "$full_file")\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl_command+=" https://ntfy.zio.sh/"
|
||||||
|
|
||||||
|
echo $curl_command
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $_PLUG_INVOKED != "true" ]]; then
|
if [[ $_PLUG_INVOKED != "true" ]]; then
|
||||||
|
|
Loading…
Reference in New Issue