Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

poe::component::irc::plugin::nickreclaim(3pm) [debian man page]

POE::Component::IRC::Plugin::NickReclaim(3pm)		User Contributed Perl Documentation	     POE::Component::IRC::Plugin::NickReclaim(3pm)

NAME
POE::Component::IRC::Plugin::NickReclaim - A PoCo-IRC plugin for reclaiming your nickname SYNOPSIS
use strict; use warnings; use POE qw(Component::IRC Component::IRC::Plugin::NickReclaim); my $nickname = 'Flibble' . $$; my $ircname = 'Flibble the Sailor Bot'; my $ircserver = 'irc.blahblahblah.irc'; my $port = 6667; my $irc = POE::Component::IRC->spawn( nick => $nickname, server => $ircserver, port => $port, ircname => $ircname, ) or die "Oh noooo! $!"; POE::Session->create( package_states => [ main => [ qw(_start) ], ], ); $poe_kernel->run(); sub _start { $irc->yield( register => 'all' ); # Create and load our NickReclaim plugin, before we connect $irc->plugin_add( 'NickReclaim' => POE::Component::IRC::Plugin::NickReclaim->new( poll => 30 ) ); $irc->yield( connect => { } ); return; } DESCRIPTION
POE::Component::IRC::Plugin::NickReclaim - A POE::Component::IRC plugin automagically deals with your bot's nickname being in use and reclaims it when it becomes available again. It registers and handles 'irc_433' events. On receiving a 433 event it will reset the nickname to the 'nick' specified with "spawn" or "connect", appendedwith an underscore, and then poll to try and change it to the original nickname. If someone in your channel who has the nickname you're after quits or changes nickname, the plugin will try to reclaim it immediately. METHODS
"new" Takes one optional argument: 'poll', the number of seconds between nick change attempts, default is 30; Returns a plugin object suitable for feeding to POE::Component::IRC's "plugin_add" method. AUTHOR
Chris 'BinGOs' Williams With amendments applied by Zoffix Znet SEE ALSO
POE::Component::IRC perl v5.14.2 2011-12-07 POE::Component::IRC::Plugin::NickReclaim(3pm)

Check Out this Related Man Page

POE::Component::IRC::Cookbook::BasicBot(3pm)		User Contributed Perl Documentation	      POE::Component::IRC::Cookbook::BasicBot(3pm)

NAME
POE::Component::IRC::Cookbook::BasicBot - A basic IRC bot SYNOPSIS
This a very basic bot that connects to IRC, joins a few channels, and announces its arrival. DESCRIPTION
We start off quite simply: #!/usr/bin/env perl use strict; use warnings; Then we "use" the stuff we're going to...well, use. "::State" is a subclass which keeps track of state information related to channels and nicknames. It is needed by the "AutoJoin" plugin which takes care of keeping us on our channels. use POE; use POE::Component::IRC::State; use POE::Component::IRC::Plugin::AutoJoin; Next up is our POE session. We create it and list our event handlers. We then start the POE kernel. POE::Session->create( package_states => [ main => [ qw(_start irc_join) ] ] ); $poe_kernel->run(); Now all we have to do is write the handlers for "_start" and "irc_join". In "_start", we create our IRC component, add an "AutoJoin" plugin, register for the "irc_join" event, and connect to the IRC server. sub _start { my $irc = POE::Component::IRC::State->spawn( Nick => 'basic_bot', Server => 'irc.freenode.net', ); $irc->plugin_add('AutoJoin', POE::Component::IRC::Plugin::AutoJoin->new( Channels => [ '#test_channel1', '#test_channel2' ] )); $irc->yield(register => 'join'); $irc->yield('connect'); } Now comes our "irc_join" event handler. We send a message to the channel once we've joined it. sub irc_join { my $nick = (split /!/, $_[ARG0])[0]; my $channel = $_[ARG1]; my $irc = $_[SENDER]->get_heap(); # only send the message if we were the one joining if ($nick eq $irc->nick_name()) { $irc->yield(privmsg => $channel, 'Hi everybody!'); } } That's it! AUTHOR
Hinrik Oern Sigur`sson, hinrik.sig@gmail.com perl v5.14.2 2011-12-07 POE::Component::IRC::Cookbook::BasicBot(3pm)
Man Page