2010-12-15 22:36:16 -07:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
firebot () {
|
|
|
|
read cmd args
|
|
|
|
case $cmd in
|
|
|
|
calc)
|
|
|
|
printf "%s = " "$args"
|
|
|
|
echo "$args" | bc -l
|
|
|
|
;;
|
|
|
|
units)
|
2010-12-16 17:28:43 -07:00
|
|
|
src=$(printf "%s" "$args" | sed 's/ ->.*//')
|
|
|
|
dst=$(printf "%s" "$args" | sed 's/.*-> //')
|
2010-12-15 22:36:16 -07:00
|
|
|
units -1 -v -- "$src" "$dst"
|
|
|
|
;;
|
|
|
|
.note)
|
2010-12-16 17:28:43 -07:00
|
|
|
who=$(printf "%s" "$args" | sed 's/ .*//;s/[^-A-Za-z0-9]/./')
|
|
|
|
what=$(printf "%s" "$args" | cut -d\ -f2-)
|
2010-12-15 22:36:16 -07:00
|
|
|
when=$(date)
|
|
|
|
echo "($when) <$sender> $what" > notes/$who
|
|
|
|
echo "I've left $who a note, $sender."
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -f notes/$sender ]; then
|
|
|
|
echo "Welcome back, $sender. Your messages:"
|
|
|
|
cat notes/$sender
|
|
|
|
rm notes/$sender
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$1" | firebot
|
|
|
|
|
|
|
|
|
|
|
|
|