Compare commits
2 commits
b827471e6d
...
3463907670
Author | SHA1 | Date | |
---|---|---|---|
3463907670 | |||
fb1e41ddc4 |
4 changed files with 34 additions and 24 deletions
|
@ -16,17 +16,9 @@ jobs:
|
||||||
source "$HOME/.cargo/env"
|
source "$HOME/.cargo/env"
|
||||||
cargo build --release
|
cargo build --release
|
||||||
shell: bash
|
shell: bash
|
||||||
- uses: https://code.forgejo.org/actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: teamspeak-query-lib
|
|
||||||
path: ${{ github.workspace }}/target/release/teamspeak-query-lib
|
|
||||||
- uses: https://code.forgejo.org/actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: teamspeak-query-lib
|
|
||||||
path: /tmp/artifacts
|
|
||||||
shell: bash
|
|
||||||
- id: copy-ts-control-artificat
|
- id: copy-ts-control-artificat
|
||||||
run: |
|
run: |
|
||||||
|
cp ${{ github.workspace }}/target/release/teamspeak-query-lib /tmp/artifacts
|
||||||
cp ${{ github.workspace }}/ts-control /tmp/artifacts
|
cp ${{ github.workspace }}/ts-control /tmp/artifacts
|
||||||
shell: bash
|
shell: bash
|
||||||
- uses: https://code.forgejo.org/actions/forgejo-release@v1
|
- uses: https://code.forgejo.org/actions/forgejo-release@v1
|
||||||
|
|
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -182,7 +182,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "teamspeak-query-lib"
|
name = "teamspeak-query-lib"
|
||||||
version = "0.1.5"
|
version = "0.1.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "teamspeak-query-lib"
|
name = "teamspeak-query-lib"
|
||||||
version = "0.1.5"
|
version = "0.1.6"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
44
ts-control
44
ts-control
|
@ -46,12 +46,16 @@ _ts_control_fetch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_ts_control_single_or_dmenu() {
|
_ts_control_single_or_dmenu() {
|
||||||
options=$(echo "$1" | grep "$2")
|
filter="$2"
|
||||||
|
if [ "$filter" == "^$" ]; then
|
||||||
|
filter=""
|
||||||
|
fi
|
||||||
|
options=$(echo "$1" | grep "$filter")
|
||||||
count=$(echo "$options" | wc -l)
|
count=$(echo "$options" | wc -l)
|
||||||
if [ "$count" -eq 1 ]; then
|
if [ "$count" -eq 1 ]; then
|
||||||
echo "$options"
|
echo "$options"
|
||||||
else
|
else
|
||||||
echo "$options" | $DMENU
|
echo "$1" | $DMENU
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,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"
|
||||||
|
|
||||||
|
@ -67,31 +72,44 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
# 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$")
|
|
||||||
|
|
||||||
case $action in
|
case $action in
|
||||||
"quick")
|
"quick")
|
||||||
|
|
Loading…
Reference in a new issue