diff options
Diffstat (limited to '')
-rwxr-xr-x | shbot.sh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/shbot.sh b/shbot.sh new file mode 100755 index 0000000..cba3b01 --- /dev/null +++ b/shbot.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +source ./shbirth.sh +exec 3<>/dev/tcp/$SERVER/$PORT +shbirth 1>&3 + +while true +do + read LINE 0<&3 || break + echo "<-- "$LINE + if [[ "$LINE" =~ PING\ *:(.*) ]]; then + echo "PONG :${BASH_REMATCH[1]}" >&3 + sleep 0.1 + else + echo "${LINE}" | ./shbrain.sh | \ + while true + do + read ANSWER || break + echo "--> "$ANSWER + echo $ANSWER >&3 + done + fi +done + +exec 3>&- +exit 0 + |