dot

packages and services management
Log | Files | Refs | README

commit 58ac702e2d355fbf0d26932329a254370c8212e8
parent 786bb9bf8cf5e4f2513ddfc0067e4197d520cbed
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Sat, 12 Aug 2017 20:41:49 +0200

libbearssl/bin/bot: addig a git hook argument

Diffstat:
Mlibbearssl/bin/bot | 64++++++++++++++++++++++++++++++++++++++--------------------------
Mlibbearssl/start | 2+-
2 files changed, 39 insertions(+), 27 deletions(-)

diff --git a/libbearssl/bin/bot b/libbearssl/bin/bot @@ -4,33 +4,45 @@ CHAN=#commits NICK=${0##*/} PASS=$PASS -mkdir -p "$VAR/irc/$CHAN" -cd "$VAR/irc/$CHAN" || exit +mkdir -p "$VAR/irc/$HOST" +cd "$VAR/irc/$HOST" || exit -[ -p bot ] || mkfifo bot +case "$1" in +(git) + : ${GIT_DIR:?this must be run from a git hook} + printf 'PRIVMSG %s :[%s/%s\n' "$CHAN" "$( + git -C "$GIT_DIR" rev-parse --show-toplevel | xargs basename + )" "$( + git -C "$GIT_DIR" show --name-only --format='%h] %cn: %s' + )" > bot + ;; +(-d) + [ -p bot ] || mkfifo bot -tail -f bot | brssl client "$HOST:6697" | -while IFS='' read -r line -do - case "$line" in - ('PING :'*) - printf '%s\n' "$line" - sleep 1 - printf 'PONG%s\n' "${line#PING}" > bot - printf 'PONG%s\n' "${line#PING}" - ;; - (*) - printf '%s\n' "$line" - ;; - esac -done | sed -r -n 's/^:?[^:]*:// p' >> out & + tail -f bot | brssl client "$HOST:6697" | tee /dev/stderr | + while IFS='' read -r line + do + case "$line" in + ('PING :'*) + printf '%s\n' "$line" + sleep 1 + printf 'PONG%s\n' "${line#PING}" > bot + printf 'PONG%s\n' "${line#PING}" + ;; + (*) + printf '%s\n' "$line" + ;; + esac + done | sed -r -n 's/^:?[^:]*:// p' >> out & -sleep 5 -printf 'USER %s +i * :%s\n' "$NICK" "$DESC" > bot -printf 'NICK %s\n' "$NICK" > bot -sleep 5 -printf 'PRIVMSG NickServ :IDENTIFY %s\n' "$PASS" > bot -sleep 5 -printf 'JOIN %s\n' "$CHAN" > bot + sleep 5 + printf 'USER %s +i * :%s\n' "$NICK" "$DESC" > bot + printf 'NICK %s\n' "$NICK" > bot + sleep 5 + printf 'PRIVMSG NickServ :IDENTIFY %s\n' "$PASS" > bot + sleep 5 + printf 'JOIN %s\n' "$CHAN" > bot -wait + wait + ;; +esac diff --git a/libbearssl/start b/libbearssl/start @@ -1,5 +1,5 @@ case "$1" in ( bot ) - PASS="$2" bot + PASS="$2" bot -d ;; esac & PID=$!