stormbot/triggers/keywords/keywords.sh
2020-07-23 01:16:57 -04:00

84 lines
3.9 KiB
Bash
Executable File

[ -f functions.sh ] && source functions.sh
who="${1%!*}"
who="${who//:}"
shift
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.
declare -A keywords
keywords[linux]="msg \"$chan\" \"Linux is $(shuf -n1 -e awesome God great lovely fantastic amazing wonderful)!\""
keywords[windows]="msg \"$chan\" \"$(shuf -n1 -e\
"Failure is not an option, it comes bundled with Windows!"\
"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"\
"In a world without walls and fences - who needs windows and gates?"\
"Windows, plug and pray."\
"Windows - Just another pain in the glass."\
"Windows, it's not pretty, it's not ugly, but it's pretty ugly.")!\""
keywords[emacs]="msg \"$chan\" \"$who, Real men use vim!\""
keywords[eloquence]="msg \"$chan\" \"$(shuf -n1 -e \
"anticaesure" \
"caesure" \
"Goodhesville" \
"hh've" \
"Hoobhestank" \
"tzsche" \
"uncosp" \
"webhesday" \
"wedhesday")\""
keywords[eloquents]="msg \"$chan\" \"$(shuf -n1 -e \
"anticaesure" \
"caesure" \
"hh've" \
"tzsche" \
"uncosp" \
"webhesday" \
"wedhesday")\""
keywords[jaws]="msg \"$chan\" \"$(shuf -n1 -e \
"${who}: watch out for sharks!"\
"Ooooo! Jaws! Yeah, let's spend 1,500 bucks to buy what NVDA can do for free... Not much of an accountant are you ${who}?")\""
keywords[jfw]="msg \"$chan\" JFW: Acronym that means: Jaws! FUCKING WORTHLESS!"
keywords[emacspeak]="msg \"$chan\" \"$who, Real men use vim!\""
keywords[nano]="msg \"$chan\" \"$who, Real men use vim!\""
keywords[pidgin]="msg \"$chan\" \"$who, Real men use irssi!\""
keywords[weechat]="msg \"$chan\" \"$who, Real men use irssi!\""
keywords[thunderbird]="msg \"$chan\" \"$who, Real men use mutt!\""
keywords[gedit]="msg \"$chan\" \"$who, Real men use vim!\""
keywords[pluma]="msg \"$chan\" \"$who, Real men use vim!\""
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 baby) 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[feather]="msg \"$chan\" \"$who: Erotic is using a feather. Kinky is using the whole chicken!!!\""
keywords[feathers]="msg \"$chan\" \"$who: Erotic is using a feather. Kinky is using the whole chicken!!!\""
keywords[dragonforce]="msg \"$chan\" \"$who: I love DragonForce!!!\""
keywords[vim]="msg \"$chan\" \"$(shuf -n1 -e \
"Praise vim! HA"\
"In times of trouble, just ask yourself, 'What would Bram Moolenaar do?'."\
"Vim is like a Ferrari, if you're a beginner, it handles like a bitch, but once you get the hang of it, it's small, powerful and FAST!"\
"VIM is like a new model Ferrari, and sounds like one too - 'VIIIIIIMMM!'"\
"Only through vim can you be saved! HA")\""
wordList="$(echo "${@,,}" | tr '[:space:]' $'\n' | sort -u)"
for w in ${wordList//[[:punct:]]/} ; do
if [[ -n "${keywords[${w,,}]}" && "$lastWordMatch" != "${keywords[${w,,}]}" ]]; then
eval ${keywords[${w,,}]}
lastWordMatch="${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
if [ "$who" = "lilmike" ]; then
msg "$chan" "Ewww, it sounds like 2 robots making out!"
else
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
fi