diff --git a/bot b/bot index 5b97397..989616e 100755 --- a/bot +++ b/bot @@ -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 diff --git a/firebot b/firebot index 0c3b1b1..df47296 100755 --- a/firebot +++ b/firebot @@ -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" diff --git a/infobot b/infobot index 48eb04e..3f0b742 100755 --- a/infobot +++ b/infobot @@ -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 <%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" ;;