Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Matts (1087)

  (email not shown publicly)

I work for MessageLabs [] in Toronto, ON, Canada. I write spam filters, MTA software, high performance network software, string matching algorithms, and other cool stuff mostly in Perl and C.

Journal of Matts (1087)

Monday July 01, 2002
11:56 AM

IRC Bots

[ #6098 ]

I've been working really hard on the POE tutorial lately for OSCon. It's a very long thing to write, since POE is quite in-depth. But it's going to be good.

One of the things that I've come across is that some of the components on CPAN for POE don't exactly work how I'd expect a POE component to work, or certainly not how I'd like them to work.

Take POE::Component::IRC as an example. In order to create a bot that joins a channel you need to do at least 5 things:

  1. Create a PoCo::IRC instance
  2. Create a POE::Session instance, with an _start handler, and a bunch of events that correspond to PoCo::IRC event names
  3. register all your events with the PoCo::IRC instance
  4. in your _start handler, you tell the PoCo::IRC instance to connect to a server
  5. In the irc_001 event handler you join your channel

That seems like an awful lot of work to me... And it doesn't stop there - you have to write your own reconnect code, your own ping code, and so on.

So I wrote a wrapper. It's basically a class that you have to subclass to create a bot. Then you create an instance of your class, passing in the server name, the nick, etc. Then all you have to do is define an irc_001 method in your subclass, and that gets called automatically when you are connected (so you can join channels, etc). The base class also takes care of reconnects and pings and stuff.

Anyway, I'm going to wait until Dennis (the author of PoCo::IRC) has a look at the docs so he can see if he thinks the interface is good, and then I'll upload it to CPAN.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.