summaryrefslogtreecommitdiff
path: root/shbrain.sh
diff options
context:
space:
mode:
authorjulien2009-07-07 09:56:53 +0200
committerjulien2009-07-07 09:56:53 +0200
commitd44fb2f6bae26ae857279ebcc3a914b990b95480 (patch)
treef6b7d332f393a709d50ff381df8b16f6ed07a019 /shbrain.sh
parentInitial import (diff)
downloadshbot-d44fb2f6bae26ae857279ebcc3a914b990b95480.tar.gz
shbot-d44fb2f6bae26ae857279ebcc3a914b990b95480.tar.bz2
shbot-d44fb2f6bae26ae857279ebcc3a914b990b95480.zip
Made a working trains script.
Diffstat (limited to 'shbrain.sh')
-rwxr-xr-xshbrain.sh15
1 files changed, 7 insertions, 8 deletions
diff --git a/shbrain.sh b/shbrain.sh
index bf8ade4..6dd968a 100755
--- a/shbrain.sh
+++ b/shbrain.sh
@@ -3,7 +3,7 @@
while true
do
read LINE || break
- ### First of all we get rid of the trailing \n
+ ### First of all we get rid of a potential trailing \n
LEN=`expr ${#LINE} - 1`
LINE=${LINE[@]:0:$LEN}
@@ -12,15 +12,14 @@ do
EXPAND=(${LINE})
CMD=${EXPAND[4]#:}
ARGS=${EXPAND[*]:5}
- if [[ "trains" =~ "$CMD" ]]; then
- sh -ex ./shtrains.sh ${ARGS[*]}
- break
+ if [ "$CMD" = "trains" ]; then
+ ./shtrains.sh ${ARGS[*]}
elif [ "$CMD" = "help" ]; then
- echo "PRIVMSG $CHANNEL2 :Help"
- break
+ echo "Help"
else
- echo "PRIVMSG $CHANNEL2 :Use \"shcmd help\" to list available commands."
+ echo "Use \"shcmd help\" to list available commands."
fi
+ break
fi
### Parsing brain file for potential replies
@@ -36,7 +35,7 @@ do
RESPONSE=${BRAIN[2]}
if [[ "$LINE" =~ ${PATTERN} ]]; then
if [[ "$((RANDOM / 320))" -lt ${PERCENT} ]]; then
- echo "PRIVMSG $CHANNEL2 :"`eval echo $RESPONSE`
+ echo `eval echo $RESPONSE`
#awk 'NR==$LINENUM{$0='"$RESPONSE"'}1' shbrain.txt
#sed "$LINENUM"'s\\'"${PATTERN} 10 ${RESPONSE}" -i shbrain.txt
break