irc-bot/firebot

36 lines
772 B
Plaintext
Raw Normal View History

2012-05-14 13:37:28 -06:00
#! /bin/sh -e
2010-12-15 22:36:16 -07:00
2012-05-14 13:37:28 -06:00
if ! [ -d $1 ]; then
echo "Usage: $0 BOTDIR"
echo
echo "Starts a new bot with personality defined in BOTDIR."
exit 1
fi
2011-01-07 15:38:20 -07:00
2012-05-14 13:37:28 -06:00
botdir=$(cd $1; pwd)
ircdir=$(cd $(dirname $0); pwd)
export botdir ircdir
nickname=$(cat $botdir/nickname)
realname=$(cat $botdir/realname 2>/dev/null || \
echo "I'm a little printf, short and stdout.")
export nickname realname
2010-12-15 22:36:16 -07:00
2012-05-14 13:37:28 -06:00
if [ -p $botdir/fifo ]; then
mkfifo -m 0600 $botdir/fifo
fifo="-f $botdir/fifo"
export fifo
fi
2010-12-15 22:36:16 -07:00
2012-05-14 13:37:28 -06:00
if [ -x $botdir/connect ]; then
$botdir/connect $ircdir/connect-handler
else
server=$(cat $botdir/server)
if [ -z "$server" ]; then
echo "$0: no server specified in $botdir/server"
exit 1
fi
socat TCP:$server EXEC:$ircdir/connect-handler
fi