NAME

POE::Component::IRC::Plugin::AutoJoin - A PoCo-IRC plugin which keeps you on your favorite channels throughout reconnects and even kicks.

SYNOPSIS

 use POE qw(Component::IRC::State Component::IRC::Plugin::AutoJoin);

 my $nickname = 'Chatter';
 my $server = 'irc.blahblahblah.irc';

 my %channels = (
     '#Blah'   => '',
     '#Secret' => 'secret_password',
     '#Foo'    => '',
 );
 
 POE::Session->create(
     package_states => [
         main => [ qw(_start irc_join) ],
     ],
 );

 $poe_kernel->run();

 sub _start {
     my $irc = POE::Component::IRC::State->spawn( 
         Nick => $nickname,
         Server => $server,
     ) or die "Oh noooo! $!";

     $irc->plugin_add('AutoJoin', POE::Component::IRC::Plugin::AutoJoin->new( Channels => \%channels ));
     $irc->yield(register => qw(join);
     $irc->yield(connect => { } );
 }
 
 sub irc_join {
     my $chan = @_[ARG1];
     $irc->yield(privmsg => $chan => "hi $channel!");
 }

DESCRIPTION

POE::Component::IRC::Plugin::AutoJoin is a POE::Component::IRC plugin. If you get disconnected, the plugin will join all the channels you were on the next time it gets connected to the IRC server. It can also rejoin a channel if the IRC component gets kicked from it. It keeps track of channel keys so it will be able to rejoin keyed channels in case of reconnects/kicks.

This plugin requires the IRC component POE::Component::IRC::State or a subclass thereof.

METHODS

new

Two optional arguments:

'Channels', either an array reference of channel names, or a hash reference keyed on channel name, containing the password for each channel. By default it uses the channels the component is already on, if any.

'RejoinOnKick', set this to 1 if you want the plugin to try to rejoin a channel (once) if you get kicked from it. Default is 0.

Returns a plugin object suitable for feeding to POE::Component::IRC's plugin_add() method.

AUTHOR

Hinrik Örn Sigurðsson, hinrik.sig@gmail.com