Fixed a bug in parsing input with calling the bot by name, also, added convert module that requires the units program.

This commit is contained in:
Storm Dragon 2016-09-07 10:06:14 -04:00
parent 8314bc2411
commit 1a3a715670
2 changed files with 16 additions and 4 deletions

8
bot.sh
View File

@ -83,7 +83,7 @@ do
if [ -z "$(ls modules/ | grep -i -- "$command")" ] || [ -z "$command" ]; then if [ -z "$(ls modules/ | grep -i -- "$command")" ] || [ -z "$command" ]; then
continue continue
fi fi
./modules/${command% *}/${command% *}.sh "$who" "$from" "$will" ./modules/${command% *}/${command% *}.sh "$who" "$from" $will
else else
./triggers/keywords/keywords.sh "$who" "$from" "$result" ./triggers/keywords/keywords.sh "$who" "$from" "$result"
fi fi
@ -95,19 +95,19 @@ do
else else
will="${result:1}" will="${result:1}"
will="${will#* :}" will="${will#* :}"
from=$who from="$who"
fi fi
# Had to turn on globbing to remove all leading whitespace, then turn it off again afterwards. # Had to turn on globbing to remove all leading whitespace, then turn it off again afterwards.
shopt -s extglob shopt -s extglob
will="${will##*( )}" will="${will##*( )}"
shopt -u extglob shopt -u extglob
command="${will% *}" command="${will%% *}"
will="${will#* }" will="${will#* }"
if [ -z "$(ls modules/ | grep -i -- "$command")" ] || [ -z "$command" ]; then if [ -z "$(ls modules/ | grep -i -- "$command")" ] || [ -z "$command" ]; then
./modules/help/help.sh "$who" "$from" ./modules/help/help.sh "$who" "$from"
continue continue
fi fi
./modules/$command/$command.sh "$who" "$from" "$will" ./modules/$command/$command.sh "$who" "$from" $will
;; ;;
*) *)
echo "$result" | tee -a "$log" echo "$result" | tee -a "$log"

12
modules/convert/convert.sh Executable file
View File

@ -0,0 +1,12 @@
[ -f functions.sh ] && source functions.sh
units="$(command -v units)"
shift
chan="$1"
shift
if [ -z "$units" ]; then
msg "$chan" "I do not have access to units."
else
msg "$chan" "$($units -v $@ | head -n1)"
fi