summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/reaktor2-plugins/scripts/tell-on_join.sh
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-01-11 20:55:04 +0100
committertv <tv@krebsco.de>2026-01-11 20:55:04 +0100
commit114a129b977863db2cba719fca1e213f518ca3b1 (patch)
treeb029c1ee96dc160c9c6f0e3ab623e4707de70c74 /krebs/5pkgs/simple/reaktor2-plugins/scripts/tell-on_join.sh
parentf60ccbad0558542b0a803c6947f98f393facad1e (diff)
parent68d3c925b0edb958fcbafa589d35967dfb2a979c (diff)
Merge remote-tracking branch 'krebs/master'HEADmaster
Diffstat (limited to 'krebs/5pkgs/simple/reaktor2-plugins/scripts/tell-on_join.sh')
-rwxr-xr-xkrebs/5pkgs/simple/reaktor2-plugins/scripts/tell-on_join.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/krebs/5pkgs/simple/reaktor2-plugins/scripts/tell-on_join.sh b/krebs/5pkgs/simple/reaktor2-plugins/scripts/tell-on_join.sh
new file mode 100755
index 000000000..6978e38c6
--- /dev/null
+++ b/krebs/5pkgs/simple/reaktor2-plugins/scripts/tell-on_join.sh
@@ -0,0 +1,25 @@
+#! /bin/sh
+set -euf
+
+# require flock from util-linux (pkgs.util-linux)
+if test "${FLOCK-}" != "$state_file"; then
+ exec env FLOCK="$state_file" flock "$state_file" "$0" "$@"
+fi
+
+# TODO tell now, if already joined
+jq -r <"$state_file" \
+ --arg to "$_from" \
+ --arg msgtarget "$_msgtarget" \
+ '
+ select(.to == $to and .msgtarget == $msgtarget) |
+ "\(.to): \(.text) \u00032-- \(.from)\u00032 \(.date)"
+ '
+
+jq -c <"$state_file" >"$state_file.tmp" \
+ --arg to "$_from" \
+ --arg msgtarget "$_msgtarget" \
+ '
+ select((.to == $to and .msgtarget == $msgtarget) | not)
+ '
+
+mv "$state_file.tmp" "$state_file"