keywords trigger added.

This commit is contained in:
Storm Dragon 2016-09-06 14:25:46 -04:00
parent 8e733593f0
commit 12204246ca
2 changed files with 17 additions and 0 deletions

2
bot.sh
View File

@ -79,6 +79,8 @@ do
continue
fi
./modules/${com% *}/${com% *}.sh "$who" "$from" "$will"
else
./triggers/keywords/keywords.sh "$from" "$res"
fi
# "#" would mean it's a channel
if [ "$(echo "$from" | grep '#')" ]; then

15
triggers/keywords/keywords.sh Executable file
View File

@ -0,0 +1,15 @@
[ -f functions.sh ] && source functions.sh
chan="$1"
shift
# each word is stored in an associative array, with the actions to be taken as the array's contents.
declare -A keywords
keywords[linux]="msg '$chan' 'awesome!'"
wordList="$(echo "$@" | tr '[:space:]' $'\n' | sort -u)"
for w in ${wordList//[[:punct:]]/} ; do
if [[ -n "${keywords[${w,,}]}" ]]; then
eval ${keywords[${w,,}]}
fi
done