App::Hachero::Plugin::Classify::Robot - plugin that marks robot request


App-Hachero documentation Contained in the App-Hachero distribution.

Index


Code Index:

NAME

Top

App::Hachero::Plugin::Classify::Robot - plugin that marks robot request

SYNOPSYS

Top

  ---
  plugins:
    - module: Classify::Robot
      config:
        filter: 1

DESCRIPTION

Top

A plugin that marks robot request. excludes robot request if you pass 1 to filter configuration.

implemented hooks

* classify

AUTHOR

Top

Takaaki Mizuno <cpan@takaaki.info>

Nobuo Danjou <nobuo.danjou@gmail.com>

SEE ALSO

Top

App::Hachero


App-Hachero documentation Contained in the App-Hachero distribution.

package App::Hachero::Plugin::Classify::Robot;
use strict;
use warnings;
use base qw(App::Hachero::Plugin::Base);

sub classify : Hook {
    my ($self, $context, $args) = @_;
    my $ua = $context->currentlog->{ua} or return;
    $context->currentinfo->{is_robot} = $ua =~ /googlebot|slurp/ ? 1 : 0;
    if( $context->currentinfo->{is_robot} ){
        if( $self->config->{config} && 
                $self->config->{config}->{filter} == 1 ){
            $context->currentline( '' );
        }
    }
}

1;
__END__