Added the quote module
This commit is contained in:
parent
ec7e577dd7
commit
d067533902
5 changed files with 42 additions and 2 deletions
1
shbot.sh
1
shbot.sh
|
@ -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
|
||||
|
|
12
shhelp.sh
12
shhelp.sh
|
@ -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
|
||||
|
||||
|
|
25
shquote.sh
Executable file
25
shquote.sh
Executable file
|
@ -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
|
||||
|
4
shquote.txt
Normal file
4
shquote.txt
Normal file
|
@ -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.
|
Reference in a new issue