From 2f80a68b1f4e9cb5a636a38de90dd39987ebaa51 Mon Sep 17 00:00:00 2001 From: Vivia Nikolaidou Date: Tue, 5 Nov 2013 15:49:25 +0200 Subject: Added the duck generation module. The duck generation module listens to the "duck" command. It will then generate a random duck based on https://github.com/adyxax/hsbot with some additional heads and beaks. --- shduck.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 shduck.sh (limited to 'shduck.sh') 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 -- cgit v1.2.3