Bot::BasicBot::Pluggable::Module::CoreList - IRC frontend to Module::CoreList


Bot-BasicBot-Pluggable-Module-CoreList documentation Contained in the Bot-BasicBot-Pluggable-Module-CoreList distribution.

Index


Code Index:

NAME

Top

Bot::BasicBot::Pluggable::Module::CoreList - IRC frontend to Module::CoreList

SYNOPSIS

Top

    < you> bot: corelist File::Spec
    < bot> File::Spec was first released with perl 5.00503 (released on 1999-03-28)

DESCRIPTION

Top

This module is a frontend to the excellent Module::CoreList module which will let you know what modules shipped with which versions of perl, over IRC.

IRC USAGE

Top

The robot replies to requests in the following form:

    corelist <subcommand> [args]

Commands

The robot understand the following subcommands:

* release
* date
    < you> bot: corelist release Test::More
    < bot> you: Test::More was first released with perl 5.7.3 (patchlevel perl/15039, released on 2002-03-05)

If no command is given, release is the default.

* find
    < you> bot corelist search Data
    < bot> Found Data::Dumper, Module::Build::ConfigData

Perl version numbers can be passed as optional parameters to restrict the search:

    < you> corelist search Data 5.006
    < bot> Found Data::Dumper in perl 5.006

The search never returns more than 9 replies, to avoid flooding the channel:

    < you> bot: corelist find e
    < bot> Found AnyDBM_File, AutoLoader, B::Assembler, B::Bytecode, B::Debug, B::Deparse, B::Disassembler, B::Showlex, B::Terse, ... 

AUTHOR

Top

Philippe "BooK" Bruhat, <book@cpan.org>, inspired by the existing corelist bot, last seen on IRC in May 2006.

BUGS

Top

Please report any bugs or feature requests to bug-bot-basicbot-pluggable-module-corelist@rt.cpan.org, or through the web interface at http://rt.cpan.org/. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT & LICENSE

Top


Bot-BasicBot-Pluggable-Module-CoreList documentation Contained in the Bot-BasicBot-Pluggable-Module-CoreList distribution.

package Bot::BasicBot::Pluggable::Module::CoreList;

use strict;
use Bot::BasicBot::Pluggable::Module;
use Module::CoreList;

use vars qw( @ISA $VERSION );
@ISA     = qw(Bot::BasicBot::Pluggable::Module);
$VERSION = '0.03';

my $ident = qr/[A-Za-z_][A-Za-z_0-9]*/;
my $cmds  = qr/find|search|release|date/;

sub told {
    my ( $self, $mess ) = @_;
    my $bot = $self->bot();

    # we must be directly addressed
    return
        if !( ( defined $mess->{address} && $mess->{address} eq $bot->nick() )
        || $mess->{channel} eq 'msg' );

    # ignore people we ignore
    return if $bot->ignore_nick( $mess->{who} );

    # only answer to our command (which can be our name too)
    my $src = $bot->nick() eq 'corelist' ? 'raw_body' : 'body';
    return
        if $mess->{$src}
        !~ /^\s*corelist(?:\W+($cmds))?\W+(.*)/io;

    # grab the parameter list
    my ( $command, $module, @args ) = ( $1 || 'release', split /\s+/, $2 );

    # compute the reply
    my $reply;
    if ( $command =~ /^(?:find|search)$/i ) {
        my @modules = Module::CoreList->find_modules( qr/$module/, @args );

        # shorten large response lists
        @modules = (@modules[0..8], '...') if @modules > 9;

        local $" = ', ';
        my $where = ( @args ? " in perl @args" : '' );
        $reply = ( @modules
            ? "Found @modules"
            : "Found no module matching /$module/" )
            . $where;
    }
    else {
        my ( $release, $patchlevel, $date )
            = ( Module::CoreList->first_release($module), '', '' );
        if ($release) {
            $patchlevel = $Module::CoreList::patchlevel{$release}
                ? join( "/", @{ $Module::CoreList::patchlevel{$release} } )
                : '';
            $date  = $Module::CoreList::released{$release};
        }
        $reply = $release
            ? "$module was first released with perl $release ("
            . ( $patchlevel ? "patchlevel $patchlevel, " : '' )
            . "released on $date)"
            : "$module is not in the core";
    }

    return $reply;
}

sub help {'corelist [release] module, or corelist find regex [perl versions]'}

1;

__END__