Changeset 23947

Show
Ignore:
Timestamp:
11/17/08 20:03:54 (5 years ago)
Author:
daisuke
Message:

fix error case

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Morris/trunk/lib/Morris/Plugin/Channel/PeekURL.pm

    r23946 r23947  
    1111    is => 'rw', 
    1212    isa => 'LWP::UserAgent', 
    13     default => sub { LWP::UserAgent->new(agent => 'Morris IRCBot/peekURL plugin') }, 
     13    default => sub { LWP::UserAgent->new(timeout => 10, agent => 'Morris IRCBot/peekURL plugin') }, 
    1414); 
    1515 
     
    4242        my $res = $self->user_agent->get($uri); 
    4343        if (! $res->is_success ) { 
    44             $self->irc_notice($args->{message}->channel, $res->message); 
     44            $self->connection->irc_notice({ 
     45                channel => $args->{message}->channel, 
     46                message => $res->message 
     47            }); 
     48            next; 
     49        } 
     50 
     51        if ( $res->content_type !~ /\btext\/html\b/i) { 
     52            $self->connection->irc_notice({ 
     53                channel => $args->{message}->channel,  
     54                message => sprintf( "%s [%s]", $uri, $res->content_type ) 
     55            }); 
    4556            next; 
    4657        } 
     
    5465            ); 
    5566            $p->strict_comment(1); 
    56             $p->parse_content($res->content); 
     67            $p->parse_content($res->decoded_content); 
    5768            my $title = $p->find_by_tag_name('title'); 
    5869            if ($title) {