irc-bot/bot

25 lines
536 B
Bash
Executable File

#! /bin/sh -e
botdir=$1
d=$(dirname $0)
nickname=$(cat $botdir/nickname)
realname=$(cat $botdir/realname 2>/dev/null || \
echo "I'm a little printf, short and stdout.")
export nickname realname
(
# UCSPI wants input on FD 7, and sets $PROTO
[ -n "$PROTO" ] && exec 1>&7
if [ -x $botdir/login ]; then
$botdir/login
else
echo "NICK $nickname"
echo "USER $nickname $nickname $nickname :$realname"
fi
)
mkfifo -m 0600 $botdir/fifo
exec $d/dispatch -f $botdir/fifo $d/irc $botdir/handler