Jan. 15, 2011, 2:38 p.m.
posted by voila
Introduction: Hacks #31-39
Programming IRC bots is fun and allows you to be very creative, as you are responsible for everything they say and do. Later chapters will show you how to create all sorts of IRC bots to log channels, create comic strips, pass on messages, share files, and so on. The limit is your imagination.
The first step in creating your own IRC bot is to understand the basic handshake that goes on when you connect to an IRC server. An example is given, showing you how to connect to an IRC server using no more than a basic Telnet application. Once connected, you can use Telnet to join channels and send messages to people. This illustrates the simplicity of the text-based IRC protocol, and the chapter continues by showing you how to write simple Perl, Java, and Python programs to connect to IRC.
This chapter also introduces some libraries for connecting to IRC. This lets you forget about the intricacies of the IRC protocol and concentrate on the functionality of your IRC bot. This covers the Net::IRC module for Perl, the PircBot package for Java, and the IRCLib module for Python.
Of course, one can perform many tasks with IRC bots, and not all of them are good. The chapter is rounded off with a brief discussion of the ethics of running IRC bots.