2010-12-16 22:02:43 -07:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
db=$1; shift
|
|
|
|
text=$1
|
|
|
|
|
2011-09-20 10:08:14 -06:00
|
|
|
lc () {
|
|
|
|
printf "%s" "$1" | tr A-Z a-z
|
|
|
|
}
|
|
|
|
|
|
|
|
sender=$(lc "$sender")
|
2010-12-16 22:02:43 -07:00
|
|
|
if [ -f $db/$sender ]; then
|
|
|
|
echo "Welcome back, $sender. Your messages:"
|
|
|
|
cat $db/$sender
|
|
|
|
rm $db/$sender
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$text" in
|
2011-01-10 15:04:10 -07:00
|
|
|
note\ *)
|
|
|
|
args=${text#note }
|
2011-09-20 10:08:14 -06:00
|
|
|
who=$(lc "${args%% *}")
|
2010-12-16 22:02:43 -07:00
|
|
|
what=${args#* }
|
|
|
|
when=$(date)
|
|
|
|
|
2010-12-16 22:07:39 -07:00
|
|
|
echo "($when) <$prefix> $what" >> $db/$who
|
2010-12-16 22:02:43 -07:00
|
|
|
echo "Okay, $sender, I've left $who a note."
|
|
|
|
;;
|
|
|
|
esac
|