#!/bin/sh # random toribash player NICK=bot SPACE_SLEEP=${1:-15} player=0 timeout=0 echo "Botname $NICK space_sleep $SPACE_SLEEP" # connect to server #exec 5<>/dev/tcp/127.0.0.1/20184 || exit 1 #exec 5<>/dev/tcp/66.230.225.210/20182 || exit 1 exec 5<>/dev/tcp/203.81.48.75/20186 || exit 1 echo NICK $NICK >&5 echo ENTER >&5 #echo SAY "hello I am $NICK" >&5 while read x; do echo x=$x echo $x | grep -qs "lolbot" >&5 if [ $? -eq 0 ]; then echo SAY "Moo!" >&5 fi echo $x | grep "^BOUT " | grep -qs $NICK if [ $? -eq 0 ]; then player=$(echo $x | cut -d " " -f2 | cut -d ";" -f 1) fi now=$(date "+%s") if [ $now -gt $timeout ]; then echo PING >&5 echo ">> sending ping" let "timeout=$now + 10" fi [ $player -gt 1 ] && continue echo $x | grep -qs "GAME" if [ $? -eq 0 ]; then let "lg=$RANDOM % 2" let "rg=$RANDOM % 2" jstr="JOINT $player; " for ((i=0; i<20; i++)); do let "r = $RANDOM % 4" #r=3 jstr="$jstr $i $r" done sleep $SPACE_SLEEP echo "COMMITING" echo "GRIP $player; $lg $rg" >&5 #echo "GRIP $player; 1 1" >&5 #echo "JOINT $player;0 3 1 3 2 3 3 3 4 2 5 3 6 3 7 2 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3" >&5 echo $jstr >&5 fi echo $x | grep -qs "WIN" && sleep 5 && echo READY >&5 done <&5