keywords trigger added.
This commit is contained in:
parent
8e733593f0
commit
12204246ca
2
bot.sh
2
bot.sh
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue