mirror of https://github.com/nealey/irc-bot
28 lines
486 B
Bash
Executable File
28 lines
486 B
Bash
Executable File
#! /bin/sh
|
|
|
|
db=$1; shift
|
|
text=$1
|
|
|
|
lc () {
|
|
printf "%s" "$1" | tr A-Z a-z
|
|
}
|
|
|
|
sender=$(lc "$sender")
|
|
if [ -f $db/$sender ]; then
|
|
echo "Welcome back, $sender. Your messages:"
|
|
cat $db/$sender
|
|
rm $db/$sender
|
|
fi
|
|
|
|
case "$text" in
|
|
note\ *)
|
|
args=${text#note }
|
|
who=$(lc "${args%% *}")
|
|
what=${args#* }
|
|
when=$(date)
|
|
|
|
echo "($when) <$prefix> $what" >> $db/$who
|
|
echo "Okay, $sender, I've left $who a note."
|
|
;;
|
|
esac
|