NAME POE::Component::IRC::Plugin::WWW::OhNoRobotCom::Search - search http://ohnorobot.com/ website from IRC SYNOPSIS use strict; use warnings; use POE qw(Component::IRC Component::IRC::Plugin::WWW::OhNoRobotCom::Search); my $irc = POE::Component::IRC->spawn( nick => 'OhNoRobotComBot', server => 'irc.freenode.net', port => 6667, ircname => 'Bot for searching ohnorobot.com', ); POE::Session->create( package_states => [ main => [ qw(_start irc_001) ], ], ); $poe_kernel->run; sub _start { $irc->yield( register => 'all' ); $irc->plugin_add( 'OhNoRobot' => POE::Component::IRC::Plugin::WWW::OhNoRobotCom::Search->new( comic_id => 56 # XKCD comics ) ); $irc->yield( connect => {} ); } sub irc_001 { $_[KERNEL]->post( $_[SENDER] => join => '#zofbot' ); } OhNoRobotComBot, comic foo http://xkcd.com/233/ http://xkcd.com/240/ http://xkcd.com/261/ OhNoRobotComBot, comic bar http://xkcd.com/328/ http://xkcd.com/359/ http://xkcd.com/361/ DESCRIPTION This module is a POE::Component::IRC plugin which uses POE::Component::IRC::Plugin for its base. It provides interface to search website from IRC. It accepts input from public channel events, "/notice" messages as well as "/msg" (private messages); although that can be configured at will. CONSTRUCTOR new # plain and simple $irc->plugin_add( 'OhNoRobotCom' => POE::Component::IRC::Plugin::WWW::OhNoRobotCom::Search->new ); # juicy flavor $irc->plugin_add( 'OhNoRobotCom' => POE::Component::IRC::Plugin::WWW::OhNoRobotCom::Search->new( auto => 1, response_event => 'irc_ohnorobot_results', banned => [ qr/aol\.com$/i ], addressed => 1, root => [ qr/mah.net$/i ], trigger => qr/^comics?\s+(?=\S)/i, obj_args => { debug => 1 }, max_results => 3, include => [ qw(all_text meta) ], comic_id => 56, # XKCD comics lucky => 1, listen_for_input => [ qw(public notice privmsg) ], eat => 1, debug => 0, ) ); The "new()" method constructs and returns a new "POE::Component::IRC::Plugin::WWW::OhNoRobotCom::Search" object suitable to be fed to POE::Component::IRC's "plugin_add" method. The constructor takes a few arguments, but *all of them are optional*. Note: most of these arguments can be changed on the fly by changing them as keys in your plugin's object, i.e. "$plug_obj->{banned} = [qr/.*/ ];". The possible arguments/values are as follows: auto ->new( auto => 0 ); Optional. Takes either true or false values, specifies whether or not the plugin should auto respond to requests. When the "auto" argument is set to a true value plugin will respond to the requesting person with the results automatically. When the "auto" argument is set to a false value plugin will not respond and you will have to listen to the events emited by the plugin to retrieve the results (see EMITED EVENTS section and "response_event" argument for details). Defaults to: 1. response_event ->new( response_event => 'event_name_to_recieve_results' ); Optional. Takes a scalar string specifying the name of the event to emit when the results of the request are ready. See EMITED EVENTS section for more information. Defaults to: "irc_ohnorobot_results" banned ->new( banned => [ qr/aol\.com$/i ] ); Optional. Takes an arrayref of regexes as a value. If the usermask of the person (or thing) making the request matches any of the regexes listed in the "banned" arrayref, plugin will ignore the request. Defaults to: "[]" (no bans are set). root ->new( root => [ qr/\Qjust.me.and.my.friend.net\E$/i ] ); Optional. As opposed to "banned" argument, the "root" argument allows access only to people whose usermasks match any of the regexen you specify in the arrayref the argument takes as a value. By default: it is not specified. Note: as opposed to "banned" specifying an empty arrayref to "root" argument will restrict access to everyone. trigger ->new( trigger => qr/^comics?\s+(?=\S)/i ); Optional. Takes a regex as an argument. Messages matching this regex will be considered as requests. See also addressed option below which is enabled by default. Note: the trigger will be removed from the message, therefore make sure your trigger doesn't match the actual data that needs to be processed. Defaults to: "qr/^comics?\s+(?=\S)/i" obj_args ->new( obj_args => { debug => 1 } ); Optional. Takes a hashref as an argument which will be dereferenced directly into POE::Component::WWW::OhNoRobotCom::Search's constructor. See documentation for POE::Component::WWW::OhNoRobotCom::Search for possible arguments. Defaults to: "{}" ( default constructor ) comic_id ->( comic_id => 56 ) Optional. The "comic_id" argument takes a scalar as a value which should be a comic ID number or an empty string which indicates that search should be done on all comics. To obtain the comic ID number go to , "View Source" and search for the name of the comic, when you'll find an