Add response option to ntfy

This commit is contained in:
Tobias Reisinger 2024-10-27 18:55:08 +01:00
parent fb1e41ddc4
commit 3463907670
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE

View file

@ -64,6 +64,7 @@ handle_ntfy_events() {
msg=$(echo "$data" | jq -r --unbuffered '.message')
type=$(echo "$data" | jq -r --unbuffered '.type')
mode=$(echo "$data" | jq -r --unbuffered '.params.targetmode')
client_nickname=$(echo "$data" | jq -r --unbuffered '.client.client_nickname')
echo "$data"
@ -71,25 +72,39 @@ handle_ntfy_events() {
continue # Skip all messages that are not direct messages
fi
friendly_type="Event"
title="TS3 Event"
case $type in
"NotifyClientPoke")
friendly_type="Poke"
title="TS3 Poke"
;;
"NotifyTextMessage")
friendly_type="Message"
title="TS3 Message"
;;
esac
echo "($friendly_type) $target: $msg"
echo "($title) $target: $msg"
payload=$(jq -n \
--arg topic "$TS3_NTFY_TOPIC" \
--arg webhook "$TS3_NTFY_WEBHOOK&client=$client_nickname" \
--arg msg "$msg" \
--arg type "$title" \
'{
topic: $topic,
message: $msg,
title: $type,
actions: [{
action: "http",
label: "TS response",
method: "POST",
url: $webhook,
clear: true
}]
}')
curl -sSL \
-H "Authorization: Bearer $TS3_NTFY_TOKEN" \
-d "{
\"topic\": \"$TS3_NTFY_TOPIC\",
\"message\": \"$msg\",
\"title\": \"TS3 $friendly_type\"
}" \
-d "$payload" \
"$TS3_NTFY_HOST"
done
}