This commit is contained in:
parent
915c2ccbbf
commit
b827471e6d
2 changed files with 43 additions and 1 deletions
|
@ -294,6 +294,7 @@ impl Serialize for Event {
|
||||||
x.serialize_field("type", &self.event_type)?;
|
x.serialize_field("type", &self.event_type)?;
|
||||||
x.serialize_field("channel", &self.channel)?;
|
x.serialize_field("channel", &self.channel)?;
|
||||||
x.serialize_field("client", &self.client)?;
|
x.serialize_field("client", &self.client)?;
|
||||||
|
x.serialize_field("params", &self.params)?;
|
||||||
x.serialize_field("message", &self.get_message())?;
|
x.serialize_field("message", &self.get_message())?;
|
||||||
x.end()
|
x.end()
|
||||||
}
|
}
|
||||||
|
|
43
ts-control
43
ts-control
|
@ -9,7 +9,8 @@ not away
|
||||||
back
|
back
|
||||||
message
|
message
|
||||||
message-user
|
message-user
|
||||||
events"
|
events
|
||||||
|
ntfy-events"
|
||||||
|
|
||||||
_ts_control_get_entity() {
|
_ts_control_get_entity() {
|
||||||
entity=$(_ts_control_single_or_dmenu "$(teamspeak-query-lib "$1s")" "$2")
|
entity=$(_ts_control_single_or_dmenu "$(teamspeak-query-lib "$1s")" "$2")
|
||||||
|
@ -54,6 +55,41 @@ _ts_control_single_or_dmenu() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handle_ntfy_events() {
|
||||||
|
while read -r data; do
|
||||||
|
msg=$(echo "$data" | jq -r --unbuffered '.message')
|
||||||
|
type=$(echo "$data" | jq -r --unbuffered '.type')
|
||||||
|
mode=$(echo "$data" | jq -r --unbuffered '.params.targetmode')
|
||||||
|
|
||||||
|
echo "$data"
|
||||||
|
|
||||||
|
if [ "$type" = "NotifyTextMessage" ] && [ "$mode" != "1" ]; then
|
||||||
|
continue # Skip all messages that are not direct messages
|
||||||
|
fi
|
||||||
|
|
||||||
|
friendly_type="Event"
|
||||||
|
case $type in
|
||||||
|
"NotifyClientPoke")
|
||||||
|
friendly_type="Poke"
|
||||||
|
;;
|
||||||
|
"NotifyTextMessage")
|
||||||
|
friendly_type="Message"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "($friendly_type) $target: $msg"
|
||||||
|
|
||||||
|
curl -sSL \
|
||||||
|
-H "Authorization: Bearer $TS3_NTFY_TOKEN" \
|
||||||
|
-d "{
|
||||||
|
\"topic\": \"$TS3_NTFY_TOPIC\",
|
||||||
|
\"message\": \"$msg\",
|
||||||
|
\"title\": \"TS3 $friendly_type\"
|
||||||
|
}" \
|
||||||
|
"$TS3_NTFY_HOST"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# Add '$' to $1 to add 'End of line' to the regex for grep
|
# Add '$' to $1 to add 'End of line' to the regex for grep
|
||||||
action=$(_ts_control_single_or_dmenu "$actions" "$1$")
|
action=$(_ts_control_single_or_dmenu "$actions" "$1$")
|
||||||
|
|
||||||
|
@ -102,4 +138,9 @@ case $action in
|
||||||
teamspeak-query-lib events --filter=others NotifyClientMoved NotifyClientEnterView NotifyClientLeftView NotifyTextMessage NotifyClientPoke \
|
teamspeak-query-lib events --filter=others NotifyClientMoved NotifyClientEnterView NotifyClientLeftView NotifyTextMessage NotifyClientPoke \
|
||||||
| jq -r --unbuffered '.message' \
|
| jq -r --unbuffered '.message' \
|
||||||
| tee >(xargs -I{} notify-send "TS3 Event" "{}")
|
| tee >(xargs -I{} notify-send "TS3 Event" "{}")
|
||||||
|
;;
|
||||||
|
"ntfy-events")
|
||||||
|
teamspeak-query-lib events --filter=others NotifyClientPoke NotifyTextMessage \
|
||||||
|
| handle_ntfy_events
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in a new issue