View on
Zoffix Znet > POE-Component-IRC-PluginBundle-Toys-1.001001 > POE::Component::IRC::Plugin::YouAreDoingItWrong



Annotate this POD


View/Report Bugs
Module Version: 1.001001   Source  


POE::Component::IRC::Plugin::YouAreDoingItWrong - show people what they are doing wrong by giving links to images.


    use strict;
    use warnings;

    use POE qw(Component::IRC Component::IRC::Plugin::YouAreDoingItWrong);

    my $irc = POE::Component::IRC->spawn(
            nick    => 'WrongBot',
            server  => '',
            port    => 6667,
            ircname => 'You Are Doing It Wrong Bot',
    ) or die "Oh noes :( $!";

        package_states => [
            main => [ qw( _start  irc_001 ) ],


    sub _start {
        $irc->yield( register => 'all' );

        # register our plugin
            'Wrong' => POE::Component::IRC::Plugin::YouAreDoingItWrong->new

        $irc->yield( connect => { } );

    sub irc_001 {
        my ( $kernel, $sender ) = @_[ KERNEL, SENDER ];
        $kernel->post( $sender => join => '#zofbot' );



    [13:00:27] <Zoffix> WrongBot, doing it wrong Zoffix
    [13:00:27] <WrongBot> Zoffix, you are doing it wrong:
    [13:00:41] <Zoffix> WrongBot, doing it wrong
    [13:00:42] <WrongBot> You are doing it wrong:


The module is a POE::Component::IRC plugin which, when triggered, fetches links to images from and posts them into the channel, optionally addressing a specific person.



        'Wrong' => POE::Component::IRC::Plugin::YouAreDoingItWrong->new

        'Wrong' => POE::Component::IRC::Plugin::YouAreDoingItWrong->new(
            auto           => 0,                 # do not auto respond
            trigger        => qr/^wrong/i,       # trigger
            banned         => [ qr/aol\.com$/ ], # ignore AOL users
            response_event => 'diw_event',       # event to send response to
            debug          => 1,                 # enable some debug output

Returns a POE::Component::IRC::Plugin object suitable to be fed to POE::Component::IRC plugin_add() method. Takes a few arguments, all of which are optional. The arguments may be as follows:


    ->new( auto => 1 );

Optional. The auto argument specifies whether or not the plugin should auto respond with privmsg to the channel when triggered. If auto is set to a true value the plugin will automatically respond when triggered, when auto is set to a false value the plugin will not send any messages to the server and you'll have to listen to the event emitted by the plugin (see below). In other words, if you are unhappy with the default behaviour you may turn auto off (by setting it to a false value) and set up a handler on the plugin event to do exactly what you want. Defaults to: 1


    ->new( trigger => qr/^doing it wrong/i );

Optional. Takes a regex as an argument which specifies the trigger for the plugin. Defaults to: qr/^doing it wrong/i Note: plugin responds to addressed messages, In other words, if you set the trigger to qr/^diw/i and your bot's nick name is WrongBot the plugin will be triggered by saying WrongBot, diw. Note 2: if after removing bot's nickname and the trigger the left over will match m/(\S+)\s*$/ the capture will be prepended to the output, this is so you could address a specific person:

    [13:00:27] <Zoffix> WrongBot, doing it wrong Zoffix
    [13:00:27] <WrongBot> Zoffix, you are doing it wrong:
    [13:00:41] <Zoffix> WrongBot, doing it wrong
    [13:00:42] <WrongBot> You are doing it wrong:


    ->new( banned => [ qr/aol\.com$/ ] );

Optional. Takes an arrayref of regexes as an argument. If the user mask of the person who triggered the plugin matches any of the regexes in the banned arrayref the plugin will ignore that person. Defaults to: [] (no bans are set)


    ->new( response_event => 'diw_event' );

Optional. Specifies the name of the event to emit when plugin is triggered. See EMITTED EVENTS section for details. Defaults to: irc_you_are_doing_it_wrong_response


    ->new( debug => 1 );

Optional. When set to a true value plugin will print out a bit of debug information. Defaults to: 0 (no debug info is printed out)


    ->new( eat => 0 );

If set to a false value plugin will return a PCI_EAT_NONE after responding. If eat is set to a true value, plugin will return a PCI_EAT_ALL after responding. See POE::Component::IRC::Plugin documentation for more information if you are interested. Defaults to: 1



    $VAR1 = {
        'what' => 'WrongBot, doing it wrong',
        'who' => 'Zoffix!n=Zoffix@unaffiliated/zoffix',
        'channel' => '#zofbot',
        'nick_to_address' => undef,
        'error' => undef,
        'pic' => bless( do{\(my $o = '')}, 'URI::http' )

The event handler set up to handle the event, name of which you can specify in the response_event of the constructor (it defaults to irc_you_are_doing_it_wrong_response) will receive input from the plugin every time it's triggered. The input will come in the form of a hashref in ARG0. The keys of that hashref are as follows:


    { 'what' => 'WrongBot, doing it wrong' }

The what key will contain the message which triggered the plugin.


    { 'who' => 'Zoffix!n=Zoffix@unaffiliated/zoffix' }

The who key will contain the mask of the user who triggered the plugin.


    { 'nick_to_address' => undef }

The nick_to_address key will contain the nick of the person to address if the plugin was triggered in the "address someone" mode (see description of the trigger argument to the constructor) or undef if plugin was triggered in normal mode.


    { error => undef }

If an error occurred during while fetching the link to a random image on the error key will contain the error message, otherwise it will be undef.


    { 'pic' => bless( do{\(my $o = '')}, 'URI::http' ) }

If no errors occurred (see error above), the pic key will contain a URI object pointing to one of the images on


Fork this module on GitHub:


To report bugs or request features, please use

If you can't access GitHub, you can email your request to bug-POE-Component-IRC-PluginBundle-Toys at


Zoffix Znet <zoffix at> (,


You can use and distribute this module under the same terms as Perl itself. See the LICENSE file included in this distribution for complete details.

syntax highlighting: