mirror of https://github.com/nealey/irc-bot
38 lines
841 B
Bash
Executable File
38 lines
841 B
Bash
Executable File
#! /bin/sh
|
|
|
|
firebot () {
|
|
read cmd args
|
|
case $cmd in
|
|
calc)
|
|
printf "%s = " "$args"
|
|
echo "$args" | bc -l
|
|
;;
|
|
units)
|
|
src=$(printf "%s" "$args" | sed 's/ ->.*//')
|
|
dst=$(printf "%s" "$args" | sed 's/.*-> //')
|
|
units -1 -v -- "$src" "$dst"
|
|
;;
|
|
.note)
|
|
who=$(printf "%s" "$args" | sed 's/ .*//;s/[^-A-Za-z0-9]/./')
|
|
what=$(printf "%s" "$args" | cut -d\ -f2-)
|
|
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
|
|
|
|
|
|
|