Bot-Cobalt

 view release on metacpan or  search on metacpan

lib/Bot/Cobalt/Plugin/Extras/CPAN.pm  view on Meta::CPAN

package Bot::Cobalt::Plugin::Extras::CPAN;
$Bot::Cobalt::Plugin::Extras::CPAN::VERSION = '0.021003';
use strictures 2;

use Bot::Cobalt;
use Bot::Cobalt::Common;

use Bot::Cobalt::Serializer;
our $Serializer = Bot::Cobalt::Serializer->new('JSON');

use HTTP::Request;

use Module::CoreList;

use Try::Tiny;

our $HelpText
  = 'try: dist, latest, tests, abstract, changes, belongs, license';

## FIXME cachedb?

sub new { bless [], shift }

sub Cobalt_register {
  my ($self, $core) = splice @_, 0, 2;

  register $self, SERVER => qw/
    public_cmd_cpan
    public_cmd_corelist
    mcpan_plug_resp_recv
  /;

  logger->info("Loaded: !cpan");

  PLUGIN_EAT_NONE
}

sub Cobalt_unregister {
  my ($self, $core) = splice @_, 0, 2;
  logger->info("Bye!");
  PLUGIN_EAT_NONE
}

sub Bot_public_cmd_corelist {
  my ($self, $core) = splice @_, 0, 2;
  my $msg = ${ $_[0] };

  my $dist = $msg->message_array->[0];

  unless ($dist) {
    broadcast( 'message',
      $msg->context, $msg->channel,
      "corelist needs a module name."
    );
    return PLUGIN_EAT_ALL
  }

  my $resp;
  my $vers = $msg->message_array->[1];
  if (my $first = Module::CoreList->first_release($dist, $vers)) {
    $resp = $vers ?
            "$dist ($vers) was released with $first"
            : "$dist was released with $first"
  } else {
    $resp = "Module not found in core."
  }

  broadcast( 'message',
    $msg->context, $msg->channel,
    join(', ', $msg->src_nick, $resp)
  );
}

sub Bot_public_cmd_cpan {
  my ($self, $core) = splice @_, 0, 2;



( run in 1.142 second using v1.01-cache-2.11-cpan-39bf76dae61 )