summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/Reaktor/scripts
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2021-09-28 22:48:17 +0200
committertv <tv@krebsco.de>2021-09-28 22:48:17 +0200
commited2c6bd9792afbc433ae4eb23f40e17b90420f99 (patch)
tree289de32dd7f58f46accf7ad25ed184db5aa45198 /krebs/5pkgs/simple/Reaktor/scripts
parent20e358043546482acfa8c6134f095c1a64ef144d (diff)
parente151cfd3298120ec541987d4beb155e18335a0d8 (diff)
Merge remote-tracking branch 'prism/master'
Diffstat (limited to 'krebs/5pkgs/simple/Reaktor/scripts')
-rwxr-xr-xkrebs/5pkgs/simple/Reaktor/scripts/tell-on_join.sh25
-rwxr-xr-xkrebs/5pkgs/simple/Reaktor/scripts/tell-on_privmsg.sh18
2 files changed, 43 insertions, 0 deletions
diff --git a/krebs/5pkgs/simple/Reaktor/scripts/tell-on_join.sh b/krebs/5pkgs/simple/Reaktor/scripts/tell-on_join.sh
new file mode 100755
index 000000000..c21dc8776
--- /dev/null
+++ b/krebs/5pkgs/simple/Reaktor/scripts/tell-on_join.sh
@@ -0,0 +1,25 @@
+#! /bin/sh
+set -euf
+
+# require flock from util-linux (pkgs.utillinux)
+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"
diff --git a/krebs/5pkgs/simple/Reaktor/scripts/tell-on_privmsg.sh b/krebs/5pkgs/simple/Reaktor/scripts/tell-on_privmsg.sh
new file mode 100755
index 000000000..fc05bdefb
--- /dev/null
+++ b/krebs/5pkgs/simple/Reaktor/scripts/tell-on_privmsg.sh
@@ -0,0 +1,18 @@
+#! /bin/sh
+set -euf
+
+# require flock from 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 -cn \
+ --arg from "$_from" \
+ --arg to "${1%% *}" \
+ --arg text "${1#* }" \
+ --arg msgtarget "$_msgtarget" \
+ '{ $from, $to, $text, $msgtarget, date: (now | todate) }' \
+ >> "$state_file"
+
+echo 'Consider it noted.' # that's what lambdabot says...