File: namer.pl

package info (click to toggle)
libbot-basicbot-perl 0.93-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 180 kB
  • sloc: perl: 960; makefile: 2
file content (29 lines) | stat: -rwxr-xr-x 507 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/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();