Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-release > by-pkgid > cc0b99298185f49029a5a0b77c54a2f7 > files > 10

perl-Bot-BasicBot-0.930.0-2.mga7.noarch.rpm

#!/usr/bin/perl

=head1 NAME

namer - read out url titles in the channel

=cut

package Bot;
use base qw(Bot::BasicBot);
use warnings;
use strict;
use URI::Title qw( title );
use URI::Find::Simple qw( list_uris );

sub said {
  my $self = shift;
  my $message = shift;
  my $body = $message->{body};
  return unless my @urls = list_uris($message->{body});
  $self->reply($message, title($_)) for (@urls);
}

Bot->new(
  server => "irc.perl.org",
  channels => [ '#jerakeen' ],
  nick => 'namer',
)->run();