summaryrefslogtreecommitdiff
path: root/shbot.sh
diff options
context:
space:
mode:
authorjulien2009-07-06 17:26:39 +0200
committerjulien2009-07-06 17:26:39 +0200
commit962e19a2bcd0697aa80e5da8b0bf499557219a59 (patch)
tree2e188f8a6e3c57cffcb88e048b9d8f2e5d2935ac /shbot.sh
downloadshbot-962e19a2bcd0697aa80e5da8b0bf499557219a59.tar.gz
shbot-962e19a2bcd0697aa80e5da8b0bf499557219a59.tar.bz2
shbot-962e19a2bcd0697aa80e5da8b0bf499557219a59.zip
Initial import
Diffstat (limited to 'shbot.sh')
-rwxr-xr-xshbot.sh27
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
+