mirror of https://github.com/nealey/irc-bot
allow "nick++ extra text"
This commit is contained in:
parent
e889eb8c27
commit
f369efcad7
|
@ -0,0 +1,9 @@
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
(
|
||||||
|
# UCSPI wants input on FD 7, and sets $PROTO
|
||||||
|
[ -n "$PROTO" ] && exec 1>&7
|
||||||
|
echo "NICK $1"
|
||||||
|
echo "USER $1 $1 $1 :I'm a little printf, short and stdout."
|
||||||
|
)
|
||||||
|
exec ./dispatch ./irc ./$1-handler
|
22
infobot
22
infobot
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
db=$1; shift
|
db=$1; shift
|
||||||
text="$1"
|
text="$1"
|
||||||
|
cmd=${text%% *}
|
||||||
|
args=${text#* }
|
||||||
|
|
||||||
lookup () {
|
lookup () {
|
||||||
if ! cdb -q -m $db "$1"; then
|
if ! cdb -q -m $db "$1"; then
|
||||||
|
@ -16,7 +18,7 @@ lookup () {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$text" in
|
case "$cmd" in
|
||||||
!h*)
|
!h*)
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
!stats Show statistics
|
!stats Show statistics
|
||||||
|
@ -30,23 +32,20 @@ EOF
|
||||||
cdb -s $db | head -n 1
|
cdb -s $db | head -n 1
|
||||||
;;
|
;;
|
||||||
!l*)
|
!l*)
|
||||||
args=$(echo "$text" | cut -d\ -f2-)
|
|
||||||
printf "factoids for \"%s\": " "$args"
|
printf "factoids for \"%s\": " "$args"
|
||||||
cdb -q -m $db "$args" | awk '{printf("|%s", $0);}'
|
cdb -q -m $db "$args" | awk '{printf("|%s", $0);}'
|
||||||
echo
|
echo
|
||||||
;;
|
;;
|
||||||
!a*)
|
!a*)
|
||||||
args=$(echo "$text" | cut -d\ -f2-)
|
key=${args% +=*}
|
||||||
key=$(printf "%s" "$args" | sed 's/ +=.*//')
|
val=${args#*+= }
|
||||||
val=$(printf "%s" "$args" | sed 's/.*+= //')
|
|
||||||
(printf "+%d,%d:%s->%s\n" ${#key} ${#val} "$key" "$val";
|
(printf "+%d,%d:%s->%s\n" ${#key} ${#val} "$key" "$val";
|
||||||
cdb -d $db) | cdb -c $db
|
cdb -d $db) | cdb -c $db
|
||||||
echo "Okay, $sender, I added a factoid to $key"
|
echo "Okay, $sender, I added a factoid to $key"
|
||||||
;;
|
;;
|
||||||
!r*)
|
!r*)
|
||||||
args=$(echo "$text" | cut -d\ -f2-)
|
key=${args% -=*}
|
||||||
key=$(printf "%s" "$args" | sed 's/ -=.*//')
|
val=${args#*-= }
|
||||||
val=$(printf "%s" "$args" | sed 's/.*-= //')
|
|
||||||
re=":$key->.*$val"
|
re=":$key->.*$val"
|
||||||
n=$(cdb -d $db | grep -c "$re")
|
n=$(cdb -d $db | grep -c "$re")
|
||||||
if [ $n -gt 0 ]; then
|
if [ $n -gt 0 ]; then
|
||||||
|
@ -56,8 +55,7 @@ EOF
|
||||||
echo "Nothing matched, $sender."
|
echo "Nothing matched, $sender."
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
!forget\ *)
|
!forget)
|
||||||
args=$(echo "$text" | cut -d\ -f2-)
|
|
||||||
cdb -d $db | grep -a -F -v ":$args->" | cdb -c $db
|
cdb -d $db | grep -a -F -v ":$args->" | cdb -c $db
|
||||||
echo "I removed all factoids from $args"
|
echo "I removed all factoids from $args"
|
||||||
;;
|
;;
|
||||||
|
@ -67,10 +65,10 @@ EOF
|
||||||
"")
|
"")
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
\\*)
|
''*)
|
||||||
echo "Someone's up to no good!"
|
echo "Someone's up to no good!"
|
||||||
;;
|
;;
|
||||||
\\*)
|
'\'*)
|
||||||
printf "%s\n" "${resp#\\}"
|
printf "%s\n" "${resp#\\}"
|
||||||
;;
|
;;
|
||||||
:*)
|
:*)
|
||||||
|
|
6
whuffie
6
whuffie
|
@ -13,7 +13,7 @@ put () {
|
||||||
}
|
}
|
||||||
|
|
||||||
adj () {
|
adj () {
|
||||||
who=${text%%$1$1}
|
who=${text%%$1$1*}
|
||||||
if [ "$who" = "$sender" ]; then
|
if [ "$who" = "$sender" ]; then
|
||||||
echo "Nice try, $sender."
|
echo "Nice try, $sender."
|
||||||
else
|
else
|
||||||
|
@ -28,10 +28,10 @@ case "$text" in
|
||||||
amt=$(get "$who")
|
amt=$(get "$who")
|
||||||
echo "$who has $amt whuffie"
|
echo "$who has $amt whuffie"
|
||||||
;;
|
;;
|
||||||
*++)
|
*++|*++\ *)
|
||||||
adj +
|
adj +
|
||||||
;;
|
;;
|
||||||
*--)
|
*--|*--\ *)
|
||||||
adj -
|
adj -
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
Loading…
Reference in New Issue