| Bot-BasicBot-Pluggable documentation | Contained in the Bot-BasicBot-Pluggable distribution. |
Bot::BasicBot::Pluggable::Module::Title - speaks the title of URLs mentioned
version 0.93
None. If the module is loaded, the bot will speak the titles of all URLs mentioned.
Defaults to 1; whether or not we should convert all titles to ascii from Unicode
If set to a nonempty string, ignore URLs matching this re
Mario Domgoergen <mdom@cpan.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Bot-BasicBot-Pluggable documentation | Contained in the Bot-BasicBot-Pluggable distribution. |
package Bot::BasicBot::Pluggable::Module::Title; BEGIN { $Bot::BasicBot::Pluggable::Module::Title::VERSION = '0.93'; } use base qw(Bot::BasicBot::Pluggable::Module); use warnings; use strict; use Text::Unidecode; use URI::Title qw(title); use URI::Find::Simple qw(list_uris); use URI; sub help { return "Speaks the title of URLs mentioned."; } sub init { my $self = shift; $self->config( { user_asciify => 1, user_ignore_re => '', user_be_rude => 0, } ); } sub admin { # do this in admin so we always get a chance to see titles my ( $self, $mess ) = @_; my $ignore_regexp = $self->get('user_ignore_re'); my $reply = ""; for ( list_uris( $mess->{body} ) ) { next if $ignore_regexp && /$ignore_regexp/; my $uri = URI->new($_); next unless $uri; if ( $uri->scheme eq "file" ) { next unless $self->get("user_be_rude"); my $who = $mess->{who}; $self->reply( $mess, "Nice try $who, you tosser" ); return; } my $title = title("$_"); next unless defined $title; $title = unidecode($title) if $self->get("user_asciify"); $reply .= "[ $title ] "; } if ($reply) { $self->reply( $mess, $reply ) } return; # Title.pm is passive, and doesn't intercept things. } 1; __END__