POE::Component::IRC 4.93
Sponsored Links
POE::Component::IRC 4.93 Ranking & Summary
File size:
0.23 MB
Platform:
Any Platform
License:
Perl Artistic License
Price:
Downloads:
1227
Date added:
2006-06-15
Publisher:
Dennis Taylor
POE::Component::IRC 4.93 description
POE::Component::IRC is a fully event-driven IRC client module.
SYNOPSIS
# A simple Rot13 encryption bot
use strict;
use warnings;
use POE qw(Component::IRC);
my $nickname = Flibble . $$;
my $ircname = Flibble the Sailor Bot;
my $ircserver = irc.blahblahblah.irc;
my $port = 6667;
my @channels = ( #Blah, #Foo, #Bar );
# We create a new PoCo-IRC object and component.
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(_default _start irc_001 irc_public) ],
],
heap => { irc => $irc },
);
$poe_kernel->run();
exit 0;
sub _start {
my ($kernel,$heap) = @_[KERNEL,HEAP];
# We get the session ID of the component from the object
# and register and connect to the specified server.
my $irc_session = $heap->{irc}->session_id();
$kernel->post( $irc_session => register => all );
$kernel->post( $irc_session => connect => { } );
undef;
}
sub irc_001 {
my ($kernel,$sender) = @_[KERNEL,SENDER];
# Get the components object at any time by accessing the heap of
# the SENDER
my $poco_object = $sender->get_heap();
print "Connected to ", $poco_object->server_name(), "n";
# In any irc_* events SENDER will be the PoCo-IRC session
$kernel->post( $sender => join => $_ ) for @channels;
undef;
}
sub irc_public {
my ($kernel,$sender,$who,$where,$what) = @_[KERNEL,SENDER,ARG0,ARG1,ARG2];
my $nick = ( split /!/, $who )[0];
my $channel = $where->[0];
if ( my ($rot13) = $what =~ /^rot13 (.+)/ ) {
$rot13 =~ tr[a-zA-Z][n-za-mN-ZA-M];
$kernel->post( $sender => privmsg => $channel => "$nick: $rot13" );
}
undef;
}
# We registered for all events, this will produce some debug info.
sub _default {
my ($event, $args) = @_[ARG0 .. $#_];
my @output = ( "$event: " );
foreach my $arg ( @$args ) {
if ( ref($arg) eq ARRAY ) {
push( @output, "[" . join(" ,", @$arg ) . "]" );
} else {
push ( @output, "$arg" );
}
}
print STDOUT join , @output, "n";
return 0;
}
POE::Component::IRC is a POE component (whod have guessed?) which acts as an easily controllable IRC client for your other POE components and sessions. You create an IRC component and tell it what events your session cares about and where to connect to, and it sends back interesting IRC events when they happen. You make the client do things by sending it events. Thats all there is to it. Cool, no?
[Note that using this module requires some familiarity with the details of the IRC protocol. Id advise you to read up on the gory details of RFC 1459
before you get started. Keep the list of server numeric codes handy while you program. Needless to say, youll also need a good working knowledge of POE, or this document will be of very little use to you.]
The POE::Component::IRC distribution has a docs/ folder with a collection of salient documentation including the pertinent RFCs.
POE::Component::IRC consists of a POE::Session that manages the IRC connection and dispatches irc_ prefixed events to interested sessions and an object that can be used to access additional information using methods.
Sessions register their interest in receiving irc_ events by sending register to the component. One would usually do this in your _start handler. Your session will continue to receive events until you unregister. The component will continue to stay around until you tell it not to with shutdown.
The SYNOPSIS demonstrates a fairly basic bot.
SYNOPSIS
# A simple Rot13 encryption bot
use strict;
use warnings;
use POE qw(Component::IRC);
my $nickname = Flibble . $$;
my $ircname = Flibble the Sailor Bot;
my $ircserver = irc.blahblahblah.irc;
my $port = 6667;
my @channels = ( #Blah, #Foo, #Bar );
# We create a new PoCo-IRC object and component.
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(_default _start irc_001 irc_public) ],
],
heap => { irc => $irc },
);
$poe_kernel->run();
exit 0;
sub _start {
my ($kernel,$heap) = @_[KERNEL,HEAP];
# We get the session ID of the component from the object
# and register and connect to the specified server.
my $irc_session = $heap->{irc}->session_id();
$kernel->post( $irc_session => register => all );
$kernel->post( $irc_session => connect => { } );
undef;
}
sub irc_001 {
my ($kernel,$sender) = @_[KERNEL,SENDER];
# Get the components object at any time by accessing the heap of
# the SENDER
my $poco_object = $sender->get_heap();
print "Connected to ", $poco_object->server_name(), "n";
# In any irc_* events SENDER will be the PoCo-IRC session
$kernel->post( $sender => join => $_ ) for @channels;
undef;
}
sub irc_public {
my ($kernel,$sender,$who,$where,$what) = @_[KERNEL,SENDER,ARG0,ARG1,ARG2];
my $nick = ( split /!/, $who )[0];
my $channel = $where->[0];
if ( my ($rot13) = $what =~ /^rot13 (.+)/ ) {
$rot13 =~ tr[a-zA-Z][n-za-mN-ZA-M];
$kernel->post( $sender => privmsg => $channel => "$nick: $rot13" );
}
undef;
}
# We registered for all events, this will produce some debug info.
sub _default {
my ($event, $args) = @_[ARG0 .. $#_];
my @output = ( "$event: " );
foreach my $arg ( @$args ) {
if ( ref($arg) eq ARRAY ) {
push( @output, "[" . join(" ,", @$arg ) . "]" );
} else {
push ( @output, "$arg" );
}
}
print STDOUT join , @output, "n";
return 0;
}
POE::Component::IRC is a POE component (whod have guessed?) which acts as an easily controllable IRC client for your other POE components and sessions. You create an IRC component and tell it what events your session cares about and where to connect to, and it sends back interesting IRC events when they happen. You make the client do things by sending it events. Thats all there is to it. Cool, no?
[Note that using this module requires some familiarity with the details of the IRC protocol. Id advise you to read up on the gory details of RFC 1459
The POE::Component::IRC distribution has a docs/ folder with a collection of salient documentation including the pertinent RFCs.
POE::Component::IRC consists of a POE::Session that manages the IRC connection and dispatches irc_ prefixed events to interested sessions and an object that can be used to access additional information using methods.
Sessions register their interest in receiving irc_ events by sending register to the component. One would usually do this in your _start handler. Your session will continue to receive events until you unregister. The component will continue to stay around until you tell it not to with shutdown.
The SYNOPSIS demonstrates a fairly basic bot.
POE::Component::IRC 4.93 Screenshot
POE::Component::IRC 4.93 Keywords
IRC
POE
SENDER
IRC 4.93
KERNEL
IRC client
events
session
component
client
object
rot13
POE::Component::IRC
POEComponentIRC
POE::Component::IRC 4.93
Libraries
Bookmark POE::Component::IRC 4.93
POE::Component::IRC 4.93 Copyright
WareSeeker periodically updates pricing and software information of POE::Component::IRC 4.93 full version from the publisher, so some information may be slightly out-of-date. You should confirm all information before relying on it. Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future development of POE::Component::IRC 4.93 Edition. Download links are directly from our publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed
Featured Software
Want to place your software product here?
Please contact us for consideration.
Contact WareSeeker.com
Related Information
events in las vegas
sessions at aol
current events
aol sessions
events in seattle
sessions clocks
events and adventures
sessions
irc clients
events in history
sessions clothing
facebook login page user session key
series of unfortunate events
general session court
events management
science current events
session linkin park
sessions clock company
Related Software
POE::Component::Client::Rcon is an implementation of the Rcon remote console protocol. Free Download
POE::Component::Generic is a POE component that provides non-blocking access to a blocking object. Free Download
POE::Component::Server::IRC is a fully event-driven networkable IRC server daemon module. Free Download
POE::Component::OSCAR is a POE component for the Net::OSCAR module. Free Download
POE::Component::Growl provides a Growl notification dispatcher for POE. Free Download
POE::Component::Proxy::TCP is a simplified TCP proxy. Free Download
POE::Component::Client::Ping is a non-blocking ICMP ping client. Free Download
POE::Component::Client::HTTP is a HTTP user-agent component. Free Download
Latest Software
Popular Software
Favourite Software