Sunday, August 17, 2008

A simple IRC Logger-bot in Bash

The script :

## Bot.sh - begin
#!/bin/bash
config=/tmp/ircbot

echo NICK ircbot > $config
echo USER username +iw ircbot :$0 >> $config
echo JOIN #orkut_linux >> $config

tail -f $config | telnet irc.freenode.net 6667 | while true
do read MESSAGE || break
echo $MESSAGE >> irclog.txt
done

rm $config
## EOF

Make Bot.sh executable:

chmod +x Bot.sh

Now all that's left is to run it.
Enjoy!

1 comment:

Unknown said...

Hi,

Thanks!

I have implemented something similar with my notification system -- astralbot : http://code.google.com/p/astralbot/source/browse/irc-bot.sh

Note that the above will not work, as you need to prepend each message with "PRIVMSG #channel:".

Another problem is with the PING/PONG system. Upon sending the PING command, the server expects a PONG back -- this causes disconnects; I'm working on it.

Callan