Remove leading '.' after Brugh bitched at me enough.

This commit is contained in:
Neale Pickett 2011-01-10 14:10:32 -06:00
parent 3df34ce677
commit b45ae4b605
3 changed files with 19 additions and 11 deletions

2
bot
View File

@ -1,5 +1,7 @@
#! /bin/sh
nickname=$1; export nickname
echo "NICK $1" 1>&6
echo "USER $1 $1 $1 :I'm a little printf, short and stdout." 1>&6
exec ./dispatch ./irc ./$1-handler

View File

@ -3,11 +3,11 @@
cmd=${1%% *}
[ "$cmd" = "$1" ] || args=${1#* }
case $cmd in
.calc)
calc)
printf "%s = " "$args"
echo "$args" | bc -l
;;
.units)
units)
src=$(printf "%s" "$args" | sed 's/ ->.*//')
dst=$(printf "%s" "$args" | sed 's/.*-> //')
units -1 -v -- "$src" "$dst"

24
infobot
View File

@ -2,8 +2,6 @@
db=$1; shift
text="$1"
cmd=${text%% *}
args=${text#* }
lookup () {
if ! cdb -q -m $db "$1"; then
@ -18,7 +16,15 @@ lookup () {
fi
}
case "$cmd" in
db_append () {
(printf "+%d,%d:%s->%s\n" ${#1} ${#2} "$1" "$2"; cdb -d $db) | cdb -c $db
echo "Okay, $sender, I added a factoid to $1."
}
nickname=${nickname:-infobot}
args=${text#* }
case "$text" in
!h*)
cat <<EOF
!stats Show statistics
@ -36,12 +42,12 @@ EOF
cdb -q -m $db "$args" | awk '{printf("|%s", $0);}'
echo
;;
$nickname:\ *\ is\ *)
s=${text#$nickname: }
db_append "${s%% is *}" "${s#* is }"
;;
!a*)
key=${args% +=*}
val=${args#*+= }
(printf "+%d,%d:%s->%s\n" ${#key} ${#val} "$key" "$val";
cdb -d $db) | cdb -c $db
echo "Okay, $sender, I added a factoid to $key"
db_append "${args% +=*}" "${args#*+= }"
;;
!r*)
key=${args% -=*}
@ -55,7 +61,7 @@ EOF
echo "Nothing matched, $sender."
fi
;;
!forget)
!forget\ *)
cdb -d $db | grep -a -F -v ":$args->" | cdb -c $db
echo "I removed all factoids from $args"
;;