From addddffddcf4fbc896c43ac596adb204bc980963 Mon Sep 17 00:00:00 2001 From: polyfloyd Date: Wed, 21 Sep 2016 13:01:50 +0200 Subject: [PATCH] Work around a bug in netcat --- irc-bot | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/irc-bot b/irc-bot index 05894d1..a617159 100755 --- a/irc-bot +++ b/irc-bot @@ -1,8 +1,6 @@ #!/bin/bash # Super simple IRC bot. -# -# Note: Requires the OpenBSD version of netcat! NICK="bitlair-space" CHANNEL="#bitlair-test" @@ -23,13 +21,13 @@ echo "JOIN $CHANNEL" # FIXME: Possible race condition between loop and stdin. tail -f "$loop" & -nc -6 -k -lp "$INPORT" | while read line; do - echo "NOTICE $CHANNEL $line" +while true; do + echo "NOTICE $CHANNEL $(nc -lp "$INPORT")" done } | \ nc "$SERVER" 6667 | while read message; do case "$message" in - PING*) echo "PONG ${message#PING :}" | tee "$loop";; + PING*) echo "PONG ${message#PING :}" > "$loop";; ERROR*) echo "$message"; exit;; *PRIVMSG*) echo "${message}" | sed -nr "s/^:([^!]+).*PRIVMSG[^:]+:(.*)/[$(date '+%R')] <\1> \2/p";; *) echo "${message}";;