stormbot/triggers/keywords/keywords.sh

33 lines
1.7 KiB
Bash
Raw Normal View History

2016-09-06 14:25:46 -04:00
[ -f functions.sh ] && source functions.sh
who="$1"
shift
2016-09-06 14:25:46 -04:00
chan="$1"
shift
# each word is stored in an associative array, with the actions to be taken as the array's contents.
# the variable $chan contains the channel that caused the trigger.
# the variable $who contains the nick that caused the trigger.
2016-09-06 14:25:46 -04:00
declare -A keywords
2017-04-08 00:33:42 -04:00
keywords[linux]="msg \"$chan\" \"Linux is $(shuf -n1 -e awesome God great lovely fantastic amazing wonderful)!\""
2017-04-27 21:33:56 -04:00
keywords[windows]="msg \"$chan\" \"$(shuf -n1 -e "Apple got all pissed off because I farted in their store. It's not my falt they don't have Windows..." "Windows is dumb!" "Did you know that Micro Soft is Linda's pet name for Bill Gates?" "A computer without Windows is like a chocolate cake without the mustard." "Windows is stupid")!\""
2017-04-08 00:33:42 -04:00
keywords[chicken]="msg \"$chan\" \"$who, I'm gonna grab me $(shuf -n1 -e "a case of beer" "a weed eater" "a 5 gallon jug of vaseline" "a can of wd40") and a $(shuf -n1 -e dead frozen live young) chicken, and $(shuf -n1 -e "have fun"
"make
chicks"
"lay it like an egg" "put my beak where it don't belong") ALL NIGHT LONG!!!\""
keywords[dragonforce]="msg \"$chan\" \"$who: I love DragonForce!!!\""
2016-09-06 14:25:46 -04:00
wordList="$(echo "${@,,}" | tr '[:space:]' $'\n' | sort -u)"
2016-09-06 14:25:46 -04:00
for w in ${wordList//[[:punct:]]/} ; do
if [[ -n "${keywords[${w,,}]}" ]]; then
eval ${keywords[${w,,}]}
fi
done
# Example of dealing with multi word triggers.
# Reset wordList without sorting it and with spaces removed.
wordList="$(echo "${@,,}" | tr -d '[:space:]')"
if [[ "$wordList" =~ .*nowplaying:.*-.* ]]; then
2016-09-25 00:27:31 -04:00
act "$chan" "$(shuf -n1 -e "cranks the volume up to 11" "got soooo high at that show" "boogies down to the sound of the band")!"
fi