diff options
Diffstat (limited to '')
-rw-r--r-- | README | 0 | ||||
-rwxr-xr-x | shbirth.sh | 9 | ||||
-rwxr-xr-x | shbot.sh | 3 | ||||
-rwxr-xr-x | shbrain.sh | 15 | ||||
-rw-r--r-- | shbrain.txt | 2 | ||||
-rwxr-xr-x | shtrains.sh | 17 |
6 files changed, 29 insertions, 17 deletions
@@ -4,13 +4,14 @@ SERVER=${1:-kro.corp} #SERVER=${1:-localhost} PORT=6667 export NICK=shbot -export CHANNELS=${2:-#codemore} -export CHANNEL2=${2:-#shbot} +export CHANNELS=('#codemore #shbot') function shbirth () { echo "NICK $NICK" echo "USER $(whoami) +iw $NICK :$0" - #echo "JOIN $CHANNEL" - echo "JOIN $CHANNEL2" + for CHANNEL in $CHANNELS + do + echo "JOIN $CHANNEL" + done } @@ -12,12 +12,13 @@ do echo "PONG :${BASH_REMATCH[1]}" >&3 sleep 0.1 else + [[ ${LINE} =~ :[a-zA-Z]*!.*(#.*)\ :.* ]] && ORIGIN=${BASH_REMATCH[1]} echo "${LINE}" | ./shbrain.sh | \ while true do read ANSWER || break echo "--> "$ANSWER - echo $ANSWER >&3 + echo "PRIVMSG $ORIGIN :"$ANSWER >&3 done fi done @@ -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 diff --git a/shbrain.txt b/shbrain.txt index a203053..4ebf14d 100644 --- a/shbrain.txt +++ b/shbrain.txt @@ -1,6 +1,6 @@ ping 100 pong plop 100 pataplop -:([a-zA-Z]*)!.*:.*(shbot|julien|root).*(le retour) 100 De retour, encore plus fort... +:([a-zA-Z]*)!.*:.*(shbot|julien|root).*(le retour|is back) 100 De retour, encore plus fort... :([a-zA-Z]*)!.*:.*(shbot|julien|root).*(fuck|merde) 100 You, fuck you ${BASH_REMATCH[1]}... :([a-zA-Z]*)!.*:.*(clex|galdor).*(fuck|merde|suck) 100 You are right ${BASH_REMATCH[1]}, fuck you ${BASH_REMATCH[2]}. diff --git a/shtrains.sh b/shtrains.sh index d49738e..0d9739a 100755 --- a/shtrains.sh +++ b/shtrains.sh @@ -1,9 +1,20 @@ #!/bin/bash -links -dump 'http://transilien.mobi/pam/TempReelSaisieDepartSubmit.do?debutDepart=Courbevoie&tous=Tous+trains' > trains.tmp -#wget -q -O trains.tmp 'http://transilien.mobi/pam/TempReelSaisieDepartSubmit.do?debutDepart=Courbevoie&tous=Tous+trains' +links -dump 'http://transilien.mobi/pam/TempReelSaisieDepartSubmit.do?debutDepart=Courbevoie&tous=Tous+trains' | head -n 22 | tail -n 18 >trains.tmp -echo "PRIVMSG $CHANNEL2 :"$* +cat trains.tmp | \ +while true +do + read PATTERN || break + read STATION || break + read UGUU || break + [[ $PATTERN =~ \ *[A-Z]{4}\ *(.*) ]] && PATTERN=${BASH_REMATCH[1]} + if [ -n "$*" ]; then + [[ $STATION =~ $@ ]] && echo "$PATTERN $STATION" + else + echo "$PATTERN $STATION" + fi +done exit 0 |