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')
|
msg=$(echo "$data" | jq -r --unbuffered '.message')
|
||||||
type=$(echo "$data" | jq -r --unbuffered '.type')
|
type=$(echo "$data" | jq -r --unbuffered '.type')
|
||||||
mode=$(echo "$data" | jq -r --unbuffered '.params.targetmode')
|
mode=$(echo "$data" | jq -r --unbuffered '.params.targetmode')
|
||||||
|
client_nickname=$(echo "$data" | jq -r --unbuffered '.client.client_nickname')
|
||||||
|
|
||||||
echo "$data"
|
echo "$data"
|
||||||
|
|
||||||
|
@ -71,25 +72,39 @@ handle_ntfy_events() {
|
||||||
continue # Skip all messages that are not direct messages
|
continue # Skip all messages that are not direct messages
|
||||||
fi
|
fi
|
||||||
|
|
||||||
friendly_type="Event"
|
title="TS3 Event"
|
||||||
case $type in
|
case $type in
|
||||||
"NotifyClientPoke")
|
"NotifyClientPoke")
|
||||||
friendly_type="Poke"
|
title="TS3 Poke"
|
||||||
;;
|
;;
|
||||||
"NotifyTextMessage")
|
"NotifyTextMessage")
|
||||||
friendly_type="Message"
|
title="TS3 Message"
|
||||||
;;
|
;;
|
||||||
esac
|
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 \
|
curl -sSL \
|
||||||
-H "Authorization: Bearer $TS3_NTFY_TOKEN" \
|
-H "Authorization: Bearer $TS3_NTFY_TOKEN" \
|
||||||
-d "{
|
-d "$payload" \
|
||||||
\"topic\": \"$TS3_NTFY_TOPIC\",
|
|
||||||
\"message\": \"$msg\",
|
|
||||||
\"title\": \"TS3 $friendly_type\"
|
|
||||||
}" \
|
|
||||||
"$TS3_NTFY_HOST"
|
"$TS3_NTFY_HOST"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue