mirror of https://github.com/nealey/irc-bot
56 lines
1.1 KiB
Bash
Executable File
56 lines
1.1 KiB
Bash
Executable File
#! /bin/sh
|
||
|
||
pfx=$1; export pfx; shift
|
||
command=$1; export command; shift
|
||
sender=$1; export sender; shift
|
||
forum=$1; export forum; shift
|
||
text=$1; export text; shift
|
||
# $* is now args
|
||
|
||
# Debug output
|
||
echo '>>>' ${pfx:+:}$pfx $command "$@" ${text:+:}"$text" 1>&2
|
||
|
||
raw () {
|
||
fmt="\007$1\n"; shift
|
||
printf "$fmt" "$@"
|
||
}
|
||
|
||
join () {
|
||
raw "JOIN $1"
|
||
}
|
||
|
||
case $command in
|
||
001)
|
||
for chan in ${CHANNELS:-#cobalt}; do
|
||
join $chan
|
||
done
|
||
;;
|
||
433)
|
||
raw "NICK bottimus"
|
||
;;
|
||
PRIVMSG)
|
||
case "$forum" in
|
||
\#*)
|
||
./firebot "$text" || \
|
||
./whuffie woozle/whuffie.cdb "$text" || \
|
||
./infobot woozle/factoids.cdb "$text"
|
||
./notes woozle/notes "$text"
|
||
;;
|
||
esac
|
||
;;
|
||
INVITE)
|
||
join "$forum"
|
||
raw "PRIVMSG %s :Thanks for the invitation, %s." "$forum" "$sender"
|
||
;;
|
||
esac | while read -r line; do
|
||
case "$line" in
|
||
*)
|
||
printf "%s\r\n" "${line#}"
|
||
;;
|
||
*)
|
||
printf "PRIVMSG %s :%s\r\n" "$forum" "$line"
|
||
;;
|
||
esac
|
||
done
|
||
|