|Welcome to the Monastery|
I have been working on a resource list for basic IRC programming in Perl. I noticed that there was no comprehensive tutorial node on perlmonks that discusses IRC programming, which is something I happened to have been reading about a lot lately. So I have written up a draft for the tutorials section or Q&A. I could use any advice you can offer involving content that needs to be added or sections that need to be modified. I definitely want to add more detail to the modules and server sections, and I was debating whether or not I should add some of my own code, as there is already plenty of fine example code elsewhere (which is linked from my node anyway). But if you see a reason for doing it over, I could maybe throw together a simple bot or something to illustrate some basic concepts.
It's not meant to be a full tutorial - there have been plenty written already. I just wanted to give people enough to enable them to learn more on their own. Here's what I've got so far. What would you change about it?
IRC Programming In PerlRecently, I have started teaching myself how to write Perl programs for IRC (Internet Relay Chat). Here is a listing of a few resources that I have found helpful for learning to write my own IRC clients and servers in Perl.
Basic IRC UsageIf you haven't used IRC yet, it would probably be a good idea to play around with someone elses client, before you bother trying to write your own. IRC is a great tool for anyone learning to program Perl -- it is a great way to get real-time assistance, share your knowledge with other people, and just talk about interesting topics related to Perl. Check out the #Perl and #PerlHelp channels at irc.efnet.org, as well as the #Perl channel at irc.freenode.net
Please be sure to read the guidelines for the channels before you post to them...
For those of you who have not used IRC before, or who need a quick refresher, here is a listing of IRC Commands
Be sure you use it safely:
And here's a more detailed reference:
IRC Help Directory
IRC Clients that run Perl Scripts:A great way to practice your Perl programming skills is to get a lightweight IRC client that is configured and operated via Perl scripts -- two such clients are sirc && irssi. And using a simple client is generally a more secure method of connecting to IRC than using a bloated (read: buggy & insecure) graphical client.
The irssi website has a large collection of scripts that you can look through to learn a bit about how they are written. You can find that collection below, as well as a link to a guide to writing Perl scripts for irsii:
Irssi Script Collection
irssi - Perl Scripting Reference
Irssi - Juerd's Site
There are many other clients to choose from as well -- a quick Google search for "irc client" will give you an idea of what's available to you.
Perl Modules For IRCThere are several modules on CPAN related to IRC. Here are some of those most commonly used:
As I mentioned earlier, although it might be useful to learn how to use Net::IRC (for things like modifying legacy code that uses it, etc), for the most part you will want to use POE::Component::IRC. It will make your life much easier.
Writing IRC BotsProgramming your own IRC bots is fun and is a great method for practicing all manner of programming skills -- especially linguistics and pattern matching. Analyzing the text from so many different people speaking, is quite a challenge. Plus it can be quite entertaining. But just be sure that your bot doesn't become a nuisance and interfere with other people's discussions or eat up the server's resources with needless chatter. Be respectful!
The following is a great beginner's resource for programming your own simple IRC bots using the Net::IRC module:
Programming IRC Bots In Perl
Note: You will probably want to start using the POE::Component::IRC module instead. However by learning the Net::IRC module, you might gain a deeper understanding of the POE::Component::IRC method, as you will have to build the event handling functionality in yourself.
The POE Cookbook has an excellent set of resources on programming IRC bots using the Perl Object Environment modules. They POE::Component modules' documentation is also excellent, so if you want to know about it, that will be the great place to start (here's that link again POE::Component::IRC)
There are also several CPAN bot modules. Check out these modules if you want to see some working bot code:
Running an IRC ServerIt is quite easy to use Perl to write your own IRC server programs as well. For this, you will likely want to use the POE::Component::Server::IRC module. Like its client counterpart, the documentation is excellent:
To allow users to engage in meaningful conversation, you have to filter out a lot of garbage that floats in from the internet. This will help you with that:
IRC Operator's Guide
And of course, the usual rules still apply -- always be very cautious when allowing strangers to connect to services running on your server. If you are planning to start your own server, and you haven't read the security guide above, perhaps now is a good time to do so...
The IRC ProtocolAnd if you really want to get down. Here are some resources on the technical details behind the IRC protocols:
RFC 1459: Internet Relay Chat Protocol
RFC 2810: Internet Relay Chat: Architecture
RFC 2811: Internet Relay Chat: Channel Management
RFC 2812: Internet Relay Chat: Client Protocol
RFC 2813: Internet Relay Chat: Server Protocol
There is much more out there, but hopefully, once you have looked over the stuff above, you will know where to go from here.