Compare commits

..

No commits in common. "3463907670d4bac7bab76b79e8399edef27cc0d8" and "b827471e6de1a1e6c0b3018e42eca08e9ba04ba0" have entirely different histories.

4 changed files with 24 additions and 34 deletions

View file

@ -16,9 +16,17 @@ jobs:
source "$HOME/.cargo/env"
cargo build --release
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
run: |
cp ${{ github.workspace }}/target/release/teamspeak-query-lib /tmp/artifacts
cp ${{ github.workspace }}/ts-control /tmp/artifacts
shell: bash
- uses: https://code.forgejo.org/actions/forgejo-release@v1

2
Cargo.lock generated
View file

@ -182,7 +182,7 @@ dependencies = [
[[package]]
name = "teamspeak-query-lib"
version = "0.1.6"
version = "0.1.5"
dependencies = [
"clap",
"serde",

View file

@ -1,6 +1,6 @@
[package]
name = "teamspeak-query-lib"
version = "0.1.6"
version = "0.1.5"
edition = "2021"
[dependencies]

View file

@ -46,16 +46,12 @@ _ts_control_fetch() {
}
_ts_control_single_or_dmenu() {
filter="$2"
if [ "$filter" == "^$" ]; then
filter=""
fi
options=$(echo "$1" | grep "$filter")
options=$(echo "$1" | grep "$2")
count=$(echo "$options" | wc -l)
if [ "$count" -eq 1 ]; then
echo "$options"
else
echo "$1" | $DMENU
echo "$options" | $DMENU
fi
}
@ -64,7 +60,6 @@ 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"
@ -72,44 +67,31 @@ handle_ntfy_events() {
continue # Skip all messages that are not direct messages
fi
title="TS3 Event"
friendly_type="Event"
case $type in
"NotifyClientPoke")
title="TS3 Poke"
friendly_type="Poke"
;;
"NotifyTextMessage")
title="TS3 Message"
friendly_type="Message"
;;
esac
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
}]
}')
echo "($friendly_type) $target: $msg"
curl -sSL \
-H "Authorization: Bearer $TS3_NTFY_TOKEN" \
-d "$payload" \
-d "{
\"topic\": \"$TS3_NTFY_TOPIC\",
\"message\": \"$msg\",
\"title\": \"TS3 $friendly_type\"
}" \
"$TS3_NTFY_HOST"
done
}
action=$(_ts_control_single_or_dmenu "$actions" "^$1$")
# Add '$' to $1 to add 'End of line' to the regex for grep
action=$(_ts_control_single_or_dmenu "$actions" "$1$")
case $action in
"quick")