Merge pull request #1 from vivia/master
Misc bugfixes, added duck module
This commit is contained in:
commit
44ddc623e4
4 changed files with 36 additions and 4 deletions
2
shbot.sh
2
shbot.sh
|
@ -11,7 +11,7 @@ do
|
||||||
if [[ "$LINE" =~ PING\ *:(.*) ]]; then
|
if [[ "$LINE" =~ PING\ *:(.*) ]]; then
|
||||||
echo "PONG :${BASH_REMATCH[1]}" >&3
|
echo "PONG :${BASH_REMATCH[1]}" >&3
|
||||||
else
|
else
|
||||||
[[ ${LINE} =~ :[a-zA-Z]*!.*(#.*)\ :.* ]] && ORIGIN=${BASH_REMATCH[1]}
|
[[ ${LINE} =~ :[^!]*![^#]*(#.*)\ :.* ]] && ORIGIN=${BASH_REMATCH[1]}
|
||||||
echo "${LINE}" | ./shbrain.sh | \
|
echo "${LINE}" | ./shbrain.sh | \
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
|
|
|
@ -8,12 +8,12 @@ do
|
||||||
LINE=${LINE[@]:0:$LEN}
|
LINE=${LINE[@]:0:$LEN}
|
||||||
|
|
||||||
### Parsing potential shcmd
|
### Parsing potential shcmd
|
||||||
if [[ $LINE =~ :([a-zA-Z]*)!.*:shcmd ]]; then
|
if [[ $LINE =~ :([^!]*)!.*:shcmd ]]; then
|
||||||
EXPAND=(${LINE})
|
EXPAND=(${LINE})
|
||||||
CMD=${EXPAND[4]#:}
|
CMD=${EXPAND[4]#:}
|
||||||
ARGS=${EXPAND[*]:5}
|
ARGS=${EXPAND[*]:5}
|
||||||
if [ "$CMD" = "advert" ]; then
|
if [ "$CMD" = "advert" ]; then
|
||||||
echo "PRIVMSG $ARGS :Listen to shbot, the one true Bot"'!' >&3
|
echo "Listen to shbot, the one true Bot!"
|
||||||
elif [ "$CMD" = "join" ]; then
|
elif [ "$CMD" = "join" ]; then
|
||||||
echo "JOIN $ARGS" >&3
|
echo "JOIN $ARGS" >&3
|
||||||
elif [ "$CMD" = "part" ]; then
|
elif [ "$CMD" = "part" ]; then
|
||||||
|
@ -22,6 +22,8 @@ do
|
||||||
./shquote.sh ${ARGS[*]}
|
./shquote.sh ${ARGS[*]}
|
||||||
elif [ "$CMD" = "trains" ]; then
|
elif [ "$CMD" = "trains" ]; then
|
||||||
./shtrains.sh ${ARGS[*]}
|
./shtrains.sh ${ARGS[*]}
|
||||||
|
elif [ "$CMD" = "duck" ]; then
|
||||||
|
./shduck.sh
|
||||||
elif [ "$CMD" = "help" ]; then
|
elif [ "$CMD" = "help" ]; then
|
||||||
./shhelp.sh $ARGS
|
./shhelp.sh $ARGS
|
||||||
else
|
else
|
||||||
|
|
30
shduck.sh
Executable file
30
shduck.sh
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Duck generation based on https://github.com/adyxax/hsbot
|
||||||
|
|
||||||
|
RANDOM=$$ #Seed random number generator from script PID
|
||||||
|
export GLOBIGNORE="*" #Do not substitute asterisks (e.g. in $heads) for lists of files!!
|
||||||
|
|
||||||
|
#Body parts (both RTL and LTR where applicable)
|
||||||
|
leftbeaks=(">" "=")
|
||||||
|
rightbeaks=("<" "=")
|
||||||
|
leftbody=("_/" "__/" "_~" "__~")
|
||||||
|
rightbody=("\\\\_" "\\\\__" "~_" "~__")
|
||||||
|
heads=("o" "O" "0" "@" "©" "®" "ð" "*" "ò" "ô" "ó" "ø" "⊕" "Ω" "ꙫ" "ꙩ" "Ꙩ" "ȯ" "◔" "õ" "ȯ" "⁰" "Ö" "Ó" "Ò" "Õ" "Ô" "ö")
|
||||||
|
|
||||||
|
head=${heads[$RANDOM % ${#heads[@]} ]} #Pick a head
|
||||||
|
|
||||||
|
left=$(expr $RANDOM % 2) #Whether it will be a left-to-right duck
|
||||||
|
|
||||||
|
#Generate the duck
|
||||||
|
if [ $left == 1 ]; then
|
||||||
|
beak=${leftbeaks[$RANDOM % ${#leftbeaks[@]} ]}
|
||||||
|
body=${leftbody[$RANDOM % ${#leftbody[@]} ]}
|
||||||
|
duck=$beak$head$body
|
||||||
|
else
|
||||||
|
beak=${rightbeaks[$RANDOM % ${#rightbeaks[@]} ]}
|
||||||
|
body=${rightbody[$RANDOM % ${#rightbody[@]} ]}
|
||||||
|
duck=$body$head$beak
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $duck
|
|
@ -16,7 +16,7 @@ case "$1" in
|
||||||
"trains") echo "trains [STATION] : Prints the next trains that will stop at Courbevoie's station."
|
"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 " When provided, only results that concerns STATION are advertised."
|
||||||
;;
|
;;
|
||||||
*) echo "The following commands are available : advert help join part quote trains"
|
*) echo "The following commands are available : advert help join part quote trains duck"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
Reference in a new issue