Add response option to ntfy
This commit is contained in:
parent
fb1e41ddc4
commit
3463907670
1 changed files with 24 additions and 9 deletions
33
ts-control
33
ts-control
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue