README
1NAME
2
3 POE::Component::IRC::Plugin::RSS::Headlines - A POE::Component::IRC
4 plugin that provides RSS headline retrieval.
5
6VERSION
7
8 version 1.10
9
10SYNOPSIS
11
12 use strict;
13 use warnings;
14 use POE qw(Component::IRC Component::IRC::Plugin::RSS::Headlines);
15
16 my $nickname = 'RSSHead' . $$;
17 my $ircname = 'RSSHead the Sailor Bot';
18 my $ircserver = 'irc.perl.org';
19 my $port = 6667;
20 my $channel = '#IRC.pm';
21 my $rss_url = 'http://eekeek.org/jerkcity.cgi';
22
23 my $irc = POE::Component::IRC->spawn(
24 nick => $nickname,
25 server => $ircserver,
26 port => $port,
27 ircname => $ircname,
28 debug => 0,
29 plugin_debug => 1,
30 options => { trace => 0 },
31 ) or die "Oh noooo! $!";
32
33 POE::Session->create(
34 package_states => [
35 'main' => [ qw(_start irc_001 irc_join irc_rssheadlines_items) ],
36 ],
37 );
38
39 $poe_kernel->run();
40 exit 0;
41
42 sub _start {
43 # Create and load our plugin
44 $irc->plugin_add( 'RSSHead' =>
45 POE::Component::IRC::Plugin::RSS::Headlines->new() );
46
47 $irc->yield( register => 'all' );
48 $irc->yield( connect => { } );
49 undef;
50 }
51
52 sub irc_001 {
53 $irc->yield( join => $channel );
54 undef;
55 }
56
57 sub irc_join {
58 my ($kernel,$sender,$channel) = @_[KERNEL,SENDER,ARG1];
59 print STDERR "$channel $rss_url\n";
60 $kernel->yield( 'get_headline', { url => $rss_url, _channel => $channel } );
61 undef;
62 }
63
64 sub irc_rssheadlines_items {
65 my ($kernel,$sender,$args) = @_[KERNEL,SENDER,ARG0];
66 my $channel = delete $args->{_channel};
67 $kernel->post( $sender, 'privmsg', $channel, join(' ', @_[ARG1..$#_] ) );
68 undef;
69 }
70
71DESCRIPTION
72
73 POE::Component::IRC::Plugin::RSS::Headlines, is a POE::Component::IRC
74 plugin that provides a mechanism for retrieving RSS headlines from
75 given URLs.
76
77CONSTRUCTOR
78
79 new
80
81 Creates a new plugin object. Takes the following optional arguments:
82
83 'http_alias', you may provide the alias of an existing POE::Component::Client::HTTP
84 component that the plugin will use instead of spawning it's own;
85 'follow_redirects', this argument is passed to PoCoCl::HTTP to inform it how to deal with
86 following redirects, default is 2;
87
88INPUT EVENTS
89
90 The plugin registers the following state handler within your session:
91
92 get_headline
93
94 Takes a hashref as an argument with the following keys:
95
96 'url', the RSS based url to retrieve items for;
97
98 You may pass arbitary key/value pairs, but the keys must be prefixed
99 with an underscore.
100
101OUTPUT
102
103 The following irc event is generated with the result of a
104 'get_headline' command:
105
106 irc_rssheadlines_items
107
108 Has the following parameters:
109
110 'ARG0', the original hashref that was passed;
111 'ARG1' .. $#_, RSS headline item titles;
112
113 irc_rssheadlines_error
114
115 Has the following parameters:
116
117 'ARG0', the original hashref that was passed;
118 'ARG1', the error text;
119
120SEE ALSO
121
122 POE::Component::IRC
123
124AUTHOR
125
126 Chris Williams
127
128COPYRIGHT AND LICENSE
129
130 This software is copyright (c) 2017 by Chris Williams.
131
132 This is free software; you can redistribute it and/or modify it under
133 the same terms as the Perl 5 programming language system itself.
134
135