diff options
Diffstat (limited to '')
-rwxr-xr-x | shbot.sh | 1 | ||||
-rwxr-xr-x | shbrain.sh | 2 | ||||
-rwxr-xr-x | shhelp.sh | 12 | ||||
-rwxr-xr-x | shquote.sh | 25 | ||||
-rw-r--r-- | shquote.txt | 4 |
5 files changed, 42 insertions, 2 deletions
@@ -10,7 +10,6 @@ do echo "<-- "$LINE if [[ "$LINE" =~ PING\ *:(.*) ]]; then echo "PONG :${BASH_REMATCH[1]}" >&3 - sleep 0.1 else [[ ${LINE} =~ :[a-zA-Z]*!.*(#.*)\ :.* ]] && ORIGIN=${BASH_REMATCH[1]} echo "${LINE}" | ./shbrain.sh | \ @@ -18,6 +18,8 @@ do echo "JOIN $ARGS" >&3 elif [ "$CMD" = "part" ]; then echo "PART $ARGS" >&3 + elif [ "$CMD" = "quote" ]; then + ./shquote.sh ${ARGS[*]} elif [ "$CMD" = "trains" ]; then ./shtrains.sh ${ARGS[*]} elif [ "$CMD" = "help" ]; then @@ -1,12 +1,22 @@ #!/bin/bash -ex case "$1" in + "advert") echo "advert <CHANNEL> : Make shbot speak the truth about himself on the specified CHANNEL." + ;; "help") echo "help <TOPIC> : Prints help about TOPIC." ;; + "join") echo "join <CHANNEL> : Make shbot join the specified CHANNEL." + ;; + "part") echo "part <CHANNEL> : Make shbot part the specified CHANNEL." + ;; + "quote") echo "quote [OWNER QUOTE] :" + echo " Without arguments : prints a random quote." + echo " if OWNER and QUOTE are provided : save the quote for posterity and legend." + ;; "trains") echo "trains [STATION] : Prints the next trains that will stop at Courbevoie's station." echo " When provided, only results that concerns STATION are advertised." ;; - *) echo "The following commands are available : help trains" + *) echo "The following commands are available : advert help join part quote trains" ;; esac diff --git a/shquote.sh b/shquote.sh new file mode 100755 index 0000000..82076fb --- /dev/null +++ b/shquote.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +if [ -n "$2" ]; then + ARGS=$* && ARGS=($ARGS) + OWNER=$1 + LEN=`expr ${#ARGS[*]}` + QUOTE=${ARGS[@]:1:$LEN} + + echo "${OWNER}" >> shquote.txt + echo "${QUOTE}" >> shquote.txt +#elif [ -n "$1" ]; then + # TODO : quote someone +else + NB_LINES=(`wc -l shquote.txt`) + LINE=$((RANDOM * NB_LINES[0] / 65534)) + + # IFS="\r" LINES=(`tail -n $((LINE + 2)) shquote.txt | head -n 2`) + # QUOTE=${LINES[0]} + # OWNER=${LINES[1]} + QUOTE=`tail -n $((LINE * 2 + 1)) shquote.txt | head -n 1` + OWNER=`tail -n $((LINE * 2 + 2)) shquote.txt | head -n 1` + echo "\"${QUOTE}\"" + echo "-- ${OWNER}" +fi + diff --git a/shquote.txt b/shquote.txt new file mode 100644 index 0000000..415a8d2 --- /dev/null +++ b/shquote.txt @@ -0,0 +1,4 @@ +galdor 08/17/09 21:08:14 +J'ai 23 ans et une gueule de nerd. +julien 08/17/09 21:42:28 +J'ai déjà fait beaucoup de rapports en latex. |