POE::Component::IRC::Plugin::Trac::RSS - A POE::Component::IRC plugin that provides RSS headline retrieval.
use strict; use warnings; use POE qw(Component::IRC Component::IRC::Plugin::Trac::RSS); my $nickname = 'TracRSS' . $$; my $ircname = 'TracRSS Name'; my $ircserver = 'irc.nnnnn.net'; my $port = 6667; my $channel = '#channel'; my $rss_url = 'http://'; my $rss_username = 'username'; my $rss_password = 'password'; my $irc = POE::Component::IRC->spawn( nick => $nickname, server => $ircserver, port => $port, ircname => $ircname, debug => 0, plugin_debug => 1, options => { trace => 0 }, ) or die "Oh noooo! $!"; POE::Session->create( package_states => [ 'main' => [ qw(_start irc_001 irc_join irc_tracrss_items) ], ], ); $poe_kernel->run(); exit 0; sub _start { # Create and load our plugin $irc->plugin_add( 'TracRSS' => POE::Component::IRC::Plugin::Trac::RSS->new() ); $irc->yield( register => 'all' ); $irc->yield( connect => { } ); undef; } sub irc_001 { $irc->yield( join => $channel ); undef; } sub irc_join { my ($kernel,$sender,$channel) = @_[KERNEL,SENDER,ARG1]; print STDERR "$channel $rss_url\n"; $kernel->yield( 'get_tracrss', { url => $rss_url, username => $rss_username, password => $rss_password, _channel => $channel } ); undef; } sub irc_tracrss_items { my ($kernel,$sender,$args) = @_[KERNEL,SENDER,ARG0]; my $channel = delete $args->{_channel}; $kernel->post( $sender, 'privmsg', $channel, join(' ', @_[ARG1..$#_] ) ); undef; }
POE::Component::IRC::Plugin::Trac::RSS, is a POE::Component::IRC plugin that provides a mechanism for retrieving Trac/RSS headlines from given URLs.
Creates a new plugin object. Takes the following optional arguments:
'http_alias', you may provide the alias of an existing POE::Component::Client::HTTP component that the plugin will use instead of spawning it's own; 'follow_redirects', this argument is passed to PoCoCl::HTTP to inform it how to deal with following redirects, default is 2;
The plugin registers the following state handler within your session:
Takes a hashref as an argument with the following keys:
'url', the RSS based url to retrieve items for; 'username', Username to login in trac. 'password', Password to login in trac.
You may pass arbitary key/value pairs, but the keys must be prefixed with an underscore.
The following irc event is generated with the result of a 'get_headline' command:
Has the following parameters:
'ARG0', the original hashref that was passed; 'ARG1' .. $#_, RSS headline item titles;
'ARG0', the original hashref that was passed; 'ARG1', the error text;
Thiago Berlitz Rondon
Copyright (c) Thiago Berlitz Rondon
(c)
This module may be used, modified, and distributed under the same terms as Perl itself. Please see the license that came with your Perl distribution for details.
POE::Component::IRC
To install POE::Component::IRC::Plugin::Trac::RSS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm POE::Component::IRC::Plugin::Trac::RSS
CPAN shell
perl -MCPAN -e shell install POE::Component::IRC::Plugin::Trac::RSS
For more information on module installation, please visit the detailed CPAN module installation guide.