irc-bot/cobalt-handler

56 lines
1.2 KiB
Plaintext
Raw Normal View History

2010-12-15 22:36:16 -07:00
#! /bin/sh
2011-01-10 15:18:34 -07:00
prefix=$1; export prefix; shift
2011-01-06 21:08:21 -07:00
command=$1; export command; shift
2010-12-15 22:36:16 -07:00
sender=$1; export sender; shift
forum=$1; export forum; shift
2011-01-06 21:08:21 -07:00
text=$1; export text; shift
2010-12-15 22:36:16 -07:00
# $* is now args
2011-01-06 21:08:21 -07:00
# Debug output
2011-01-10 15:18:34 -07:00
echo '>>>' ${prefix:+:}$prefix $command "$@" ${text:+:}"$text" 1>&2
2011-01-06 21:08:21 -07:00
raw () {
fmt="\007$1\n"; shift
printf "$fmt" "$@"
}
2010-12-15 22:36:16 -07:00
join () {
2011-01-06 21:08:21 -07:00
raw "JOIN $1"
}
2010-12-15 22:36:16 -07:00
case $command in
001)
2011-01-07 15:38:20 -07:00
for chan in ${CHANNELS:-#cobalt}; do
join $chan
done
2011-01-06 21:08:21 -07:00
;;
433)
raw "NICK bottimus"
2010-12-15 22:36:16 -07:00
;;
PRIVMSG)
2010-12-16 21:13:34 -07:00
case "$forum" in
\#*)
2010-12-16 21:13:34 -07:00
./firebot "$text" || \
2010-12-16 22:02:43 -07:00
./whuffie woozle/whuffie.cdb "$text" || \
./infobot woozle/factoids.cdb "$text"
2010-12-16 22:03:50 -07:00
./notes woozle/notes "$text"
2010-12-16 21:13:34 -07:00
;;
esac
2010-12-15 22:36:16 -07:00
;;
INVITE)
join "$forum"
2011-01-06 21:08:21 -07:00
raw "PRIVMSG %s :Thanks for the invitation, %s." "$forum" "$sender"
2010-12-15 22:36:16 -07:00
;;
2011-01-06 21:08:21 -07:00
esac | while read -r line; do
case "$line" in
*)
printf "%s\r\n" "${line#}"
;;
*)
printf "PRIVMSG %s :%s\r\n" "$forum" "$line"
;;
esac
done
2010-12-15 22:36:16 -07:00