GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
POE::Component::IRC::Object(3) User Contributed Perl Documentation POE::Component::IRC::Object(3)

POE::Component::IRC::Object - A slightly simpler OO interface to PoCoIRC

  package ElizaBot;
  use Chatbot::Eliza;
  use POE;
  use POE::Component::IRC::Object;
  use base qw(POE::Component::IRC::Object);
  
  BEGIN { $chatbot = Chatbot::Eliza->new(); }
  
  sub irc_001 {
    $_[OBJECT]->join( "#elizabot" );
    print "Joined channel #elizabot\n";
  }
  
  sub irc_public {
    my ($self, $kernel, $who, $where, $msg) = 
      @_[OBJECT, KERNEL, ARG0, ARG1, ARG2];
    
    $msg =~ s/^doctor[:,]?\s+//;
    
    my ($nick, undef) = split(/!/, $who, 2);
    my $channel = $where->[0];
    
    my $response = $chatbot->transform($msg);
    $self->privmsg( $channel, "$nick: $response" );
  }
  
  sub irc_join {
    my ($self, $who, $channel) = 
      @_[OBJECT, ARG0, ARG1];
    
    my ($nick, undef) = split(/!/, $who, 2);
    $self->privmsg( $channel, "$nick: How can I help you?" );
  }
  
  package main;
  use POE;
  
  ElizaBot->new(
    Nick => 'doctor',
    Server => 'grou.ch',
    Port => 6667,
  );
  
  $poe_kernel->run();
  exit(0);

Quite simply, I didn't like the way the module POE::Component::IRC worked. I felt like it required me to do too many things - create a PoCo::IRC instance for each IRC client, and then create a session, and in the "_start" for the session I was supposed to connect to the server and do all the right things.

For an IRC client that connects to multiple channels from one piece of code this is good. But for me it was too flexible. So I wrote this module.

Oh, and this module also saves you some typing.

Basic usage is to create a subclass of this module. In that subclass define events according to the event names in POE::Component::IRC.

This module has pretty good reconnect code in (i.e. reconnect if we get disconnected by accident, and keep retrying indefinitely). But it will break if you redefine the irc_error, irc_connected, or reconnect methods. So don't do that ;-)

Any methods that you call on the object will be passed through as "$kernel-"post()> calls to the underlying POE::Component::IRC object. This makes it very easy to return messages, via "$self->privmsg($channel, $text)" and so on.

Probably some. Some may consider it a bug that the whole module uses AUTOLOAD and _default to send calls to the right place.

This is free software. You may use and distribute it under the same terms as perl itself.

Matt Sergeant - matt@sergeant.org
2002-07-02 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.