Add whuffie

This commit is contained in:
Neale Pickett 2010-12-16 21:13:34 -07:00
parent 76dfcbf258
commit 13202d4ebd
3 changed files with 49 additions and 7 deletions

View File

@ -14,8 +14,13 @@ case $command in
printf '\aJOIN #bot\n'
;;
PRIVMSG)
./firebot "$text" || \
./infobot woozle.cdb "$text"
case "$forum" in
\#woozle|\#foozle)
./firebot "$text" || \
./whuffie woozle.whuffie.cdb "$text" || \
./infobot woozle.factoids.cdb "$text"
;;
esac
;;
INVITE)
printf '\aJOIN %s\n' "$forum"

View File

@ -1,10 +1,6 @@
#! /bin/sh
if [ $# -gt 1 ]; then
db=$1; shift
else
db=info.cdb
fi
db=$1; shift
text="$1"
args=$(echo "$text" | cut -d\ -f2-)

41
whuffie Executable file
View File

@ -0,0 +1,41 @@
#! /bin/sh
db=$1; shift
text="$1"
get () {
cdb -q $db "$1" || echo 0
}
put () {
(printf "+%d,%d:%s->%s\n" ${#1} ${#2} "$1" $2;
cdb -d $db) | cdb -c -u $db
}
adj () {
who=${text%%$1$1}
if [ "$who" = "$sender" ]; then
echo "Nice try, $sender."
else
put "$who" $(expr $(get "$who") $1 1)
fi
}
case "$text" in
whuffie\ *)
who=${text##whuffie }
amt=$(get "$who")
echo "$who has $amt whuffie"
;;
*++)
adj +
;;
*--)
adj -
;;
*)
exit 1
;;
esac