diff options
author | Julien Dessaux | 2013-11-05 14:30:18 -0800 |
---|---|---|
committer | Julien Dessaux | 2013-11-05 14:30:18 -0800 |
commit | 44ddc623e4b317a31a120fb9463d634dbb37a1dd (patch) | |
tree | b2ccc8c89db8bd3d34c8688cf737595f13c9d08f /shduck.sh | |
parent | Added the quote module (diff) | |
parent | Added the duck generation module. (diff) | |
download | shbot-44ddc623e4b317a31a120fb9463d634dbb37a1dd.tar.gz shbot-44ddc623e4b317a31a120fb9463d634dbb37a1dd.tar.bz2 shbot-44ddc623e4b317a31a120fb9463d634dbb37a1dd.zip |
Merge pull request #1 from vivia/master
Misc bugfixes, added duck module
Diffstat (limited to '')
-rwxr-xr-x | shduck.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/shduck.sh b/shduck.sh new file mode 100755 index 0000000..5fc4b02 --- /dev/null +++ b/shduck.sh @@ -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 |