The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

POE::Component::IRC::Plugin::SigFail - make witty error/no result messages

SYNOPSIS

    use strict;
    use warnings;

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

    my $irc = POE::Component::IRC->spawn(
        nick        => 'FailBot',
        server      => 'irc.freenode.net',
        port        => 6667,
        ircname     => 'FAIL BOT',
        plugin_debug => 1,
    );

    POE::Session->create(
        package_states => [
            main => [ qw(_start  irc_001  irc_public  _default) ],
        ],
    );

    $poe_kernel->run;

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

        $irc->plugin_add(
            'SigFail' =>
                POE::Component::IRC::Plugin::SigFail->new
        );

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

    sub irc_public {
        $irc->yield( privmsg => '#zofbot' => '<irc_sigfail:FAIL>' );
    }

    sub irc_001 {
        $irc->yield( join => '#zofbot' );
    }

DESCRIPTION

This is a silly little module which allows you to spice up your "error" or "no result" messages with a little wit. It is to be used as a plugin for POE::Component::IRC.

CONSTRUCTOR

new

    # plain
    $irc->plugin_add(
        'SigFail' => POE::Component::IRC::Plugin::SigFail->new
    );

    # strawberry-vanilla
    $irc->plugin_add(
        'SigFail' => POE::Component::IRC::Plugin::SigFail->new(
            tag         => qr/<irc_sigfail:([^>]+)>/,
            messages    => [
                q|No idea|,
                q|No clue|,
            ],
            extra       => [
                q|Wtf is that?|,
                q|Umm.. Google it|,
            ],
            sigfail     => 1,
        )
    );

Constructs and returns a new POE::Component::IRC::Plugin::SigFail object which is suitable to be fed into plugin_add method of POE::Component::IRC object.

The constructor takes a few arguments all of which are optional and are passed as key/value pairs. All arguments can be changed dynamically by assigning to them as hashref keys in your plugin's object. In other words, if you want to change the value of sigfail argument you can simply do $your_sigfail_plugin_object->{sigfail} = 0;. The possible arguments are as follows:

tag

    ->new( tag => qr/<irc_sigfail:([^>]+)>/, );

Optional. The way the plugin works is it looks for special "tags" in outgoing privmsg and notice messages. The "tag" is a regex (qr//) which is given as a value to constructor's tag argument. The regex must have one capturing group of parenthesis. When sigfail argument (see below) is set to a true value the plugin will replace the entire "tag" with one of the "witty messages". If sigfail argument is set to a false value, the "tag" will be replaced with whatever was captured by capturing ground of parentheses. This allows you to specify "real" error/no result messages in your tags and dynamically change values of sigfail argument in case you need to know the actual message. Defaults to: qr/<irc_sigfail:([^>]+)>/.

messages

    ->new( messages => [
                q|No idea|,
                q|No clue|,
            ],
    );

Optional. The messages argument is the heart of the plugin. It takes an arrayref as a value elements of which are "witty messages" with which the tag will be replaced. The default set of messages is presented in "MESSAGES" section below. If you want to just add a few more messages see the extra argument below. If you have some nice and funny messages suitable for this plugin please tell me about them at zoffix@cpan.org and I will be more than happy to add them to the "core". Defaults to: an arrayref containing all the messages presented in "MESSAGES" section below.

extra

    ->new( extra => [
                q|Wtf is that?|,
                q|Umm.. Google it|,
            ],
    );

Optional. If you simply to want to add a few messages of your own instead of completely replacing the messages arrayref (see above) simply assign them to extra argument. The extra argument takes an arrayref as a value elements of which will be appended to messages arrayref (see description above). Defaults to: [] (empty arrayref).

sigfail

    ->new( sigfail => 1, );

Optional. This is the "controlling switch" of the plugin. It takes either true or false values as a value. When set to a true value the "tag" (see above) will be replaced with one of the witty messages given via messages argument. When set to a false value the "tag" will be replaced with whatever was captured in the first group of capturing parenthesis of the tag argument's regex (see above). Defaults to: 1

MESSAGES

The following are default "witty messages" with which you "tag" will be replaced; i.e. the default elements of messages argument arrayref.

    [
        q|No idea|,
        q|No clue|,
        q|Wtf is that?|,
        q|Umm.. Google it|,
        q|Come again?|,
        q|Trying to be funny?|,
        q|Umm, I gotta run, talk to you later!|,
        q|Leave me alone|,
        q|Do I have to know that?|,
        q|My dum-dum wants gum-gum|,
        q|Pay me!|,
        q|Hold on a sec... just wait...umm I'll be right back!!|,
        q|$SIG{FAIL}|,
        q|Mooooooo-o-o|,
        q|Huh?|,
        q|Waddayawant?!|,
        q|Yeah, right!! Keep on waiting!|,
        q|*yawn*|,
        q|Don't leave! I'm coming!|,
        q|Where is my sugar?|,
        q|I'm not that smart :(|,
        q|lalalala-lala-lala|,
        q|me iz teh suck, ask some1 else|,
        q|must.... eat... batteries..|,
        q|Something tells me you are trying to fool me...|,
        q|NO! I will NOT tell you that!|,
        q|Stop picking on bots, you racist!!|,
        q|Do you have to bug me so much just because I am a bot?|,
        q|01001011101111010000110101100011! Read that!|,
        q|Not enough megahurts :(|,
        q|Can't tell you, it's a secret!|,
        q|Hrooop, something's broke!|,
        q|If you don't know, why should I? >:O|,
    ];

EXAMPLES

The examples/ directory of this distribution contains a fail_bot.pl script which is an IRC bot which responds with a sigfail message every time there is a public message in the channel.

REPOSITORY

Fork this module on GitHub: https://github.com/zoffixznet/POE-Component-IRC-PluginBundle-Toys

BUGS

To report bugs or request features, please use https://github.com/zoffixznet/POE-Component-IRC-PluginBundle-Toys/issues

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

AUTHOR

Zoffix Znet <zoffix at cpan.org> (http://zoffix.com/, http://haslayout.net/)

LICENSE

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.